diff --git a/cssparse/src/cssparse/CssParser.scala b/cssparse/src/cssparse/CssParser.scala index 617562b6..d0d3c1e2 100644 --- a/cssparse/src/cssparse/CssParser.scala +++ b/cssparse/src/cssparse/CssParser.scala @@ -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") diff --git a/cssparse/test/src/cssparse/CssTests.scala b/cssparse/test/src/cssparse/CssTests.scala index f705ac2e..ae25e1e3 100644 --- a/cssparse/test/src/cssparse/CssTests.scala +++ b/cssparse/test/src/cssparse/CssTests.scala @@ -191,6 +191,30 @@ object CssTests extends TestSuite { UnicodeRangeToken("0025", "00FF"), DelimToken(","), UnicodeRangeToken("4??", "4??")), false)))))))))) } + + // https://github.com/com-lihaoyi/fastparse/issues/255 + test("issue-#255: comments at the end of a block"){ + val Parsed.Success(value2, index2) = parse( + """ + |p { + | font-family: sans-serif; + | color: red; + | /* test comment */ + |} + | + """.stripMargin, CssRulesParser.ruleList(_)) + + assert( + value2 == + RuleList(Seq( + QualifiedRule( + Left(ElementSelector("p")), + DeclarationList(Seq( + Left(Declaration("font-family", Seq(IdentToken("sans-serif")), false)), + Left(Declaration("color", Seq(IdentToken("red")), false))))))), + index2 == 80 + ) + } } } }