Permissively parse malformed closing tags, specifically those missing ">".

This commit is contained in:
vi 2014-07-06 17:31:27 +08:00
parent 297c7d477c
commit 66b05584b7
2 changed files with 9 additions and 1 deletions

View File

@ -117,7 +117,7 @@ tagclose = do
char '/'
skipSpace
i <- ident
char '>'
possibly '>'
return $ TagClose i
tagtext :: Bool -> Parser Tag

View File

@ -96,6 +96,14 @@ spec = do
, TagClose "body"
, TagClose "html"
]
it "doesn't choke on malformed closing tags" $
"<strong>North Korea</strong." ~> htmlWith False
`shouldParse` [ TagOpen "strong" [] False
, TagText "North Korea"
, TagClose "strong"
, TagText "."
]
(~>) :: Text -> Parser a -> Either String a
(~>) = (Test.Hspec.Attoparsec.Source.~>)