git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1508 from mpickering/master

EPUB: Fixed another mediabag related regression..

commitc2a0d47c7b15483efa565ab2b6d9fa836e3a8818 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 9 Aug 2014, 17:08 (12 years ago) parent1ea92c34ae61bd
1 file changed+5−3
src/Text/Pandoc/Readers/EPUB.hs+5−3
src/Text/Pandoc/Readers/EPUB.hs+5−3
@@ -62,7 +62,7 @@ archiveToEPUB os archive = do
6262 foldM' (\a b -> ((a <>) . bottomUp (prependHash escapedSpine))
6363 `liftM` parseSpineElem root b) mempty spine
6464 let ast = coverDoc <> (Pandoc meta bs)
65− let mediaBag = fetchImages (M.elems items) archive ast
65+ let mediaBag = fetchImages (M.elems items) root archive ast
6666 return $ (ast, mediaBag)
6767 where
6868 os' = os {readerParseRaw = True}
@@ -86,16 +86,18 @@ archiveToEPUB os archive = do
8686-- paths should be absolute when this function is called
8787-- renameImages should do this
8888fetchImages :: [(FilePath, MIME)]
89+ -> FilePath -- ^ Root
8990 -> Archive
9091 -> Pandoc
9192 -> MediaBag
92−fetchImages mimes arc (query iq -> links) =
93+fetchImages mimes root arc (query iq -> links) =
9394 foldr (uncurry3 insertMedia) mempty
9495 (mapMaybe getEntry links)
9596 where
9697 getEntry link =
98+ let abslink = root </> link in
9799 (link , lookup link mimes, ) . fromEntry
98− <$> findEntryByPath link arc
100+ <$> findEntryByPath abslink arc
99101
100102iq :: Inline -> [FilePath]
101103iq (Image _ (url, _)) = [url]