From d8d68c51103beec39bc400d60a5c9281bf018945 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 12 Dec 2011 09:17:54 -0800 Subject: EPUB writer: made unEntity handle errors better. --- src/Text/Pandoc/Writers/EPUB.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 8897473b3..1bc9f0c9e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -45,7 +45,7 @@ import Text.XML.Light hiding (ppTopElement) import Text.Pandoc.UUID import Text.Pandoc.Writers.HTML import Text.Pandoc.Writers.Markdown ( writePlain ) -import Data.Char ( toLower, isDigit ) +import Data.Char ( toLower ) import Network.URI ( unEscapeString ) -- | Produce an EPUB file from a Pandoc document. @@ -282,12 +282,9 @@ ppTopElement = ("\n" ++) . unEntity . where unEntity [] = "" unEntity ('&':'#':xs) = let (ds,ys) = break (==';') xs - c = if (all isDigit ds) - then Just $ read $ '\'' : '\\' : ds ++ "'" - else Nothing rest = drop 1 ys - in case c of - Just x | x > '\127' -> x : unEntity rest + in case reads ('\'':'\\':ds ++ "'") of + ((x,_):_) | x > '\127' -> x : unEntity rest _ -> ('&':'#':ds) ++ ";" ++ unEntity rest unEntity (x:xs) = x : unEntity xs -- cgit v1.2.3