aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-08-09 20:45:41 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2014-08-09 23:06:16 +0100
commita6648e5a735b296fa3adda5a7aa75b327e916fe6 (patch)
treeee0c44a57ddf3f18ff180a97a5de48e9853eb096 /src/Text
parent4983083079a6d5095e006a81997d8bc1ddbf1d8e (diff)
downloadpandoc-a6648e5a735b296fa3adda5a7aa75b327e916fe6.tar.gz
EPUB Reader: Changed image paths to be relative to manifest file
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/EPUB.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs
index b6b271488..fd5980f0a 100644
--- a/src/Text/Pandoc/Readers/EPUB.hs
+++ b/src/Text/Pandoc/Readers/EPUB.hs
@@ -55,7 +55,7 @@ archiveToEPUB os archive = do
meta <- parseMeta content
(cover, items) <- parseManifest content
-- No need to collapse here as the image path is from the manifest file
- let coverDoc = fromMaybe mempty (imageToPandoc . (root </>) <$> cover)
+ let coverDoc = fromMaybe mempty (imageToPandoc <$> cover)
spine <- parseSpine items content
let escapedSpine = map (escapeURI . takeFileName . fst) spine
Pandoc _ bs <-
@@ -69,17 +69,17 @@ archiveToEPUB os archive = do
parseSpineElem :: MonadError String m => FilePath -> (FilePath, MIME) -> m Pandoc
parseSpineElem (normalise -> r) (normalise -> path, mime) = do
when (readerTrace os) (traceM path)
- doc <- mimeToReader mime (r </> path)
+ doc <- mimeToReader mime r path
let docSpan = B.doc $ B.para $ B.spanWith (takeFileName path, [], []) mempty
return $ docSpan <> doc
- mimeToReader :: MonadError String m => MIME -> FilePath -> m Pandoc
- mimeToReader "application/xhtml+xml" (normalise -> path) = do
- fname <- findEntryByPathE path archive
+ mimeToReader :: MonadError String m => MIME -> FilePath -> FilePath -> m Pandoc
+ mimeToReader "application/xhtml+xml" (normalise -> root) (normalise -> path) = do
+ fname <- findEntryByPathE (root </> path) archive
return $ fixInternalReferences path .
readHtml os' .
UTF8.toStringLazy $
fromEntry fname
- mimeToReader s path
+ mimeToReader s _ path
| s `elem` imageMimes = return $ imageToPandoc path
| otherwise = return $ mempty