From cb1ede5b085e1372e400f1ff3b0d52ff684f6db7 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 2 Feb 2019 12:35:27 -0800 Subject: 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. --- src/Text/Pandoc/PDF.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc') 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 -- cgit v1.2.3