Skip to content

Commit

Permalink
Merge pull request #256 from DanHodges/issue-255
Browse files Browse the repository at this point in the history
fix css comment bug.
  • Loading branch information
lolgab authored Sep 6, 2021
2 parents e1bf5e6 + 1b38279 commit a1f2598
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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
24 changes: 24 additions & 0 deletions cssparse/test/src/cssparse/CssTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
}
}

0 comments on commit a1f2598

Please sign in to comment.