diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-12 09:17:54 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-12 09:17:54 -0800 |
commit | d8d68c51103beec39bc400d60a5c9281bf018945 (patch) | |
tree | 47f7ef78ae6724e370614c74003b368e5b03cdd9 /src | |
parent | bdb7648de24888b38196f59f83359af2f097aaa0 (diff) | |
download | pandoc-d8d68c51103beec39bc400d60a5c9281bf018945.tar.gz |
EPUB writer: made unEntity handle errors better.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 9 |
1 files changed, 3 insertions, 6 deletions
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 = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\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 |