From e1304aa59c2a942be5487e8ad774f323b7740e2b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 25 Feb 2017 21:46:41 +0100 Subject: Fetch images when generating PDF via context. To do this, we create the temp directory as a subdirectory of the working directory. Since context mk IV by default looks for images in the parent directory, this works. Closes #3380. --- src/Text/Pandoc/PDF.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index b1108008c..ff206daaa 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -38,7 +38,7 @@ import Data.Monoid ((<>)) import System.Exit (ExitCode (..)) import System.FilePath import System.IO (stdout) -import System.IO.Temp (withTempFile) +import System.IO.Temp (withTempFile, withTempDirectory) import System.Directory import Data.Digest.Pure.SHA (showDigest, sha1) import System.Environment @@ -104,8 +104,11 @@ makePDF "wkhtmltopdf" writer opts verbosity _ doc@(Pandoc meta _) = liftIO $ do setVerbosity verbosity writer opts doc html2pdf verbosity args source -makePDF program writer opts verbosity mediabag doc = - liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do +makePDF program writer opts verbosity mediabag doc = do + let withTemp = if takeBaseName program == "context" + then withTempDirectory "." + else withTempDir + liftIO $ withTemp "tex2pdf." $ \tmpdir -> do doc' <- handleImages verbosity opts mediabag tmpdir doc source <- runIOorExplode $ do setVerbosity verbosity -- cgit v1.2.3