git.iko.soy/typeable/pandoc
on master help sign in
PDF: More conservative solution to #777.
cb1ede5John MacFarlane
src/Text/Pandoc/PDF.hs+11−2
@@ -50,7 +50,8 @@ import System.Environment
50import System.Exit (ExitCode (..))
50import System.Exit (ExitCode (..))
51import System.FilePath
51import System.FilePath
52import System.IO (stdout)
52import System.IO (stdout)
53−import System.IO.Temp (withSystemTempDirectory, withTempFile)
53+import System.IO.Temp (withSystemTempDirectory, withTempDirectory,
54+ withTempFile)
54#if MIN_VERSION_base(4,8,3)
55#if MIN_VERSION_base(4,8,3)
55import System.IO.Error (IOError, isDoesNotExistError)
56import System.IO.Error (IOError, isDoesNotExistError)
56#else
57#else
@@ -102,7 +103,15 @@ makePDF program pdfargs writer opts doc = do
102 baseProg -> do
103 baseProg -> do
103 commonState <- getCommonState
104 commonState <- getCommonState
104 verbosity <- getVerbosity
105 verbosity <- getVerbosity
106+ -- latex has trouble with tildes in paths, which
107+ -- you find in Windows temp dir paths with longer
108+ -- user names (see #777)
109+ let withTempDir templ action = do
110+ tmp <- getTemporaryDirectory
111+ if '~' `elem` tmp
112+ then withTempDirectory "." templ action
105− liftIO $ withSystemTempDirectory "tex2pdf." $ \tmpdir -> do
113+ else withSystemTempDirectory templ action
114+ liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do
106 source <- runIOorExplode $ do
115 source <- runIOorExplode $ do
107 putCommonState commonState
116 putCommonState commonState
108 doc' <- handleImages tmpdir doc
117 doc' <- handleImages tmpdir doc