Coder Social home page Coder Social logo

sass / libsass Goto Github PK

View Code? Open in Web Editor NEW
4.3K 158.0 461.0 12.35 MB

A C/C++ implementation of a Sass compiler

Home Page: https://sass-lang.com/libsass

License: Other

C++ 93.63% C 2.31% Shell 2.03% Makefile 0.87% M4 0.69% Perl 0.45% CSS 0.01% SCSS 0.01%

libsass's Introduction

LibSass - Sass compiler written in C++

Currently maintained by Marcel Greter (@mgreter) and Michael Mifsud (@xzyfer) Originally created by Aaron Leung (@akhleung) and Hampton Catlin (@hcatlin)

GitHub CI Windows CI Coverage Status Percentage of issues still open Average time to resolve an issue Bountysource

Warning: LibSass is deprecated. While it will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.

LibSass 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, which is the official lightweight CLI tool built by the same people as LibSass.

Excerpt of Supported Implementations:

This list does not say anything about the quality of either the listed or not listed implementations! 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. 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 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 project using the 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.7+ 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.7+ 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!

Compatibility

For all intents and purposes LibSass is fully compatible with the Sass language spec. Any known differences can be found as open issues.

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 https://sass-lang.com

Initial development of LibSass by Aaron Leung and Hampton Catlin was supported by Moovweb.

Licensing

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

libsass's People

Contributors

alyssais avatar am11 avatar archgrove avatar asottile avatar benesch avatar caldwell avatar carsonmcdonald avatar delapuente avatar drewwells avatar glebm avatar hamptonmakes avatar jaddessi avatar jbussdieker avatar kornelski avatar larsimmisch avatar mgreter avatar michaek avatar nabellaleen avatar nschonni avatar qulogic avatar rivy avatar rodneyrehm avatar rowanbeentje avatar saper avatar stijnvn avatar taritsyn avatar uberska avatar wonja avatar xhmikosr avatar xzyfer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libsass's Issues

Improve Makefile

I've created a homebrew formula so we can simply run brew install libsass but the Makefile doesn't have an install command.

I don't really know much about makefiles so I might need some help implementing it.

Homebrew formula here: andrew/homebrew@b5601ff

Incorrect Pseudo Identifier Parsing

Pseudo parsing in the library limits the formats or required a string constant, this does not work with the :lang identifier

The following is valid CSS

selector:lang(es) {

}

Libsass only supports

selector:lang('es') {

}

which is invalid.

