Skip to content

Commit

Permalink
PDF: Got --resource-path working with pdf output.
Browse files Browse the repository at this point in the history
See #852.
  • Loading branch information
jgm committed May 20, 2017
1 parent d109c8b commit 6a7f980
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Text/Pandoc/PDF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ import Text.Pandoc.Writers.Shared (getField, metaToJSON)
import Data.List (intercalate)
#endif
import Text.Pandoc.Class (PandocIO, report, runIO, runIOorExplode,
setMediaBag, setVerbosity,
fillMediaBag, extractMedia)
setMediaBag, setVerbosity, getResourcePath,
setResourcePath, fillMediaBag, extractMedia)
import Text.Pandoc.Logging

#ifdef _WINDOWS
Expand Down Expand Up @@ -112,8 +112,9 @@ makePDF program writer opts verbosity mediabag doc = do
let withTemp = if takeBaseName program == "context"
then withTempDirectory "."
else withTempDir
resourcePath <- getResourcePath
liftIO $ withTemp "tex2pdf." $ \tmpdir -> do
doc' <- handleImages verbosity opts mediabag tmpdir doc
doc' <- handleImages verbosity opts resourcePath mediabag tmpdir doc
source <- runIOorExplode $ do
setVerbosity verbosity
writer opts doc'
Expand All @@ -126,13 +127,15 @@ makePDF program writer opts verbosity mediabag doc = do

handleImages :: Verbosity
-> WriterOptions
-> [FilePath]
-> MediaBag
-> FilePath -- ^ temp dir to store images
-> Pandoc -- ^ document
-> IO Pandoc
handleImages verbosity opts mediabag tmpdir doc = do
handleImages verbosity opts resourcePath mediabag tmpdir doc = do
doc' <- runIOorExplode $ do
setVerbosity verbosity
setResourcePath resourcePath
setMediaBag mediabag
fillMediaBag (writerSourceURL opts) doc >>=
extractMedia tmpdir
Expand Down

0 comments on commit 6a7f980

Please sign in to comment.