Skip to content
Open
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
50 changes: 46 additions & 4 deletions src/Html/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ tagAttribute =

tagAttributeName : Parser String
tagAttributeName =
Parser.getChompedString (chompOneOrMore isTagAttributeCharacter)
Parser.getChompedString
(Parser.chompIf isTagAttributeNameHeadCharacter
|. Parser.chompWhile isTagAttributeNameTailCharacter
)
|> Parser.map String.toLower


Expand Down Expand Up @@ -477,9 +480,48 @@ voidElements =
-- Character validators


isTagAttributeCharacter : Char -> Bool
isTagAttributeCharacter c =
not (isSpaceCharacter c) && c /= '"' && c /= '\'' && c /= '>' && c /= '/' && c /= '='
isTagAttributeNameHeadCharacter : Char -> Bool
isTagAttributeNameHeadCharacter c =
Char.isAlpha c || c == ':' || c == '_' || isExtendedTagAttributeNameHeadCharacter c


isExtendedTagAttributeNameHeadCharacter : Char -> Bool
isExtendedTagAttributeNameHeadCharacter c =
let
code =
Char.toCode c
in
-- Latin extended + Greek
(code >= 0xC0 && code <= 0x02FF)
-- More scripts
|| (code >= 0x0370 && code <= 0x1FFF)
-- Superscripts
|| (code >= 0x2070 && code <= 0x218F)
-- Various scripts + CJK
|| (code >= 0x2C00 && code <= 0xD7FF)
-- Compatibility + presentation
|| (code >= 0xF900 && code <= 0xFFFD)
-- All supplementary planes
|| (code >= 0x00010000)


isTagAttributeNameTailCharacter : Char -> Bool
isTagAttributeNameTailCharacter c =
isTagAttributeNameHeadCharacter c || Char.isDigit c || c == '-' || c == '.' || isExtendedTagAttributeNameTailCharacter c


isExtendedTagAttributeNameTailCharacter : Char -> Bool
isExtendedTagAttributeNameTailCharacter c =
let
code =
Char.toCode c
in
-- Middle dot
(code == 0xB7)
-- Combining marks
|| (code >= 0x0300 && code <= 0x036F)
-- Ties
|| (code >= 0x203F && code <= 0x2040)


isSpaceCharacter : Char -> Bool
Expand Down