git.iko.soy/typeable/pandoc
on master help sign in
EPUB Reader: Removed incorrectly set reader flag
commit116f03a70a8525565850f2779af2b6b348676267 authorMatthew Pickering <matthewtpickering@gmail.com> dateFri 8 Aug 2014, 19:58 (12 years ago) parentaae90a8
1 file changed+9−5
src/Text/Pandoc/Readers/EPUB.hs+9−5
src/Text/Pandoc/Readers/EPUB.hs+9−5
@@ -51,7 +51,7 @@ runEPUB = either error id . runExcept
5151-- are of the form "filename#id"
5252--
5353archiveToEPUB :: (MonadError String m) => ReaderOptions -> Archive -> m (Pandoc, MediaBag)
54−archiveToEPUB os archive = do
54+archiveToEPUB (setEPUBOptions -> os) archive = do
5555 (root, content) <- getManifest archive
5656 meta <- parseMeta content
5757 (cover, items) <- parseManifest content
@@ -65,9 +65,6 @@ archiveToEPUB os archive = do
6565 let mediaBag = fetchImages (M.elems items) root archive ast
6666 return $ (ast, mediaBag)
6767 where
68− rs = readerExtensions os
69− os' = os {readerExtensions = foldr S.insert rs [Ext_epub_html_exts, Ext_raw_html]}
70− os'' = os' {readerParseRaw = True}
7168 parseSpineElem :: MonadError String m => FilePath -> (FilePath, MIME) -> m Pandoc
7269 parseSpineElem (normalise -> r) (normalise -> path, mime) = do
7370 when (readerTrace os) (traceM path)
@@ -78,13 +75,20 @@ archiveToEPUB os archive = do
7875 mimeToReader "application/xhtml+xml" r path = do
7976 fname <- findEntryByPathE (r </> path) archive
8077 return $ fixInternalReferences (r </> path) .
81− readHtml os'' .
78+ readHtml os .
8279 UTF8.toStringLazy $
8380 fromEntry fname
8481 mimeToReader s _ path
8582 | s `elem` imageMimes = return $ imageToPandoc path
8683 | otherwise = return $ mempty
8784
85+setEPUBOptions :: ReaderOptions -> ReaderOptions
86+setEPUBOptions os = os''
87+ where
88+ rs = readerExtensions os
89+ os' = os {readerExtensions = foldr S.insert rs [Ext_epub_html_exts]}
90+ os'' = os' {readerParseRaw = True}
91+
8892fetchImages :: [(FilePath, MIME)]
8993 -> FilePath
9094 -> Archive