git.iko.soy/typeable/html-parse
on master help sign in
Avoid notInClass in tagName'
commit9e43188e6effff2fd20a4eb0fe96c085d72cc8f8 authorBen Gamari <ben@smart-cactus.org> dateFri 2 Feb 2018, 20:47 (9 years ago) parent7c4c1e4
1 file changed+9−1
Text/HTML/Parser.hs+9−1
Text/HTML/Parser.hs+9−1
@@ -117,6 +117,14 @@ isWhitespace '\x0c' = True
117117isWhitespace ' ' = True
118118isWhitespace _ = False
119119
120+orC :: (Char -> Bool) -> (Char -> Bool) -> Char -> Bool
121+orC f g c = f c || g c
122+{-# INLINE orC #-}
123+
124+isC :: Char -> Char -> Bool
125+isC = (==)
126+{-# INLINE isC #-}
127+
120128-- | /§8.2.4.8/: Tag name state: the open case
121129--
122130-- deviation: no lower-casing, don't handle NULL characters
@@ -140,7 +148,7 @@ tagName' :: Parser Text
140148tagName' = do
141149 c <- peekChar'
142150 guard $ isAsciiUpper c || isAsciiLower c
143− takeWhile $ notInClass "\x09\x0a\x0c /<>"
151+ takeWhile $ not . (isWhitespace `orC` isC '/' `orC` isC '<' `orC` isC '>')
144152
145153-- | /§8.2.4.40/: Self-closing start tag state
146154selfClosingStartTag :: TagName -> [Attr] -> Parser Token