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.
This commit is contained in:
parent
9225583ccf
commit
737c0a684e
1 changed files with 5 additions and 8 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue