@@ -45,7 +45,7 @@ import Text.XML.Light hiding (ppTopElement)
45import Text.Pandoc.UUID
45import Text.Pandoc.UUID
46import Text.Pandoc.Writers.HTML
46import Text.Pandoc.Writers.HTML
47import Text.Pandoc.Writers.Markdown ( writePlain )
47import Text.Pandoc.Writers.Markdown ( writePlain )
48−import Data.Char ( toLower, isDigit )
48+import Data.Char ( toLower )
49import Network.URI ( unEscapeString )
49import Network.URI ( unEscapeString )
51-- | Produce an EPUB file from a Pandoc document.
51-- | Produce an EPUB file from a Pandoc document.
@@ -282,12 +282,9 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity .
282 where unEntity [] = ""
282 where unEntity [] = ""
283 unEntity ('&':'#':xs) =
283 unEntity ('&':'#':xs) =
284 let (ds,ys) = break (==';') xs
284 let (ds,ys) = break (==';') xs
285− c = if (all isDigit ds)
286− then Just $ read $ '\'' : '\\' : ds ++ "'"
288 rest = drop 1 ys
285 rest = drop 1 ys
289− in case c of
286+ in case reads ('\'':'\\':ds ++ "'") of
290− Just x | x > '\127' -> x : unEntity rest
287+ ((x,_):_) | x > '\127' -> x : unEntity rest
291 _ -> ('&':'#':ds) ++ ";" ++ unEntity rest
288 _ -> ('&':'#':ds) ++ ";" ++ unEntity rest
292 unEntity (x:xs) = x : unEntity xs
289 unEntity (x:xs) = x : unEntity xs