diff options
Diffstat (limited to 'src/Text/Pandoc/Readers/EPUB.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/EPUB.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs index cb5f684b2..f900c0adc 100644 --- a/src/Text/Pandoc/Readers/EPUB.hs +++ b/src/Text/Pandoc/Readers/EPUB.hs @@ -14,7 +14,7 @@ import Text.Pandoc.Walk (walk, query) import Text.Pandoc.Generic(bottomUp) import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Options ( ReaderOptions(..), readerTrace) -import Text.Pandoc.Shared (escapeURI, collapseFilePath) +import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField) import Text.Pandoc.MediaBag (MediaBag, insertMedia) import Text.Pandoc.Compat.Except (MonadError, throwError, runExcept, Except) import qualified Text.Pandoc.Builder as B @@ -155,7 +155,7 @@ parseMeta content = do -- http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-metadata-elem parseMetaItem :: Element -> Meta -> Meta parseMetaItem e@(stripNamespace . elName -> field) meta = - B.setMeta (renameMeta field) (B.str $ strContent e) meta + addMetaField (renameMeta field) (B.str $ strContent e) meta renameMeta :: String -> String renameMeta "creator" = "author" @@ -169,10 +169,10 @@ getManifest archive = do ns <- mkE "xmlns not in namespaces" (lookup "xmlns" namespaces) as <- liftM ((map attrToPair) . elAttribs) (findElementE (QName "rootfile" (Just ns) Nothing) docElem) - root <- mkE "Root not found" (lookup "full-path" as) - let rootdir = dropFileName root + manifestFile <- mkE "Root not found" (lookup "full-path" as) + let rootdir = dropFileName manifestFile --mime <- lookup "media-type" as - manifest <- findEntryByPathE root archive + manifest <- findEntryByPathE manifestFile archive liftM ((,) rootdir) (parseXMLDocE . UTF8.toStringLazy . fromEntry $ manifest) -- Fixup @@ -272,7 +272,8 @@ findAttrE :: MonadError String m => QName -> Element -> m String findAttrE q e = mkE "findAttr" $ findAttr q e findEntryByPathE :: MonadError String m => FilePath -> Archive -> m Entry -findEntryByPathE path a = mkE ("No entry on path: " ++ path) $ findEntryByPath path a +findEntryByPathE (normalise -> path) a = + mkE ("No entry on path: " ++ path) $ findEntryByPath path a parseXMLDocE :: MonadError String m => String -> m Element parseXMLDocE doc = mkE "Unable to parse XML doc" $ parseXMLDoc doc |