@@ -62,7 +62,7 @@ archiveToEPUB os archive = do
62 foldM' (\a b -> ((a <>) . bottomUp (prependHash escapedSpine))
62 foldM' (\a b -> ((a <>) . bottomUp (prependHash escapedSpine))
63 `liftM` parseSpineElem root b) mempty spine
63 `liftM` parseSpineElem root b) mempty spine
64 let ast = coverDoc <> (Pandoc meta bs)
64 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
66 return $ (ast, mediaBag)
66 return $ (ast, mediaBag)
68 os' = os {readerParseRaw = True}
68 os' = os {readerParseRaw = True}
@@ -86,16 +86,18 @@ archiveToEPUB os archive = do
86-- paths should be absolute when this function is called
86-- paths should be absolute when this function is called
87-- renameImages should do this
87-- renameImages should do this
88fetchImages :: [(FilePath, MIME)]
88fetchImages :: [(FilePath, MIME)]
89+ -> FilePath -- ^ Root
89 -> Archive
90 -> Archive
91 -> MediaBag
92 -> MediaBag
92−fetchImages mimes arc (query iq -> links) =
93+fetchImages mimes root arc (query iq -> links) =
93 foldr (uncurry3 insertMedia) mempty
94 foldr (uncurry3 insertMedia) mempty
94 (mapMaybe getEntry links)
95 (mapMaybe getEntry links)
96 getEntry link =
97 getEntry link =
98+ let abslink = root </> link in
97 (link , lookup link mimes, ) . fromEntry
99 (link , lookup link mimes, ) . fromEntry
98− <$> findEntryByPath link arc
100+ <$> findEntryByPath abslink arc
100iq :: Inline -> [FilePath]
102iq :: Inline -> [FilePath]
101iq (Image _ (url, _)) = [url]
103iq (Image _ (url, _)) = [url]