git.iko.soy/typeable/pandoc
on master help sign in
Entity handling fixes:
12a5bd3John MacFarlane
src/Text/Pandoc/Parsing.hs+4−1
@@ -573,7 +573,10 @@ characterReference :: Stream s m Char => ParserT s st m Char
573characterReference = try $ do
573characterReference = try $ do
574 char '&'
574 char '&'
575 ent <- many1Till nonspaceChar (char ';')
575 ent <- many1Till nonspaceChar (char ';')
576+ let ent' = case ent of
577+ '#':_ -> ent
578+ _ -> ent ++ ";"
576− case lookupEntity ent of
579+ case lookupEntity ent' of
577 Just c -> return c
580 Just c -> return c
578 Nothing -> fail "entity not found"
581 Nothing -> fail "entity not found"
579
582
src/Text/Pandoc/XML.hs+6−2
@@ -100,11 +100,15 @@ toEntities (c:cs)
100-- Unescapes XML entities
100-- Unescapes XML entities
101fromEntities :: String -> String
101fromEntities :: String -> String
102fromEntities ('&':xs) =
102fromEntities ('&':xs) =
103− case lookupEntity ent of
103+ case lookupEntity ent' of
104 Just c -> c : fromEntities rest
104 Just c -> c : fromEntities rest
105 Nothing -> '&' : fromEntities xs
105 Nothing -> '&' : fromEntities xs
106 where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
106 where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
107 (zs,';':ys) -> (zs,ys)
107 (zs,';':ys) -> (zs,ys)
108− _ -> ("",xs)
108+ (zs, ys) -> (zs,ys)
109+ ent' = case ent of
110+ '#':_ -> ent
111+ _ -> ent ++ ";"
112+
109fromEntities (x:xs) = x : fromEntities xs
113fromEntities (x:xs) = x : fromEntities xs
110fromEntities [] = []
114fromEntities [] = []