Support parsing classes with dashes and underscore

This commit is contained in:
Jeroen Engels 2024-03-22 11:02:28 +01:00
parent efa46019ef
commit e525d2f17b
2 changed files with 7 additions and 4 deletions

View File

@ -335,7 +335,7 @@ cssRule acc =
Parser.oneOf
[ Parser.succeed (\selector -> Parser.Loop (Set.insert selector acc))
|. Parser.token "."
|= (Parser.chompWhile Char.isAlphaNum
|= (Parser.chompWhile (\c -> Char.isAlphaNum c || c == '-' || c == '_')
|> Parser.getChompedString
)
, Parser.end

View File

@ -94,7 +94,7 @@ import Html
import Html.Attributes as Attr
view model =
Html.span [ "known red" |> Attr.class ] []
Html.span [ "known red-faint under_score" |> Attr.class ] []
"""
|> Review.Test.runWithProjectData projectWithCssClasses (defaults |> withCssFiles [ "*.css" ] |> rule)
|> Review.Test.expectNoErrors
@ -223,9 +223,12 @@ projectWithCssClasses =
.known {
color: blue;
}
.red {
.red-faint {
color: red;
}
.under_score {
color: green;
}
"""
}
]
@ -240,7 +243,7 @@ projectWithUnparsableCssClasses =
.known {
color: blue;
}
.red {
.red-faint {
color: red;
-- missing closing curly brace
"""