You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In CSS any literal or value can contain escaped content, a simple example being content: "\""; Here we escape another quote inside the string with a backslash.
But the tl;dr is, any character can be escaped either using itself: "\+" = "+" or using a hex code: "\2b " = "+" or "\00002b" = "+". Note that if the hex escape sequence has an ambiguous length (anything else than exactly 6 hex chars) then a space must follow it.
A simpler detection of escaped content would be to allow either one char, or one or more hex chars (/[a-f][0-9]/i) with an optional space after them. This is easier and more efficient to parse. (Used by PostCSS as a heuristic for instance)
As soon as a character is escaped it can become part of a literal or a value, but it can never be part of any other token, meaning that in #\#some-id { the hash symbol doesn't stand for CSS’ hash token.
A problem for bredon in particular is that since any literal's char can be escaped, that also means that for 100% those would need to be normalised for literals. A simple example is font-\size which is still detected as font-size in the browser. So for correct detection and to make plugins work correctly this technically needs to be normalised. (This normalisation is not done in most CSS parsers however)
The text was updated successfully, but these errors were encountered:
In CSS any literal or value can contain escaped content, a simple example being
content: "\"";
Here we escape another quote inside the string with a backslash.The best article on what's possible is here: https://mathiasbynens.be/notes/css-escapes
But the tl;dr is, any character can be escaped either using itself:
"\+" = "+"
or using a hex code:"\2b " = "+"
or"\00002b" = "+"
. Note that if the hex escape sequence has an ambiguous length (anything else than exactly 6 hex chars) then a space must follow it.A simpler detection of escaped content would be to allow either one char, or one or more hex chars (
/[a-f][0-9]/i
) with an optional space after them. This is easier and more efficient to parse. (Used by PostCSS as a heuristic for instance)As soon as a character is escaped it can become part of a literal or a value, but it can never be part of any other token, meaning that in
#\#some-id {
the hash symbol doesn't stand for CSS’ hash token.A problem for bredon in particular is that since any literal's char can be escaped, that also means that for 100% those would need to be normalised for literals. A simple example is
font-\size
which is still detected asfont-size
in the browser. So for correct detection and to make plugins work correctly this technically needs to be normalised. (This normalisation is not done in most CSS parsers however)The text was updated successfully, but these errors were encountered: