git.iko.soy/typeable/pandoc
on master help sign in
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.

commit40ae8efddc243f75941328b66fce94e0c0ff3e16 authorMatthew Pickering <matthewtpickering@gmail.com> dateFri 8 Aug 2014, 22:28 (12 years ago) parent8c551f6
1 file changed+7−7
src/Text/Pandoc/Readers/EPUB.hs+7−7
src/Text/Pandoc/Readers/EPUB.hs+7−7
@@ -62,7 +62,7 @@ archiveToEPUB (setEPUBOptions -> 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) root archive ast
65+ let mediaBag = fetchImages (M.elems items) archive ast
6666 return $ (ast, mediaBag)
6767 where
6868 parseSpineElem :: MonadError String m => FilePath -> (FilePath, MIME) -> m Pandoc
@@ -89,19 +89,19 @@ setEPUBOptions os = os''
8989 os' = os {readerExtensions = foldr S.insert rs [Ext_epub_html_exts]}
9090 os'' = os' {readerParseRaw = True}
9191
92+-- paths should be absolute when this function is called
93+-- renameImages should do this
9294fetchImages :: [(FilePath, MIME)]
93− -> FilePath
9495 -> Archive
9596 -> Pandoc
9697 -> MediaBag
97−fetchImages mimes root arc (query iq -> links) =
98+fetchImages mimes arc (query iq -> links) =
9899 foldr (uncurry3 insertMedia) mempty
99100 (mapMaybe getEntry links)
100101 where
101− getEntry (normalise -> l) =
102− let mediaPos = normalise (root </> l) in
103− (l , lookup mediaPos mimes, ) . fromEntry
104− <$> findEntryByPath mediaPos arc
102+ getEntry link =
103+ (link , lookup link mimes, ) . fromEntry
104+ <$> findEntryByPath link arc
105105
106106iq :: Inline -> [FilePath]
107107iq (Image _ (url, _)) = [url]