Skip to content

Commit e1c1d89

Browse files
committed
Merge pull request #1472 from mgreter/bugfix/hex-color-parsing
Improve hex color parsing with trailing hyphen
2 parents 39e26e9 + 06d3c11 commit e1c1d89

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
@@ -1423,9 +1423,12 @@ namespace Sass {
14231423
{ return new (ctx.mem) Textual(pstate, Textual::PERCENTAGE, lexed); }
14241424

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

1429+
if (lex< sequence < exactly <'#'>, identifier > >())
1430+
{ return new (ctx.mem) String_Quoted(pstate, lexed); }
1431+
14291432
// also handle the 10em- foo special case
14301433
if (lex< sequence< dimension, optional< sequence< exactly<'-'>, negate< digit > > > > >())
14311434
{ return new (ctx.mem) Textual(pstate, Textual::DIMENSION, lexed); }
@@ -1641,9 +1644,12 @@ namespace Sass {
16411644
(*schema) << new (ctx.mem) Textual(pstate, Textual::NUMBER, lexed);
16421645
}
16431646
// lex hex color value
1644-
else if (lex< hex >()) {
1647+
else if (lex< sequence < hex, negate < exactly < '-' > > > >()) {
16451648
(*schema) << new (ctx.mem) Textual(pstate, Textual::HEX, lexed);
16461649
}
1650+
else if (lex< sequence < exactly <'#'>, identifier > >()) {
1651+
(*schema) << new (ctx.mem) String_Quoted(pstate, lexed);
1652+
}
16471653
// lex a value in parentheses
16481654
else if (peek< parenthese_scope >()) {
16491655
(*schema) << parse_factor();

0 commit comments

Comments
 (0)