A C/C++ implementation of a Sass compiler
Clone or download
Pull request Compare This branch is 2209 commits behind sass:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
m4
script
support
test
utf8
.editorconfig
.gitattributes
.gitignore
.travis.yml
COPYING
INSTALL
LICENSE
Makefile
Makefile.am
Readme.md
ast.cpp
ast.hpp
ast_def_macros.hpp
ast_factory.hpp
ast_fwd_decl.hpp
backtrace.hpp
base64vlq.cpp
base64vlq.hpp
bind.cpp
bind.hpp
color_names.hpp
configure.ac
constants.cpp
constants.hpp
context.cpp
context.hpp
contextualize.cpp
contextualize.hpp
copy_c_str.cpp
copy_c_str.hpp
debug.hpp
environment.hpp
error_handling.cpp
error_handling.hpp
eval.cpp
eval.hpp
expand.cpp
expand.hpp
extconf.rb
extend.cpp
extend.hpp
file.cpp
file.hpp
functions.cpp
functions.hpp
inspect.cpp
inspect.hpp
kwd_arg_macros.hpp
mapping.hpp
memory_manager.hpp
node.cpp
node.hpp
operation.hpp
output_compressed.cpp
output_compressed.hpp
output_nested.cpp
output_nested.hpp
parser.cpp
parser.hpp
paths.hpp
position.hpp
prelexer.cpp
prelexer.hpp
remove_placeholders.cpp
remove_placeholders.hpp
sass.cpp
sass.h
sass2scss.cpp
sass2scss.h
sass_interface.cpp
sass_interface.h
sass_util.cpp
sass_util.hpp
source_map.cpp
source_map.hpp
subset_map.hpp
test-driver
to_c.cpp
to_c.hpp
to_string.cpp
to_string.hpp
token.hpp
units.cpp
units.hpp
utf8.h
utf8_string.cpp
utf8_string.hpp
util.cpp
util.hpp

Readme.md

Libsass

by Aaron Leung (@akhleung) and Hampton Catlin (@hcatlin)

Build Status Bountysource Coverage Status

https://github.com/sass/libsass

Libsass is just a library, but if you want to RUN libsass, then go to https://github.com/sass/sassc or https://github.com/sass/ruby-libsass or find your local implementer.

LibSass requires GCC 4.7+ or Clang/LLVM. If your OS is older, this version may not compile.

About

Libsass is a C/C++ port of the Sass CSS precompiler. The original version was written in Ruby, but this version is meant for efficiency and portability.

This library strives to be light, simple, and easy to build and integrate with a variety of platforms and languages.

Developing

As you may have noticed, the libsass repo itself has no executables and no tests. Oh noes! How can you develop???

Well, luckily, SassC is the official binary wrapper for libsass and is always kept in sync. SassC uses a git submodule to include libsass. When developing libsass, its best to actually check out SassC and develop in that directory with the SassC spec and tests there.

We even run Travis tests for SassC!

Tests

Since libsass is a pure library, tests are run through the SassSpec project using the SassC driver.

To run 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.

Library Usage

While libsass is primarily implemented in C++, it provides a simple C interface that is defined in sass_interface.h. Its usage is pretty straight forward.

First, you create a sass context struct. We use these objects to define different execution parameters for the library. There are three different context types.

sass_context();        // string-in-string-out compilation
sass_file_context();   // file-based compilation
sass_folder_context(); // full-folder multi-file

Each of the contexts have slightly different behavior and are implemented seperately. This does add extra work to implementing a wrapper library, but we felt that a mixed-use context object provides for too much implicit logic. What if you set "input_string" AND "input_file"... what do we do? This would introduce bugs into wrapper libraries that would be difficult to debug.

We anticipate that most adapters in most languages will define their own logic for how to separate these use cases based on the language. For instance, the original Ruby interface has a combined interface, but is backed by three different processes.

To generate a context, use one of the following methods.

sass_new_context();
sass_new_file_context();
sass_new_folder_context();

Again, please see the sass_interface.h for more information.

And, to get even more information, then please see the implementations in SassC and SassC-Ruby.

Implementations

For a full list of implementations, checkout our implementations wiki page

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 created by the co-creator of this library, Hampton Catlin (@hcatlin). The extension and continuing evolution of the language has all 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

Contribution Agreement

Any contribution to the project are seen as copyright assigned to Hampton Catlin, a human on the planet earth. Your contribution warrants that you have the right to assign copyright on your work. The intention here is to ensure that the project remains totally free (liberal, like).

Our MIT license is designed to be as simple, and liberal as possible.

sass2scss was originally written by Marcel Greter [@mgreter] and he happily agreed to have it merged into the project.