git.iko.soy/typeable/pandoc
on master help sign in
Entity handling fixes:

- Text.Pandoc.XML.fromEntities: handle entities without a semicolon. Always lookup character references with the trailing ';', even if it wasn't present. And never add it when looking up numerical entities. (This is what tagsoup seems to require.) - Text.Pandoc.Parsing.characterReference: Always lookup character references with the trailing ';', and leave off the ';' when looking up numerical entities. This fixes a regression for e.g. `⟨`.

commit12a5bd3c8d34eddbabee0dc54fd7ce6d9539c9d4 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 8 Jan 2016, 17:08 (11 years ago) parent52d95dd
2 files changed+10−3
src/Text/Pandoc/Parsing.hs+4−1 src/Text/Pandoc/XML.hs+6−2
src/Text/Pandoc/Parsing.hs+4−1
@@ -573,7 +573,10 @@ characterReference :: Stream s m Char => ParserT s st m Char
573573characterReference = try $ do
574574 char '&'
575575 ent <- many1Till nonspaceChar (char ';')
576− case lookupEntity ent of
576+ let ent' = case ent of
577+ '#':_ -> ent
578+ _ -> ent ++ ";"
579+ case lookupEntity ent' of
577580 Just c -> return c
578581 Nothing -> fail "entity not found"
579582
src/Text/Pandoc/XML.hs+6−2
@@ -100,11 +100,15 @@ toEntities (c:cs)
100100-- Unescapes XML entities
101101fromEntities :: String -> String
102102fromEntities ('&':xs) =
103− case lookupEntity ent of
103+ case lookupEntity ent' of
104104 Just c -> c : fromEntities rest
105105 Nothing -> '&' : fromEntities xs
106106 where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
107107 (zs,';':ys) -> (zs,ys)
108− _ -> ("",xs)
108+ (zs, ys) -> (zs,ys)
109+ ent' = case ent of
110+ '#':_ -> ent
111+ _ -> ent ++ ";"
112+
109113fromEntities (x:xs) = x : fromEntities xs
110114fromEntities [] = []