The code in question is in document_parser.cpp

  Node Document::parse_pseudo() {
    if (lex< pseudo_not >()) {
    ...
      else if (lex< string_constant >()) {
        pseudo << context.new_Node(Node::string_constant, path, line, lexed);
      }
   ...

This can be resolved by changing the lexer to parse out an identifier instead of a string constant

   ...
      else if (lex< identifier >()) {
        pseudo << context.new_Node(Node::identifier, path, line, lexed);
      }
   ...

Better detection of missing rbrace (etc.)

It currently falls upon the property/style parsing function to detect missing braces (because the selector lookahead will fall through). Add better checks for missing braces, and maybe check for strange characters during lookahead.

Incorrect interpolation

When string is not top-level expression, like:

$bg = image.png;
background-image: url("#{$url}");

interpolation does not work, it produced:

background-image: url("#{$url}");

But if I use without url:

$bg = image.png;
background-image: "#{$url}";

it produce:

background-image: "image.png";

Debug Output

Whoa... so much debug output... When I run sassc, I get the following output...

    stockton:sassc hcatlin$ ./bin/sassc interpolation.scss 
    MADE A DOC AND CONTEXT OBJ
    REGISTRY: 1
    parsing value schema: #{2 + 2}
    parsing value schema: #{world}
    css import inside block
    css import inside block
    PARSED
    evaluating schema of size 1
    evaluating schema of size 1
    evaluating schema of size 2
    EVALUATED
    foobar.css
    foobar.css
    foobar.css
    EMITTED
    Allocations:    74
    Destructions:   570
    Registry size:  74
    Deallocations:  74
    Deallocated 1 source string(s).

Incorrect include_paths option format

Now this parameter parsed via hardcoded specified separator character ':'.
This is not correct on some platforms, for ex. on Windows =)
I think, it would be better to specify custom separator or array of strings (better).

Windows compilation issue

When trying to compile node-sass (https://github.com/andrew/node-sass) which wraps this library, it turns out this library is not portable enough to be compiled by Visual C++.

The compile log is here: https://gist.github.com/3885949

It seems to be mainly problems with char which should be const char, and the resulting influence on the parameter list of the templates used.

I also posted an issue with node-sass (sass/node-sass#28), but as the main compiler errors are generated by the libsass files, I thought posting an issue here too would be appropriate.

Errors out on valid gradient syntax

Looks like it doesn't recognize a non-prefixed syntax

div {
  // works:
  background-image: -webkit-linear-gradient(top, #2F2727, #1a82f7);
  // breaks:
  background-image: linear-gradient(top, #2F2727, #1a82f7);
  @include background-image(linear-gradient(top, $color1, $color1));
}

Error message:

Segmentation fault: 11

libsass does not accept parsing from stdin

Testing sassc I noticed that it doesn't accept input from stdin and looking to implement that I found that libsass doesn't accept input from stdin because it tries to fstat a file name to get it's size and preallocate memory to ready it all in memory.

Would be nice if we could use sassc/libsass accepts input from stdin that way it could be part of a sequence of filters through redirection.

cat some.scss | sed | sassc | sed | ...

segfault in current master

FYI, I tried merging the new libsass into our current node-sass repo that uses it. Something added in recently caused it to segfault. When I run it through gdb, it complains on this line:

string path_string(img_path_str);

This line is found in context.cpp on line 63. I haven't had time to investigate it, but it looks like this was new code added in a few hours ago.

Embedded base64 image

Hi,

Say you have the following SCSSย :

p:after {
content:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAACeElEQVR42nySy29McRTHP/fOnTvT6bQNrdHKMGGhFkTSELGxwoJY8Q9YWFhYEUJsRSKCsJWikjYSJBIbinpVPJLSRlEkKK2WTnXmvl+/Y4F4tPVJPqtvzjcnJ0cTEQxdY/miFH6gcAJpaWrQl86t05rR9axSKD8UZ6KqJscm5bMdyDDgAYgIBoCORm2G1u0b6w8unJ/bmDG1QtpUmIYiZ8Zk0zEpYmW76tujV9J3/Ep04v0XdR2IDYAdWxYt27Sa8/l8btWIlaYSupgqpNaMUYbC0DUa8qKXWpLGNSvZEETpZO/Z4B5gGQCRMio1xdVfioUIa3AQJ/ZARWhJgkQJKq3wfJ3RwETGhRtPgx7ABtBEhCVNBqViU2tn5+5bLfXmgurIYwJrGFEJmqZh2T4jo2X0YIreZ+7dfeejrcCEiKADfCon3O4fHzp25Nx+8nnqF65lXnEphQUtNBYKaKkMcRgxVY29093JUWCCn+gAORMaTLh0dbCjo/1KO3X1kC6BGIR+QLVioSc+F+9HnW/G1DX+QAcw0j8c/QaHj3UfeN0/MMicEmSL+J5P6DkMDUcfLvZGJ4FwWoHl/lAEXo344zv3dO3ynXJIpg7XdnBtj46bwSnblwH+QQdQ8lsNeNg32nOm/fIh3CGS0OXOQHCv90XYwUyICM2NNX85f26WUnOu5smFzX0vu9qktZjeNtusAbB+XdvfAWDZnjeurX2XST1Y8X6s7zmzYABUrHBaYNshYRC4k340FcZU/1vg2JVpgeP4uJXypHK8soD134In/W+mb+AJvffvvC022It/ve1MaCJCXU6f4UCQy1CbNVONH7/Gw7Md8fsAtddMUh5fveYAAAAASUVORK5CYII=);
}

Compiling with latest libsass gives the following errorย :

ERROR -- my-data.scss, line 2: URI is missing ')'

It works well with ruby reference implementation.

Regards,
ร‰tienne

Unicode support

Internally the project uses 'char' instead of 'wchar_t' for manipulating strings.
So that means no Unicode support?

Imports fail if there's also a directory of the same name

As in Compass, say you have a partial and a directory with a similar name. On Linux (and likely on any Unix, where "everything is a file"), if you import only the basename of the partial (i.e., without the extension), then libsass will open the directory instead of the partial and fail to read anything.

Test case:

$ touch bar.scss
$ mkdir bar
$ cat > foo.scss << EOF
@import "bar";
EOF
$ sassc foo
ERROR -- foo.scss, line 1: error reading file "bar"

Warnings printed are not informative enough.

Here's a libsass warning:

WARNING: border-radius mixin is deprecated and will be removed in the next major version release.
         on line 3 of /home/noj/sandbox/testingmw/assets/stylesheets/bourbon/css3/border-radius

What the ruby sass compiler does:

WARNING: border-radius mixin is deprecated and will be removed in the next major version release.
         on line 3 of bourbon/css3/_border-radius.scss, in `border-radius'
         from line 125 of globals/_lib.scss, in `button_base'
         from line 145 of globals/_lib.scss
         from line 18 of main.scss

It would be nice if libsass could also print the stack trace so that we know where we're using the incorrect function.

error on UTF-8 with sugnature files

When trying to process file with UTF-8 with signature (BOM) encoding, getting error:

ERROR -- filename, line 1: invalid top-level expression

No sass_free_folder_context() function

Although sass_interface.h header contains the prototype of void sass_free_folder_context(struct sass_folder_context *) function, sass_interface.cpp does not implement it. It occurs a link error.

Parser do not recognize @- browser specific rules

The actual parser do not recognize the @-webkit-keyframes rules it try to parse it as "directive" and throws "top-level blockless directive must be terminated by ';'" when it should interpret it as a block.

Actually I think it should check for "@-" and parse anything stating with it as a normal block.

examples:

@-webkit-keyframes uiDelayedFadeIn {
0% { @include opacity(0.01); }
50% { @include opacity(0.01); }
100% { @include opacity(1); }
}

@-webkit-keyframes bounce {
from {
left: 0px;
}
to {
left: 200px;
}
}

@-moz-document url-prefix() {
.fl { float:left; margin:12px 4px 0 0; padding:0; font-size:65px; line-height:62%; color:#ba1820; }
.fs { float:left; margin:12px 4px 10px 0; padding:0; font-size:65px; line-height:62%; color:#ba1820; }
}

Parse error of conditionals inside mixin

The example bellow is extracted and adapted from "compass/typography/text/_replacement.scss" and do not compile with libsass :
ERROR -- test.scss:7: invalid property name

if the conditionals are commented it does work // @if is-url($img) { // } @else { //} , it seems that the parser doesn't recognize the @if conditional inside the mixin.

@function is-url($n) {
@return $n != '';
}

@mixin replace-text($img, $x: 50%, $y: 50%) {
//@include hide-text;
background: {
@if is-url($img) {
image: $img;
} @else {
image: image-url($img);
}
repeat: no-repeat;
position: $x $y;
}
}

@mixin large-text {
font: {
family: Arial;
size: 20px;
weight: bold;
}
color: #ff0000;
}

.dad {
@include replace-text('dad');
@include large-text;
}

Parse error report that can be understood by scite editor

Hello !
I started testing sassc/libsass and noticed that the current parse error reported by libsass isn't understood by scite so I modified two lines on sass_interface.cpp and with that scite now recognize the error and can jump to source and line.

Basically I changed the static string ", line" by ":" that was enough.

line 77: msg_stream << "ERROR -- " << e.path << /", line "/ ":" << e.line << ": " << e.message << endl;
line 117:msg_stream << "ERROR -- " << e.path << /", line "/ ":" << e.line << ": " << e.message << endl;

Passing content blocks to a mixin

According to the reference, SCSS has to be able to pass content blocks to a mixin. For example:

@mixin apply-to-ie6-only {
  * html {
    @content;
  }
}
@include apply-to-ie6-only {
  #logo {
    background-image: url(/logo.gif);
  }
}

has to be compiled to:

* html #logo {
  background-image: url(/logo.gif);
}

However it causes an error:

ERROR -- test.scss, line 6: top-level @include directive must be terminated by ';'

Concatenation error

When I try to concatenate unquoted string with quoted:
bar + "foo"
it should produce unquoted string:
barfoo
but libsass produced mixed:
bar"foo"

intermittent fatal erros

Hi, Ive been getting the following errors intermittently when building sass;

node(14524,0x1017bb000) malloc: *** mmap(size=1152921504876556288) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
terminate called throwing an exceptionAbort trap: 6

Not very helpful - but with some help from a issue I raised in node-sass I was able to get the following stack trace;

0 0x00007fff8a32dce2 in pthread_kill ()
1 0x00007fff8bcf57d2 in pthread_kill ()
2 0x00007fff8bce6a7a in abort ()
3 0x00007fff9141e7bc in abort_message ()
4 0x00007fff9141bfcf in default_terminate ()
5 0x00007fff8885b1cd in _objc_terminate ()
6 0x00007fff9141c001 in safe_handler_caller ()
7 0x00007fff9141c05c in std::terminate ()
8 0x00007fff9141d152 in __cxa_throw ()
9 0x00007fff848e8255 in std::throw_length_error ()
10 0x00007fff8490e84e in std::string::_Rep::_S_create ()
11 0x00007fff849102fa in std::string::_S_construct ()
12 0x00007fff849104a8 in std::basic_string, std::allocator >::basic_string ()
13 0x000000010172c0f8 in Sass::Token::to_string () at :68
14 0x000000010172c0f8 in Sass::Node::to_string (this=0x7fff8bd0f711, inside_of=Sass::Node::none) at ../libsass/node_emitters.cpp:68
15 0x000000010172f5d1 in std::string::data () at ../libsass/node_emitters.cpp:390
16 0x000000010172f5d1 in std::string::_M_data () at /usr/include/c++/4.2.1/bits/basic_string.h:2413
17 0x000000010172f5d1 in std::operator<< , std::allocator > () at /usr/include/c++/4.2.1/bits/basic_string.h:1542
18 0x000000010172f5d1 in Sass::Node::emit_nested_css (this=0x102844e88, buf=@0x1017ba708, depth=1, at_toplevel=false, in_media_query=true) at ../libsass/node_emitters.cpp:390
19 0x000000010172fa13 in std::operator<< std::char_traits () at /usr/include/c++/4.2.1/ostream:427
20 0x000000010172fa13 in Sass::Node::emit_nested_css (this=0x10300bf28, buf=@0x1017ba708, depth=, at_toplevel=, in_media_query=false) at ../libsass/node_emitters.cpp:428
21 0x000000010172f4df in Sass::Node::emit_nested_css (this=0x1017bac58, buf=@0x1017ba708, depth=0, at_toplevel=true, in_media_query=false) at ../libsass/node_emitters.cpp:379
22 0x0000000101709787 in std::basic_stringstream, std::allocator >::str () at /usr/include/c++/4.2.1/sstream:133
23 0x0000000101709787 in Sass::Document::emit_css (this=, style=) at ../libsass/document.cpp:141
24 0x0000000101733581 in std::string::_M_rep () at ../libsass/sass_interface.cpp:51
25 0x0000000101733581 in std::string::_M_data () at /usr/include/c++/4.2.1/bits/basic_string.h:605
26 0x0000000101733581 in std::string::size () at /usr/include/c++/4.2.1/bits/basic_string.h:287
27 0x0000000101733581 in process_document (doc=@0x1017bac20, style=0) at ../libsass/sass_interface.cpp:52
28 0x0000000101733157 in sass_compile (c_ctx=0x102800140) at ../libsass/sass_interface.cpp:65
29 0x00000001000462a8 in etp_proc ()
30 0x00007fff8bcf38bf in _pthread_start ()
31 0x00007fff8bcf6b75 in thread_start ()

Does that provide enough info to be of help?

Im running on a Mac - OS X 10.7.5
Im auto building sass with 'grunt watch' using -> grunt-sass which wraps -> node-sass which wraps -> libsass

'if' function not implemented; causes arithmetic errors

The works when using plain scss --watch

The error

Failed to compile sass: gosass error: ERROR -- /Users/jeffpatzer/workspace/projects/jeffpatzer/assets/stylesheets/globals/_vertical_rhythm, line 109: argument to unit must be numeric

This line

$rhythm: $font-unit * ($lines * $base-line-height - $offset) / $font-size;

From the compass vertical rhythm file

// Taken from Compass's Vertical Rhythm module

// The base font size.
$base-font-size: 16px !default;

// The base line height determines the basic unit of vertical rhythm.
$base-line-height: 24px !default;

// Set the default border style for rhythm borders.
$default-rhythm-border-style: solid !default;

// The default font size in all browsers.
$browser-default-font-size: 16px;

// Set to false if you want to use absolute pixels in sizing your typography.
$relative-font-sizing: true !default;

// Allows the `adjust-font-size-to` mixin and the `lines-for-font-size` function
// to round the line height to the nearest half line height instead of the
// nearest integral line height to avoid large spacing between lines.
$round-to-nearest-half-line: false !default;

// Ensure there is at least this many pixels
// of vertical padding above and below the text.
$min-line-padding: 2px !default;

// $base-font-size but in your output unit of choice.
// Defaults to 1em when `$relative-font-sizing` is true.
$font-unit: if($relative-font-sizing, 1em, $base-font-size) !default;

// The basic unit of font rhythm.
$base-rhythm-unit: $base-line-height / $base-font-size * $font-unit;

// The leader is the amount of whitespace in a line.
// It might be useful in your calculations.
$base-leader: ($base-line-height - $base-font-size) * $font-unit / $base-font-size;

// The half-leader is the amount of whitespace above and below a line.
// It might be useful in your calculations.
$base-half-leader: $base-leader / 2;

// True if a number has a relative unit.
@function relative-unit($number) {
  @return unit($number) == "%" or unit($number) == "em" or unit($number) == "rem"
}

// True if a number has an absolute unit.
@function absolute-unit($number) {
  @return not (relative-unit($number) or unitless($number));
}

@if $relative-font-sizing and not relative-unit($font-unit) {
  @warn "$relative-font-sizing is true but $font-unit is set to #{$font-unit} which is not a relative unit.";
}

// Establishes a font baseline for the given font-size.
@mixin establish-baseline($font-size: $base-font-size) {
  // IE 6 refuses to resize fonts set in pixels and it weirdly resizes fonts
  // whose root is set in ems. So we set the root font size in percentages of
  // the default font size.
  * html {
    font-size: 100% * ($font-size / $browser-default-font-size);
  }
  html {
    font-size: $font-size;
    @include adjust-leading-to(1, if($relative-font-sizing, $font-size, $base-font-size));
  }
}

// Resets the line-height to 1 vertical rhythm unit.
// Does not work on elements whose font-size is different from $base-font-size.
//
// @deprecated This mixin will be removed in the next release.
// Please use the `adjust-leading-to` mixin instead.
@mixin reset-baseline {
  @include adjust-leading-to(1, if($relative-font-sizing, $base-font-size, $base-font-size));
}

// Adjust a block to have a different font size and line height to maintain the
// rhythm. $lines specifies how many multiples of the baseline rhythm each line
// of this font should use up. It does not have to be an integer, but it
// defaults to the smallest integer that is large enough to fit the font.
// Use $from-size to adjust from a font-size other than the base font-size.
@mixin adjust-font-size-to($to-size, $lines: lines-for-font-size($to-size), $from-size: $base-font-size) {
  @if not $relative-font-sizing and $from-size != $base-font-size {
    @warn "$relative-font-sizing is false but a relative font size was passed to adjust-font-size-to";
  }
  font-size: $font-unit * $to-size / $from-size;
  @include adjust-leading-to($lines, if($relative-font-sizing, $to-size, $base-font-size));
}

// Adjust a block to have different line height to maintain the rhythm.
// $lines specifies how many multiples of the baseline rhythm each line of this
// font should use up. It does not have to be an integer, but it defaults to the
// smallest integer that is large enough to fit the font.
@mixin adjust-leading-to($lines, $font-size: $base-font-size) {
  line-height: rhythm($lines, $font-size);
}

// Calculate rhythm units.
@function rhythm(
  $lines: 1,
  $font-size: $base-font-size,
  $offset: 0
) {
  @if not $relative-font-sizing and $font-size != $base-font-size {
    @warn "$relative-font-sizing is false but a relative font size was passed to the rhythm function";
  }
  $rhythm: $font-unit * ($lines * $base-line-height - $offset) / $font-size;
  // Round the pixels down to nearest integer.
  @if unit($rhythm) == px {
    $rhythm: floor($rhythm);
  }
  @return $rhythm;
}

// Calculate the minimum multiple of rhythm units needed to contain the font-size.
@function lines-for-font-size($font-size) {
  $lines: if($round-to-nearest-half-line,
              ceil(2 * $font-size / $base-line-height) / 2,
              ceil($font-size / $base-line-height));
  @if $lines * $base-line-height - $font-size < $min-line-padding * 2 {
    $lines: $lines + if($round-to-nearest-half-line, 0.5, 1);
  }
  @return $lines;
}

// Apply leading whitespace. The $property can be margin or padding.
@mixin leader($lines: 1, $font-size: $base-font-size, $property: margin) {
  #{$property}-top: rhythm($lines, $font-size);
}

// Apply leading whitespace as padding.
@mixin padding-leader($lines: 1, $font-size: $base-font-size) {
  padding-top: rhythm($lines, $font-size);
}

// Apply leading whitespace as margin.
@mixin margin-leader($lines: 1, $font-size: $base-font-size) {
  margin-top: rhythm($lines, $font-size);
}

// Apply trailing whitespace. The $property can be margin or padding.
@mixin trailer($lines: 1, $font-size: $base-font-size, $property: margin) {
  #{$property}-bottom: rhythm($lines, $font-size);
}

// Apply trailing whitespace as padding.
@mixin padding-trailer($lines: 1, $font-size: $base-font-size) {
  padding-bottom: rhythm($lines, $font-size);
}

// Apply trailing whitespace as margin.
@mixin margin-trailer($lines: 1, $font-size: $base-font-size) {
  margin-bottom: rhythm($lines, $font-size);
}

// Shorthand mixin to apply whitespace for top and bottom margins and padding.
@mixin rhythm($leader: 0, $padding-leader: 0, $padding-trailer: 0, $trailer: 0, $font-size: $base-font-size) {
  @include leader($leader, $font-size);
  @include padding-leader($padding-leader, $font-size);
  @include padding-trailer($padding-trailer, $font-size);
  @include trailer($trailer, $font-size);
}

// Apply a border and whitespace to any side without destroying the vertical
// rhythm. The whitespace must be greater than the width of the border.
@mixin apply-side-rhythm-border($side, $width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
  @if not $relative-font-sizing and $font-size != $base-font-size {
    @warn "$relative-font-sizing is false but a relative font size was passed to apply-side-rhythm-border";
  }
  border-#{$side}: {
    style: $border-style;
    width: $font-unit * $width / $font-size;
  };
  padding-#{$side}: rhythm($lines, $font-size, $offset: $width);
}

// Apply borders and whitespace equally to all sides.
@mixin rhythm-borders($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
  @if not $relative-font-sizing and $font-size != $base-font-size {
    @warn "$relative-font-sizing is false but a relative font size was passed to rhythm-borders";
  }
  border: {
    style: $border-style;
    width: $font-unit * $width / $font-size;
  };
  padding: rhythm($lines, $font-size, $offset: $width);
}

// Apply a leading border.
@mixin leading-border($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
  @include apply-side-rhythm-border(top, $width, $lines, $font-size, $border-style);
}

// Apply a trailing border.
@mixin trailing-border($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
  @include apply-side-rhythm-border(bottom, $width, $lines, $font-size, $border-style);
}

// Apply both leading and trailing borders.
@mixin horizontal-borders($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
  @include leading-border($width, $lines, $font-size, $border-style);
  @include trailing-border($width, $lines, $font-size, $border-style);
}

// Alias for `horizontal-borders` mixin.
@mixin h-borders($width: 1px, $lines: 1, $font-size: $base-font-size, $border-style: $default-rhythm-border-style) {
  @include horizontal-borders($width, $lines, $font-size, $border-style);
}

RGBA value doesn't work

This code:

$mw_box_shadow: 0 1px 3px rgba(0,0,0,0.9);
div{
  -webkit-box-shadow: $mw_box_shadow;
}

spits out this error:

Segmentation fault: 11

But this works:

$mw_box_shadow: 0 1px 3px #333;
div{
  -webkit-box-shadow: $mw_box_shadow;
}

Running both of the above as an inline command without supplying the output file:

$ sassc main.scss

Selector parsing is too strict

Valid and useful things like:

div > {
  span { ... }
  p { ... }
  etc { ... }
}

aren't recognized by the selector lookahead function.

.sass files not supported?

Given the test.sass file:
div
background-color: blue

when I run "./bin/sassc test.sass" I get the error:

ERROR -- test.sass, line 1: invalid top-level expression

Is there a flag I'm missing, or is sass not supported yet? Significant whitespace is awesome.

Merge with sassc?

I'm not sure if this has already been discussed but is there a specific argument against libsass and sassc being in one repository? Having them separate seems to make things like git bisect/recursive make/continuous integration less simple than they could be.

Implement custom importers

I would like to use libsass with user-generated SCSS templates, but exposing libsass to user creates security threat. By crafting @import directives users can read some, possibly sensitive files, for server filesystem.

I would be nice if libsass would have support for custom importers, and have control over access to filesystem.

Variables are not resolved inside parentheses

This line will produce:
background: -moz-linear-gradient(top, $headerGradientStart 0%, $headerGradientEnd 166px, #ffffff 166px);

background: -moz-linear-gradient(top, $headerGradientStart 0%, $headerGradientEnd 166px, #ffffff 166px);

After removing the parentheses:
background: -moz-linear-gradient top, $headerGradientStart 0%, $headerGradientEnd 166px, #ffffff 166px;

variables are resolved:
background: -moz-linear-gradient top, white 0%, black 166px, #ffffff 166px;

Discrepancies between libsass parsing and the ruby gem

Hi there, there seems to be some differences between libsass and the ruby gem regarding string handling.

e.g.
For desired css of the form;

background: url(/static_loc/img/beta.png);

I was able to write the following scss;

$base_url: "/static_loc/";
background-image: "url("#{$base_url}"img/beta.png)";

However, when I switched to the ruby gem (due to other issues) I had to omit several quotes to get the same css;

$base_url: "/static_loc/";
background-image: url(#{$base_url}img/beta.png);

Not a massive issue (I can probably refactor it so it works for both) but I thought it'd help to raise an issue as I assume you folks want to keep all sass parsers in sync?

Cheers,
Greg

Partials aren't imported correctly

This might be posted in the wrong place (I was testing sassc so maybe that's where this should go). But sassc won't import partials the way vanilla SASS does it, using underscore for naming and then omitting both underscore and extensions in the import directive.

/* This will fail: */
@import "variables/measures";

/* This will succeed: */
@import "variables/_measures.scss";

Rendering '@charset "UTF-8";' gives an error.

Originally reported at sass/node-sass#23. node-sass module uses libsass.

When I try to use it, it outputs 'undefined'

var sass = require('node-sass');

sass.render('@charset "UTF-8";', function(err, css){
    console.log(css)
});

The node-sass developer confirms that the problem originates from libsass. He says the following error is displayed when he tries to use sassc (https://github.com/hcatlin/sassc) to render @charset "UTF-8";:

ERROR -- test.scss, line 1: top-level blockless directive must be terminated by ';'

color functions are broken

The following scss code:

p {
    color: rgb(255, 128, 0);
}

results in:

p {
    color: alsetruetruefals; }

The Ruby sass implementation gives the correct result:

p {
    color: #ff8000; }

It seems that all of the color functions are broken in this way(darken, lighten, grayscale, etc...)

STYLE_ constants obeyed

I got all excited about adding different output styles to my libsass binding to discover that only SASS_STYLE_NESTED is working!

Are there still plans to make the other style constants work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.