aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-03-10 17:38:41 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-03-10 17:38:41 -0700
commitc3a2fc643cad7a5d75e0c576aa029a7ec51b8eed (patch)
tree42532da17823611bbec7d893ce5c2e5c96cc476c /src/Text
parent5040f3ede08188610054ff2afab1c3cd9c16c58a (diff)
parent1aed9208f883c3bf67f81582b149912de832273a (diff)
downloadpandoc-c3a2fc643cad7a5d75e0c576aa029a7ec51b8eed.tar.gz
Merge pull request #1190 from eVITAERC/patch/1151-windows-texlive
PDF: Use / as path separators in latex input only
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/PDF.hs27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index 4dfa1d827..a5f1597bd 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -56,11 +56,11 @@ import Data.List (intercalate)
#endif
withTempDir :: String -> (FilePath -> IO a) -> IO a
-withTempDir f =
+withTempDir =
#ifdef _WINDOWS
- withTempDirectory "." (f . changePathSeparators)
+ withTempDirectory "."
#else
- withSystemTempDirectory f
+ withSystemTempDirectory
#endif
#ifdef _WINDOWS
@@ -99,8 +99,7 @@ handleImage' baseURL tmpdir (Image ils (src,tit)) = do
let ext = fromMaybe (takeExtension src) $
extensionFromMimeType mime
let basename = UTF8.toString $ B64.encode $ UTF8.fromString src
- -- note: we want / even on Windows, for TexLive:
- let fname = tmpdir ++ "/" ++ basename <.> ext
+ let fname = tmpdir </> basename <.> ext
BS.writeFile fname contents
return $ Image ils (fname,tit)
_ -> do
@@ -152,18 +151,22 @@ extractMsg log' = do
runTeXProgram :: String -> Int -> FilePath -> String
-> IO (ExitCode, ByteString, Maybe ByteString)
runTeXProgram program runsLeft tmpDir source = do
- let file = tmpDir ++ "/input.tex"
+ let file = tmpDir </> "input.tex"
exists <- doesFileExist file
unless exists $ UTF8.writeFile file source
- let programArgs = ["-halt-on-error", "-interaction", "nonstopmode",
- "-output-directory", tmpDir, file]
- env' <- getEnvironment
#ifdef _WINDOWS
- let sep = ";"
+ -- note: we want / even on Windows, for TexLive
+ let tmpDir' = changePathSeparators tmpDir
+ let file' = changePathSeparators file
#else
- let sep = ":"
+ let tmpDir' = tmpDir
+ let file' = file
#endif
- let texinputs = maybe (tmpDir ++ sep) ((tmpDir ++ sep) ++)
+ let programArgs = ["-halt-on-error", "-interaction", "nonstopmode",
+ "-output-directory", tmpDir', file']
+ env' <- getEnvironment
+ let sep = searchPathSeparator:[]
+ let texinputs = maybe (tmpDir' ++ sep) ((tmpDir' ++ sep) ++)
$ lookup "TEXINPUTS" env'
let env'' = ("TEXINPUTS", texinputs) :
[(k,v) | (k,v) <- env', k /= "TEXINPUTS"]