diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-02-02 12:35:27 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-02-02 12:35:27 -0800 |
commit | cb1ede5b085e1372e400f1ff3b0d52ff684f6db7 (patch) | |
tree | b3232beef80156d0b4e466c70f80cbe6f9713a24 | |
parent | 737c0a684eaa03774b862ddcaf8c1ad7ef147571 (diff) | |
download | pandoc-cb1ede5b085e1372e400f1ff3b0d52ff684f6db7.tar.gz |
PDF: More conservative solution to #777.
Now, instead of always creating temp dirs in the home
directory on Windows, we only do it if the system tempdir
name contains tildes. (This will be the case for longer
usernames only.)
Closes #1192.
-rw-r--r-- | src/Text/Pandoc/PDF.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index f7c7f744e..33c872793 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -50,7 +50,8 @@ import System.Environment import System.Exit (ExitCode (..)) import System.FilePath import System.IO (stdout) -import System.IO.Temp (withSystemTempDirectory, withTempFile) +import System.IO.Temp (withSystemTempDirectory, withTempDirectory, + withTempFile) #if MIN_VERSION_base(4,8,3) import System.IO.Error (IOError, isDoesNotExistError) #else @@ -102,7 +103,15 @@ makePDF program pdfargs writer opts doc = do baseProg -> do commonState <- getCommonState verbosity <- getVerbosity - liftIO $ withSystemTempDirectory "tex2pdf." $ \tmpdir -> do + -- latex has trouble with tildes in paths, which + -- you find in Windows temp dir paths with longer + -- user names (see #777) + let withTempDir templ action = do + tmp <- getTemporaryDirectory + if '~' `elem` tmp + then withTempDirectory "." templ action + else withSystemTempDirectory templ action + liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do source <- runIOorExplode $ do putCommonState commonState doc' <- handleImages tmpdir doc |