aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-08-08 22:28:08 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2014-08-08 22:31:27 +0100
commit40ae8efddc243f75941328b66fce94e0c0ff3e16 (patch)
tree41050c8536ce14dafc3a1ae0a087eaf86e0611eb /src/Text
parent8c551f6f43772420d5e6db8108e5a7a7786b7fc4 (diff)
downloadpandoc-40ae8efddc243f75941328b66fce94e0c0ff3e16.tar.gz
EPUB Reader: Fixed regressions in image extraction
Before the images were relative to the position of the package file. The collapse function changed this so that they were then absolute in the archive but the fetchImages function wasn't updated to recognise this.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/EPUB.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs
index c17f00989..2967bd09a 100644
--- a/src/Text/Pandoc/Readers/EPUB.hs
+++ b/src/Text/Pandoc/Readers/EPUB.hs
@@ -62,7 +62,7 @@ archiveToEPUB (setEPUBOptions -> os) archive = do
foldM' (\a b -> ((a <>) . bottomUp (prependHash escapedSpine))
`liftM` parseSpineElem root b) mempty spine
let ast = coverDoc <> (Pandoc meta bs)
- let mediaBag = fetchImages (M.elems items) root archive ast
+ let mediaBag = fetchImages (M.elems items) archive ast
return $ (ast, mediaBag)
where
parseSpineElem :: MonadError String m => FilePath -> (FilePath, MIME) -> m Pandoc
@@ -89,19 +89,19 @@ setEPUBOptions os = os''
os' = os {readerExtensions = foldr S.insert rs [Ext_epub_html_exts]}
os'' = os' {readerParseRaw = True}
+-- paths should be absolute when this function is called
+-- renameImages should do this
fetchImages :: [(FilePath, MIME)]
- -> FilePath
-> Archive
-> Pandoc
-> MediaBag
-fetchImages mimes root arc (query iq -> links) =
+fetchImages mimes arc (query iq -> links) =
foldr (uncurry3 insertMedia) mempty
(mapMaybe getEntry links)
where
- getEntry (normalise -> l) =
- let mediaPos = normalise (root </> l) in
- (l , lookup mediaPos mimes, ) . fromEntry
- <$> findEntryByPath mediaPos arc
+ getEntry link =
+ (link , lookup link mimes, ) . fromEntry
+ <$> findEntryByPath link arc
iq :: Inline -> [FilePath]
iq (Image _ (url, _)) = [url]