forked from sass/node-sass
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump [email protected] See https://github.com/sass/libsass/releases/tag/3.5.3 * Workaround sass-spec A patch landed in sass-spec that is not compatible with 3.5.
- Loading branch information
Showing
56 changed files
with
19,533 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,20 @@ | ||
LibSass - Sass compiler written in C++ | ||
====================================== | ||
Welcome to the LibSass documentation! | ||
|
||
Currently maintained by Marcel Greter ([@mgreter]) and Michael Mifsud ([@xzyfer]) | ||
Originally created by Aaron Leung ([@akhleung]) and Hampton Catlin ([@hcatlin]) | ||
## First Off | ||
LibSass is just a library. To run the code locally (i.e. to compile your stylesheets), you need an implementer. SassC (get it?) is an implementer written in C. There are a number of other implementations of LibSass - for example Node. We encourage you to write your own port - the whole point of LibSass is that we want to bring Sass to many other languages, not just Ruby! | ||
|
||
[![Unix CI](https://travis-ci.org/sass/libsass.svg?branch=master)](https://travis-ci.org/sass/libsass "Travis CI") | ||
[![Windows CI](https://ci.appveyor.com/api/projects/status/github/sass/libsass?svg=true)](https://ci.appveyor.com/project/sass/libsass/branch/master "Appveyor CI") | ||
[![Coverage Status](https://img.shields.io/coveralls/sass/libsass.svg)](https://coveralls.io/r/sass/libsass?branch=feature%2Ftest-travis-ci-3 "Code coverage of spec tests") | ||
[![Percentage of issues still open](http://isitmaintained.com/badge/open/sass/libsass.svg)](http://isitmaintained.com/project/sass/libsass "Percentage of issues still open") | ||
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/sass/libsass.svg)](http://isitmaintained.com/project/sass/libsass "Average time to resolve an issue") | ||
[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=283068)](https://www.bountysource.com/trackers/283068-libsass?utm_source=283068&utm_medium=shield&utm_campaign=TRACKER_BADGE "Bountysource") | ||
[![Join us](https://libsass-slack.herokuapp.com/badge.svg)](https://libsass-slack.herokuapp.com/ "Slack communication channels") | ||
We're working hard on moving to full parity with Ruby Sass... learn more at the [The-LibSass-Compatibility-Plan](compatibility-plan.md)! | ||
|
||
### Implementing LibSass | ||
|
||
[LibSass](https://github.com/sass/libsass "LibSass GitHub Project") is just a library! | ||
If you want to use LibSass to compile Sass, you need an implementer. Some | ||
implementations are only bindings into other programming languages. But most also | ||
ship with a command line interface (CLI) you can use directly. There is also | ||
[SassC](https://github.com/sass/sassc), which is the official lightweight | ||
CLI tool built by the same people as LibSass. | ||
If you're interested in implementing LibSass in your own project see the [API Documentation](api-doc.md) which now includes implementing | ||
your own [Sass functions](api-function.md). You may wish to [look at other implementations](implementations.md) for your language of choice. | ||
Or make your own! | ||
|
||
### Excerpt of "sanctioned" implementations: | ||
### Contributing to LibSass | ||
|
||
- https://github.com/sass/node-sass (Node.js) | ||
- https://github.com/sass/perl-libsass (Perl) | ||
- https://github.com/sass/libsass-python (Python) | ||
- https://github.com/wellington/go-libsass (Go) | ||
- https://github.com/sass/sassc-ruby (Ruby) | ||
- https://github.com/sass/libsass-net (C#) | ||
- https://github.com/medialize/sass.js (JS) | ||
- https://github.com/bit3/jsass (Java) | ||
| Issue Tracker | Issue Triage | Community Guidelines | | ||
|-------------------|----------------------------------|-----------------------------| | ||
| We're always needing help, so check out our issue tracker, help some people out, and read our article on [Contributing](contributing.md)! It's got all the details on what to do! | To help understand the process of triaging bugs, have a look at our [Issue-Triage](triage.md) document. | Oh, and don't forget we always follow [[Sass Community Guidelines|http://sass-lang.com/community-guidelines]]. Be nice and everyone else will be nice too! | | ||
|
||
This list does not say anything about the quality of either the listed or not listed [implementations](docs/implementations.md)! | ||
The authors of the listed projects above are just known to work regularly together with LibSass developers. | ||
|
||
About | ||
----- | ||
|
||
LibSass is a C++ port of the original Ruby Sass CSS compiler with a [C API](docs/api-doc.md). | ||
We coded LibSass with portability and efficiency in mind. You can expect LibSass to be a lot | ||
faster than Ruby Sass and on par or faster than the best alternative CSS compilers around. | ||
|
||
Developing | ||
---------- | ||
|
||
As noted above, the LibSass repository does not contain any binaries or other way to execute | ||
LibSass. Therefore, you need an implementer to develop LibSass. Easiest is to start with | ||
the official [SassC](http://github.com/sass/sassc) CLI wrapper. It is *guaranteed* to compile | ||
with the latest code in LibSass master, since it is also used in the CI process. There is no | ||
limitation here, as you may use any other LibSass implementer to test your LibSass branch! | ||
|
||
Testing | ||
------- | ||
|
||
Since LibSass is a pure library, tests are run through the [Sass-Spec](https://github.com/sass/sass-spec) | ||
project using the [SassC](http://github.com/sass/sassc) CLI wrapper. To run the tests against LibSass while | ||
developing, you can run `./script/spec`. This will clone SassC and Sass-Spec under the project folder and | ||
then run the Sass-Spec test suite. You may want to update the clones to ensure you have the latest version. | ||
Note that the scripts in the `./script` folder are mainly intended for our CI needs. | ||
|
||
Building | ||
-------- | ||
|
||
To build LibSass you need GCC 4.6+ or Clang/LLVM. If your OS is older, you may need to upgrade | ||
them first (or install clang as an alternative). On Windows, you need MinGW with GCC 4.6+ or VS 2013 | ||
Update 4+. It is also possible to build LibSass with Clang/LLVM on Windows with various build chains | ||
and/or command line interpreters. | ||
|
||
See the [build docs for further instructions](docs/build.md)! | ||
|
||
Compatibility | ||
------------- | ||
|
||
Current LibSass 3.4 should be compatible with Sass 3.4. Please refer to the [sass compatibility | ||
page](http://sass-compatibility.github.io/) for a more detailed comparison. But note that there | ||
are still a few incomplete edges which we are aware of. Otherwise LibSass has reached a good level | ||
of stability, thanks to our ever growing [Sass-Spec test suite](https://github.com/sass/sass-spec). | ||
|
||
About Sass | ||
---------- | ||
|
||
Sass is a CSS pre-processor language to add on exciting, new, awesome features to CSS. Sass was | ||
the first language of its kind and by far the most mature and up to date codebase. | ||
|
||
Sass was originally conceived of by the co-creator of this library, Hampton Catlin ([@hcatlin]). | ||
Most of the language has been the result of years of work by Natalie Weizenbaum ([@nex3]) and | ||
Chris Eppstein ([@chriseppstein]). | ||
|
||
For more information about Sass itself, please visit http://sass-lang.com | ||
|
||
Initial development of LibSass by Aaron Leung and Hampton Catlin was supported by [Moovweb](http://www.moovweb.com). | ||
|
||
Licensing | ||
--------- | ||
|
||
Our [MIT license](LICENSE) is designed to be as simple and liberal as possible. | ||
|
||
[@hcatlin]: https://github.com/hcatlin | ||
[@akhleung]: https://github.com/akhleung | ||
[@chriseppstein]: https://github.com/chriseppstein | ||
[@nex3]: https://github.com/nex3 | ||
[@mgreter]: https://github.com/mgreter | ||
[@xzyfer]: https://github.com/xzyfer | ||
Please refer to the steps on [Building LibSass](build.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## Example main.c | ||
|
||
```C | ||
#include <stdio.h> | ||
#include "sass/context.h" | ||
|
||
int main( int argc, const char* argv[] ) | ||
{ | ||
|
||
// get the input file from first argument or use default | ||
const char* input = argc > 1 ? argv[1] : "styles.scss"; | ||
|
||
// create the file context and get all related structs | ||
struct Sass_File_Context* file_ctx = sass_make_file_context(input); | ||
struct Sass_Context* ctx = sass_file_context_get_context(file_ctx); | ||
struct Sass_Options* ctx_opt = sass_context_get_options(ctx); | ||
|
||
// configure some options ... | ||
sass_option_set_precision(ctx_opt, 10); | ||
|
||
// context is set up, call the compile step now | ||
int status = sass_compile_file_context(file_ctx); | ||
|
||
// print the result or the error to the stdout | ||
if (status == 0) puts(sass_context_get_output_string(ctx)); | ||
else puts(sass_context_get_error_message(ctx)); | ||
|
||
// release allocated memory | ||
sass_delete_file_context(file_ctx); | ||
|
||
// exit status | ||
return status; | ||
|
||
} | ||
``` | ||
### Compile main.c | ||
```bash | ||
gcc -c main.c -o main.o | ||
gcc -o sample main.o -lsass | ||
echo "foo { margin: 21px * 2; }" > foo.scss | ||
./sample foo.scss => "foo { margin: 42px }" | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
```C | ||
// Input behaviours | ||
enum Sass_Input_Style { | ||
SASS_CONTEXT_NULL, | ||
SASS_CONTEXT_FILE, | ||
SASS_CONTEXT_DATA, | ||
SASS_CONTEXT_FOLDER | ||
}; | ||
|
||
// sass config options structure | ||
struct Sass_Inspect_Options { | ||
|
||
// Output style for the generated css code | ||
// A value from above SASS_STYLE_* constants | ||
enum Sass_Output_Style output_style; | ||
|
||
// Precision for fractional numbers | ||
int precision; | ||
|
||
}; | ||
|
||
// sass config options structure | ||
struct Sass_Output_Options : Sass_Inspect_Options { | ||
|
||
// String to be used for indentation | ||
const char* indent; | ||
// String to be used to for line feeds | ||
const char* linefeed; | ||
|
||
// Emit comments in the generated CSS indicating | ||
// the corresponding source line. | ||
bool source_comments; | ||
|
||
}; | ||
|
||
// sass config options structure | ||
struct Sass_Options : Sass_Output_Options { | ||
|
||
// embed sourceMappingUrl as data uri | ||
bool source_map_embed; | ||
|
||
// embed include contents in maps | ||
bool source_map_contents; | ||
|
||
// create file urls for sources | ||
bool source_map_file_urls; | ||
|
||
// Disable sourceMappingUrl in css output | ||
bool omit_source_map_url; | ||
|
||
// Treat source_string as sass (as opposed to scss) | ||
bool is_indented_syntax_src; | ||
|
||
// The input path is used for source map | ||
// generation. It can be used to define | ||
// something with string compilation or to | ||
// overload the input file path. It is | ||
// set to "stdin" for data contexts and | ||
// to the input file on file contexts. | ||
char* input_path; | ||
|
||
// The output path is used for source map | ||
// generation. LibSass will not write to | ||
// this file, it is just used to create | ||
// information in source-maps etc. | ||
char* output_path; | ||
|
||
// Colon-separated list of paths | ||
// Semicolon-separated on Windows | ||
// Maybe use array interface instead? | ||
char* include_path; | ||
char* plugin_path; | ||
|
||
// Include paths (linked string list) | ||
struct string_list* include_paths; | ||
// Plugin paths (linked string list) | ||
struct string_list* plugin_paths; | ||
|
||
// Path to source map file | ||
// Enables source map generation | ||
// Used to create sourceMappingUrl | ||
char* source_map_file; | ||
|
||
// Directly inserted in source maps | ||
char* source_map_root; | ||
|
||
// Custom functions that can be called from sccs code | ||
Sass_Function_List c_functions; | ||
|
||
// Callback to overload imports | ||
Sass_Importer_List c_importers; | ||
|
||
// List of custom headers | ||
Sass_Importer_List c_headers; | ||
|
||
}; | ||
|
||
// base for all contexts | ||
struct Sass_Context : Sass_Options | ||
{ | ||
|
||
// store context type info | ||
enum Sass_Input_Style type; | ||
|
||
// generated output data | ||
char* output_string; | ||
|
||
// generated source map json | ||
char* source_map_string; | ||
|
||
// error status | ||
int error_status; | ||
char* error_json; | ||
char* error_text; | ||
char* error_message; | ||
// error position | ||
char* error_file; | ||
size_t error_line; | ||
size_t error_column; | ||
const char* error_src; | ||
|
||
// report imported files | ||
char** included_files; | ||
|
||
}; | ||
|
||
// struct for file compilation | ||
struct Sass_File_Context : Sass_Context { | ||
|
||
// no additional fields required | ||
// input_path is already on options | ||
|
||
}; | ||
|
||
// struct for data compilation | ||
struct Sass_Data_Context : Sass_Context { | ||
|
||
// provided source string | ||
char* source_string; | ||
char* srcmap_string; | ||
|
||
}; | ||
|
||
// Compiler states | ||
enum Sass_Compiler_State { | ||
SASS_COMPILER_CREATED, | ||
SASS_COMPILER_PARSED, | ||
SASS_COMPILER_EXECUTED | ||
}; | ||
|
||
// link c and cpp context | ||
struct Sass_Compiler { | ||
// progress status | ||
Sass_Compiler_State state; | ||
// original c context | ||
Sass_Context* c_ctx; | ||
// Sass::Context | ||
Sass::Context* cpp_ctx; | ||
// Sass::Block | ||
Sass::Block_Obj root; | ||
}; | ||
``` | ||
|
Oops, something went wrong.