git.iko.soy/typeable/html-parse
on master help sign in
Avoid notInClass in tagName'
9e43188Ben Gamari
Text/HTML/Parser.hs+9−1
@@ -117,6 +117,14 @@ isWhitespace '\x0c' = True
117isWhitespace ' ' = True
117isWhitespace ' ' = True
118isWhitespace _ = False
118isWhitespace _ = False
119
119
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+
120-- | /§8.2.4.8/: Tag name state: the open case
128-- | /§8.2.4.8/: Tag name state: the open case
121--
129--
122-- deviation: no lower-casing, don't handle NULL characters
130-- deviation: no lower-casing, don't handle NULL characters
@@ -140,7 +148,7 @@ tagName' :: Parser Text
140tagName' = do
148tagName' = do
141 c <- peekChar'
149 c <- peekChar'
142 guard $ isAsciiUpper c || isAsciiLower c
150 guard $ isAsciiUpper c || isAsciiLower c
143− takeWhile $ notInClass "\x09\x0a\x0c /<>"
151+ takeWhile $ not . (isWhitespace `orC` isC '/' `orC` isC '<' `orC` isC '>')
144
152
145-- | /§8.2.4.40/: Self-closing start tag state
153-- | /§8.2.4.40/: Self-closing start tag state
146selfClosingStartTag :: TagName -> [Attr] -> Parser Token
154selfClosingStartTag :: TagName -> [Attr] -> Parser Token