Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix css comment bug. #256

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
}
}
}
}