git.iko.soy/typeable/html-parse
on master help sign in
Refactor.
315f11fMatthias Fischmann
Text/HTML/Parser.hs+6−13
@@ -91,32 +91,23 @@ tagOpen =
91 (char '!' >> markupDeclOpen)
91 (char '!' >> markupDeclOpen)
92 <|> (char '/' >> endTagOpen)
92 <|> (char '/' >> endTagOpen)
93 <|> (char '?' >> bogusComment)
93 <|> (char '?' >> bogusComment)
94− <|> tryStartTag
94+ <|> tagNameOpen
95 <|> other
95 <|> other
96 where
96 where
97− tryStartTag = do
98− c <- peekChar'
99− guard $ isAsciiUpper c || isAsciiLower c
100− tagNameOpen
101−
102 other = do
97 other = do
103 return $ ContentChar '<'
98 return $ ContentChar '<'
104
99
105-- | /§8.2.4.9/: End tag open state
100-- | /§8.2.4.9/: End tag open state
106endTagOpen :: Parser Token
101endTagOpen :: Parser Token
107−endTagOpen = do
108− tryEndTag
109− where
110− tryEndTag = do
111− c <- peekChar'
112− guard $ isAsciiUpper c || isAsciiLower c
113− tagNameClose
102+endTagOpen = tagNameClose
114
103
115-- | /§8.2.4.10/: Tag name state: the open case
104-- | /§8.2.4.10/: Tag name state: the open case
116--
105--
117-- deviation: no lower-casing
106-- deviation: no lower-casing
118tagNameOpen :: Parser Token
107tagNameOpen :: Parser Token
119tagNameOpen = do
108tagNameOpen = do
109+ c <- peekChar'
110+ guard $ isAsciiUpper c || isAsciiLower c
120 tag <- takeWhile $ notInClass "\x09\x0a\x0c />"
111 tag <- takeWhile $ notInClass "\x09\x0a\x0c />"
121 id $ (satisfy (inClass "\x09\x0a\x0c ") >> beforeAttrName tag [])
112 id $ (satisfy (inClass "\x09\x0a\x0c ") >> beforeAttrName tag [])
122 <|> (char '/' >> selfClosingStartTag tag [])
113 <|> (char '/' >> selfClosingStartTag tag [])
@@ -127,6 +118,8 @@ tagNameOpen = do
127-- deviation: no lower-casing
118-- deviation: no lower-casing
128tagNameClose :: Parser Token
119tagNameClose :: Parser Token
129tagNameClose = do
120tagNameClose = do
121+ c <- peekChar'
122+ guard $ isAsciiUpper c || isAsciiLower c
130 tag <- takeWhile $ notInClass "\x09\x0a\x0c />"
123 tag <- takeWhile $ notInClass "\x09\x0a\x0c />"
131 char '>' >> return (TagClose tag)
124 char '>' >> return (TagClose tag)
132
125