sass / libsass

A C/C++ implementation of a Sass compiler
https://sass-lang.com/libsass
Other
4.33k stars 461 forks source link

CSS escapes #102

Closed emagnier closed 10 years ago

emagnier commented 11 years ago

I'm using the font-icons method (via the @media rule) which display a specific character (the icon) via the CSS content property in a pseudo class (:before/:after).

For some special characters my tool adds a backslash before it, which is valid and compiles well with the official ruby compiler:

[data-icon='test-1']:before {
    content:'\\';
}

[data-icon='test-2']:before {
    content:'\'';
}

[data-icon='test-3']:before {
    content:"\"";
}

But with Libsass I get this error message: error reading values after '\\';

I also made a search about this and discovered the CSS escape can be use in the selectors:

.\E9motion { ... }
.\E9 dition { ... }
.\0000E9dition { ... }

These selectors represent the word émotion and édition. More details here: http://www.w3.org/International/questions/qa-escapes

emagnier commented 11 years ago

I'm trying to compile inuit.css (a great OOCSS framework) with Libsass, but it also block on this kind of code:

$open-quote: \201C;
$close-quote: \201D;
craigbarnes commented 11 years ago

According to the CSS 2.1 grammar spec, literal, UTF-8 encoded characters ("nonascii") are valid in selectors too but that also causes an error in libsass:

$ sassc <<< '.émotion {color: red}'
:1: error: invalid top-level expression

http://jsfiddle.net/XbGfh/

akhleung commented 11 years ago

I've added some backslash handling to the refactor branch ... I'll make sure it works with your examples and merge it during the coming week.

emagnier commented 11 years ago

Just for the follow up, all examples listed above works now. Except this:

[data-icon='test-1']:before {
    content:'\\';
}

[data-icon='test-2']:before {
    content:'\'';
}

[data-icon='test-3']:before {
    content:"\"";
}
akhleung commented 11 years ago

Hmm, looks like I need to futz with the string matcher ... thanks for checking!

emagnier commented 11 years ago

FYI this code also doesn't work:

$open-quote:    «;
$close-quote:   »;
emagnier commented 10 years ago

Thanks!