Skip to content

Commit 06d3c11

Browse files
committed
Improve hex color parsing with trailing hyphen
1 parent 0ae11a4 commit 06d3c11

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/parser.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,9 +1421,12 @@ namespace Sass {
14211421
{ return new (ctx.mem) Textual(pstate, Textual::PERCENTAGE, lexed); }
14221422

14231423
// match hex number first because 0x000 looks like a number followed by an indentifier
1424-
if (lex< alternatives< hex, hex0 > >())
1424+
if (lex< sequence < alternatives< hex, hex0 >, negate < exactly<'-'> > > >())
14251425
{ return new (ctx.mem) Textual(pstate, Textual::HEX, lexed); }
14261426

1427+
if (lex< sequence < exactly <'#'>, identifier > >())
1428+
{ return new (ctx.mem) String_Quoted(pstate, lexed); }
1429+
14271430
// also handle the 10em- foo special case
14281431
if (lex< sequence< dimension, optional< sequence< exactly<'-'>, negate< digit > > > > >())
14291432
{ return new (ctx.mem) Textual(pstate, Textual::DIMENSION, lexed); }
@@ -1639,9 +1642,12 @@ namespace Sass {
16391642
(*schema) << new (ctx.mem) Textual(pstate, Textual::NUMBER, lexed);
16401643
}
16411644
// lex hex color value
1642-
else if (lex< hex >()) {
1645+
else if (lex< sequence < hex, negate < exactly < '-' > > > >()) {
16431646
(*schema) << new (ctx.mem) Textual(pstate, Textual::HEX, lexed);
16441647
}
1648+
else if (lex< sequence < exactly <'#'>, identifier > >()) {
1649+
(*schema) << new (ctx.mem) String_Quoted(pstate, lexed);
1650+
}
16451651
// lex a value in parentheses
16461652
else if (peek< parenthese_scope >()) {
16471653
(*schema) << parse_factor();

0 commit comments

Comments
 (0)