@@ -45,7 +45,7 @@ import Data.Maybe (fromMaybe)
45import qualified Text.Pandoc.UTF8 as UTF8
45import qualified Text.Pandoc.UTF8 as UTF8
46import Text.Pandoc.Definition
46import Text.Pandoc.Definition
47import Text.Pandoc.Walk (walkM)
47import Text.Pandoc.Walk (walkM)
48−import Text.Pandoc.Shared (fetchItem, warn, withTempDir)
48+import Text.Pandoc.Shared (fetchItem', warn, withTempDir)
49import Text.Pandoc.Options (WriterOptions(..))
49import Text.Pandoc.Options (WriterOptions(..))
50import Text.Pandoc.MIME (extensionFromMimeType)
50import Text.Pandoc.MIME (extensionFromMimeType)
51import Text.Pandoc.Process (pipeProcess)
51import Text.Pandoc.Process (pipeProcess)
@@ -65,26 +65,26 @@ makePDF :: String -- ^ pdf creator (pdflatex, lualatex, xelatex)
65 -> Pandoc -- ^ document
65 -> Pandoc -- ^ document
66 -> IO (Either ByteString ByteString)
66 -> IO (Either ByteString ByteString)
67makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do
67makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do
68− doc' <- handleImages (writerSourceURL opts) tmpdir doc
68+ doc' <- handleImages opts tmpdir doc
69 let source = writer opts doc'
69 let source = writer opts doc'
70 tex2pdf' tmpdir program source
70 tex2pdf' tmpdir program source
72−handleImages :: Maybe String -- ^ source base URL
72+handleImages :: WriterOptions
73 -> FilePath -- ^ temp dir to store images
73 -> FilePath -- ^ temp dir to store images
74 -> Pandoc -- ^ document
74 -> Pandoc -- ^ document
75 -> IO Pandoc
75 -> IO Pandoc
76−handleImages baseURL tmpdir = walkM (handleImage' baseURL tmpdir)
76+handleImages opts tmpdir = walkM (handleImage' opts tmpdir)
78−handleImage' :: Maybe String
78+handleImage' :: WriterOptions
79 -> FilePath
79 -> FilePath
81 -> IO Inline
81 -> IO Inline
82−handleImage' baseURL tmpdir (Image ils (src,tit)) = do
82+handleImage' opts tmpdir (Image ils (src,tit)) = do
83 exists <- doesFileExist src
83 exists <- doesFileExist src
85 then return $ Image ils (src,tit)
85 then return $ Image ils (src,tit)
87− res <- fetchItem baseURL src
87+ res <- fetchItem' (writerMediaBag opts) (writerSourceURL opts) src
88 case res of
88 case res of
89 Right (contents, Just mime) -> do
89 Right (contents, Just mime) -> do
90 let ext = fromMaybe (takeExtension src) $
90 let ext = fromMaybe (takeExtension src) $