git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: made unEntity handle errors better.
commitd8d68c51103beec39bc400d60a5c9281bf018945 authorJohn MacFarlane <fiddlosopher@gmail.com> dateMon 12 Dec 2011, 09:17 (15 years ago) parentbdb7648
1 file changed+3−6
src/Text/Pandoc/Writers/EPUB.hs+3−6
src/Text/Pandoc/Writers/EPUB.hs+3−6
@@ -45,7 +45,7 @@ import Text.XML.Light hiding (ppTopElement)
4545import Text.Pandoc.UUID
4646import Text.Pandoc.Writers.HTML
4747import Text.Pandoc.Writers.Markdown ( writePlain )
48−import Data.Char ( toLower, isDigit )
48+import Data.Char ( toLower )
4949import Network.URI ( unEscapeString )
5050
5151-- | Produce an EPUB file from a Pandoc document.
@@ -282,12 +282,9 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity .
282282 where unEntity [] = ""
283283 unEntity ('&':'#':xs) =
284284 let (ds,ys) = break (==';') xs
285− c = if (all isDigit ds)
286− then Just $ read $ '\'' : '\\' : ds ++ "'"
287− else Nothing
288285 rest = drop 1 ys
289− in case c of
290− Just x | x > '\127' -> x : unEntity rest
286+ in case reads ('\'':'\\':ds ++ "'") of
287+ ((x,_):_) | x > '\127' -> x : unEntity rest
291288 _ -> ('&':'#':ds) ++ ";" ++ unEntity rest
292289 unEntity (x:xs) = x : unEntity xs
293290