git.iko.soy/typeable/pandoc
on master help sign in
Allow use of -output-directory in --pdf-engine-opt.
d88a601John MacFarlane
src/Text/Pandoc/PDF.hs+6−4
@@ -47,7 +47,7 @@ import Text.Pandoc.Writers.Shared (getField, metaToJSON)
47#ifdef _WINDOWS
47#ifdef _WINDOWS
48import Data.List (intercalate)
48import Data.List (intercalate)
49#endif
49#endif
50−import Data.List (isPrefixOf)
50+import Data.List (isPrefixOf, find)
51import Text.Pandoc.Class (PandocIO, extractMedia, fillMediaBag, getCommonState,
51import Text.Pandoc.Class (PandocIO, extractMedia, fillMediaBag, getCommonState,
52 getVerbosity, putCommonState, report,
52 getVerbosity, putCommonState, report,
53 runIOorExplode, setVerbosity)
53 runIOorExplode, setVerbosity)
@@ -330,10 +330,12 @@ getResultingPDF logFile pdfFile = do
330runTeXProgram :: Verbosity -> String -> [String] -> Int -> Int -> FilePath
330runTeXProgram :: Verbosity -> String -> [String] -> Int -> Int -> FilePath
331 -> Text -> PandocIO (ExitCode, ByteString, Maybe ByteString)
331 -> Text -> PandocIO (ExitCode, ByteString, Maybe ByteString)
332runTeXProgram verbosity program args runNumber numRuns tmpDir' source = do
332runTeXProgram verbosity program args runNumber numRuns tmpDir' source = do
333+ let isOutdirArg x = "-outdir=" `isPrefixOf` x ||
334+ "-output-directory=" `isPrefixOf` x
333 let tmpDir =
335 let tmpDir =
334− case [x | x <- args, "-outdir=" `isPrefixOf` x] of
336+ case find isOutdirArg args of
335− [x] -> drop 8 x
337+ Just x -> drop 1 $ dropWhile (/='=') x
336− _ -> tmpDir'
338+ Nothing -> tmpDir'
337 liftIO $ createDirectoryIfMissing True tmpDir
339 liftIO $ createDirectoryIfMissing True tmpDir
338 let file = tmpDir ++ "/input.tex" -- note: tmpDir has / path separators
340 let file = tmpDir ++ "/input.tex" -- note: tmpDir has / path separators
339 exists <- liftIO $ doesFileExist file
341 exists <- liftIO $ doesFileExist file