aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-02-02 11:31:29 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-02-02 11:31:29 -0800
commit737c0a684eaa03774b862ddcaf8c1ad7ef147571 (patch)
tree18348a84d881edee0954da411f6108ad65064b23 /src/Text
parent9225583ccf43879584aa98d75c978d911fc1f5fa (diff)
downloadpandoc-737c0a684eaa03774b862ddcaf8c1ad7ef147571.tar.gz
PDF: use system temp dir and set TEXMFOUTPUT.
Previously the temp directory was created inside the working directory, so that programs like epstopdf.pl would be allowed to run in restricted mode. However, setting TEXMFOUTPUT allows these programs to run in the tmpdir inside the system temp directory. This is a better solution than cd51983. Using the system temp dir prevents problems when pandoc is run inside a synced directory (e.g. dropbox). Partially addresses #1192.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/PDF.hs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index 3484699c0..f7c7f744e 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -50,7 +50,7 @@ import System.Environment
import System.Exit (ExitCode (..))
import System.FilePath
import System.IO (stdout)
-import System.IO.Temp (withTempDirectory, withTempFile)
+import System.IO.Temp (withSystemTempDirectory, withTempFile)
#if MIN_VERSION_base(4,8,3)
import System.IO.Error (IOError, isDoesNotExistError)
#else
@@ -100,14 +100,9 @@ makePDF program pdfargs writer opts doc = do
verbosity <- getVerbosity
liftIO $ ms2pdf verbosity program args source
baseProg -> do
- -- With context and latex, we create a temp directory within
- -- the working directory, since pdflatex sometimes tries to
- -- use tools like epstopdf.pl, which are restricted if run
- -- on files outside the working directory.
- let withTemp = withTempDirectory "."
commonState <- getCommonState
verbosity <- getVerbosity
- liftIO $ withTemp "tex2pdf." $ \tmpdir -> do
+ liftIO $ withSystemTempDirectory "tex2pdf." $ \tmpdir -> do
source <- runIOorExplode $ do
putCommonState commonState
doc' <- handleImages tmpdir doc
@@ -291,7 +286,9 @@ runTeXProgram verbosity program args runNumber numRuns tmpDir source = do
let texinputs = maybe (tmpDir' ++ sep) ((tmpDir' ++ sep) ++)
$ lookup "TEXINPUTS" env'
let env'' = ("TEXINPUTS", texinputs) :
- [(k,v) | (k,v) <- env', k /= "TEXINPUTS"]
+ ("TEXMFOUTPUT", tmpDir') :
+ [(k,v) | (k,v) <- env'
+ , k /= "TEXINPUTS" && k /= "TEXMFOUTPUT"]
when (verbosity >= INFO && runNumber == 1) $ do
putStrLn "[makePDF] temp dir:"
putStrLn tmpDir'