aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-04-26 20:33:15 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-04-26 20:36:06 -0700
commit26fefa040a7046bbe00e3caf2597f33e65af5986 (patch)
tree0a53c1edc381fa7032efc917b643e40c94c4cf84 /src/Text/Pandoc
parentfdd5f26d1412540dba58693e5065541eb37420e4 (diff)
downloadpandoc-26fefa040a7046bbe00e3caf2597f33e65af5986.tar.gz
PDF: On Windows, create temdir in working directory.
Reason: the path to the system temp directory may contain tildes, which causes problems in LaTeX when the username is more than eight characters. Closes #777.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/PDF.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index 4f3f38a14..3227fd0bd 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings, CPP #-}
{-
Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
@@ -45,10 +45,18 @@ import Text.Pandoc.UTF8 as UTF8
import Control.Monad (unless)
import Data.List (isInfixOf)
+withTempDir :: String -> (FilePath -> IO a) -> IO a
+withTempDir =
+#ifdef _WINDOWS
+ withTempDirectory "."
+#else
+ withSystemTempDirectory
+#endif
+
tex2pdf :: String -- ^ tex program (pdflatex, lualatex, xelatex)
-> String -- ^ latex source
-> IO (Either ByteString ByteString)
-tex2pdf program source = withSystemTempDirectory "tex2pdf" $ \tmpdir ->
+tex2pdf program source = withTempDir "tex2pdf." $ \tmpdir ->
tex2pdf' tmpdir program source
tex2pdf' :: FilePath -- ^ temp directory for output