diff --git a/src/Text/Taggy/Parser.hs b/src/Text/Taggy/Parser.hs index 485e022..5709e6b 100644 --- a/src/Text/Taggy/Parser.hs +++ b/src/Text/Taggy/Parser.hs @@ -84,23 +84,11 @@ possibly c = (char c *> return ()) ident :: Parser T.Text ident = - takeWhile1 (\c -> isAlphaNum c - || c == '-' - || c == '_' - || c == ':' - || c == '.' - ) + takeWhile1 (\c -> isAlphaNum c || c `elem` "-_:.") attribute_ident :: Parser T.Text attribute_ident = - takeWhile1 (\c -> isAlphaNum c - || c == '-' - || c == '_' - || c == ':' - || c == '(' - || c == ')' - || c == ',' - ) + takeWhile1 (\c -> isAlphaNum c || c `elem` "-_:(),\"/.") tagopen :: Bool -> Parser Tag tagopen cventities = do diff --git a/tests/Text/Taggy/ParserSpec.hs b/tests/Text/Taggy/ParserSpec.hs index 3fbc25e..5679a7f 100644 --- a/tests/Text/Taggy/ParserSpec.hs +++ b/tests/Text/Taggy/ParserSpec.hs @@ -45,6 +45,13 @@ spec = do "
" ~> tagopen False `shouldParse` TagOpen "br" [] True + it "successfully (and forgivingly) parses " $ + "<title foo\">" ~> tagopen False + `shouldParse` TagOpen "title" [Attribute "foo\"" ""] False + it "successfully (and forgivingly) parses <title https://github.com/alpmestan/taggy\">" $ + "<title https://github.com/alpmestan/taggy/\">" ~> tagopen False + `shouldParse` TagOpen "title" [Attribute "https://github.com/alpmestan/taggy/\"" ""] False + it "can successfully convert entities in attribute values: <a title=\" Hello!\">" $ "<a title=\" Hello!\">" ~> tagopen True `shouldParse` TagOpen "a" [Attribute "title" "\160Hello!"] False