Skip to content

Commit

Permalink
enable backtracking on comments, otherwise the parser will error when…
Browse files Browse the repository at this point in the history
… the comment is the last line in a block.
  • Loading branch information
DanHodges committed Aug 14, 2021
1 parent e843bc8 commit fa746b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cssparse/src/cssparse/CssParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import fastparse.NoWhitespace._

object CssTokensParser {

def comment[_: P] = P( "/*" ~/ (!"*/" ~ AnyChar).rep ~/ "*/")
def comment[_: P] = P( "/*" ~ (!"*/" ~ AnyChar).rep ~ "*/")

def newline[_: P] = P( "\n" | "\r\n" | "\r" | "\f")

Expand Down
3 changes: 2 additions & 1 deletion cssparse/test/src/cssparse/CssTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ object CssTests extends TestSuite {
| font-family: sans-serif;
| -webkit-text-size-adjust: 100%;
| -ms-text-size-adjust: 100%;
| /* test comment */
|}
|
""".stripMargin, CssRulesParser.ruleList(_))
Expand All @@ -65,7 +66,7 @@ object CssTests extends TestSuite {
Left(Declaration("font-family", Seq(IdentToken("sans-serif")), false)),
Left(Declaration("-webkit-text-size-adjust", Seq(PercentageToken("100")), false)),
Left(Declaration("-ms-text-size-adjust", Seq(PercentageToken("100")), false))))))),
index2 == 363
index2 == 384
)
}

Expand Down

0 comments on commit fa746b2

Please sign in to comment.