git.iko.soy/typeable/pandoc
on master help sign in
PDF: Use / as path separators in latex input only

Fixes compile error on Windows for 5040f3e Reverted back to canonical file separators </> in all places except for arguments to the LaTeX builder and in TEXINPUTS See #1151. Note: Temporary directories still fail to be removed in Windows due to call of ByteString.Lazy.readFile creating process ownership of the compiled pdf file.

commit1aed9208f883c3bf67f81582b149912de832273a authorTim Lin <timtylin@gmail.com> dateMon 10 Mar 2014, 16:23 (13 years ago) parent5040f3e
1 file changed+15−12
src/Text/Pandoc/PDF.hs+15−12
src/Text/Pandoc/PDF.hs+15−12
@@ -56,11 +56,11 @@ import Data.List (intercalate)
5656#endif
5757
5858withTempDir :: String -> (FilePath -> IO a) -> IO a
59−withTempDir f =
59+withTempDir =
6060#ifdef _WINDOWS
61− withTempDirectory "." (f . changePathSeparators)
61+ withTempDirectory "."
6262#else
63− withSystemTempDirectory f
63+ withSystemTempDirectory
6464#endif
6565
6666#ifdef _WINDOWS
@@ -99,8 +99,7 @@ handleImage' baseURL tmpdir (Image ils (src,tit)) = do
9999 let ext = fromMaybe (takeExtension src) $
100100 extensionFromMimeType mime
101101 let basename = UTF8.toString $ B64.encode $ UTF8.fromString src
102− -- note: we want / even on Windows, for TexLive:
103− let fname = tmpdir ++ "/" ++ basename <.> ext
102+ let fname = tmpdir </> basename <.> ext
104103 BS.writeFile fname contents
105104 return $ Image ils (fname,tit)
106105 _ -> do
@@ -152,18 +151,22 @@ extractMsg log' = do
152151runTeXProgram :: String -> Int -> FilePath -> String
153152 -> IO (ExitCode, ByteString, Maybe ByteString)
154153runTeXProgram program runsLeft tmpDir source = do
155− let file = tmpDir ++ "/input.tex"
154+ let file = tmpDir </> "input.tex"
156155 exists <- doesFileExist file
157156 unless exists $ UTF8.writeFile file source
158− let programArgs = ["-halt-on-error", "-interaction", "nonstopmode",
159− "-output-directory", tmpDir, file]
160− env' <- getEnvironment
161157#ifdef _WINDOWS
162− let sep = ";"
158+ -- note: we want / even on Windows, for TexLive
159+ let tmpDir' = changePathSeparators tmpDir
160+ let file' = changePathSeparators file
163161#else
164− let sep = ":"
162+ let tmpDir' = tmpDir
163+ let file' = file
165164#endif
166− let texinputs = maybe (tmpDir ++ sep) ((tmpDir ++ sep) ++)
165+ let programArgs = ["-halt-on-error", "-interaction", "nonstopmode",
166+ "-output-directory", tmpDir', file']
167+ env' <- getEnvironment
168+ let sep = searchPathSeparator:[]
169+ let texinputs = maybe (tmpDir' ++ sep) ((tmpDir' ++ sep) ++)
167170 $ lookup "TEXINPUTS" env'
168171 let env'' = ("TEXINPUTS", texinputs) :
169172 [(k,v) | (k,v) <- env', k /= "TEXINPUTS"]