From d88a601642c30b954bbc057892a359447d0cef4f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 23 Apr 2019 10:08:25 -0700 Subject: Allow use of -output-directory in --pdf-engine-opt. This is currently possible with `mklatex` and `-outdir`, but was not yet possible with xelatex and `-output-directory`. Closes #5462. --- src/Text/Pandoc/PDF.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index 97daa6859..516cc4002 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -47,7 +47,7 @@ import Text.Pandoc.Writers.Shared (getField, metaToJSON) #ifdef _WINDOWS import Data.List (intercalate) #endif -import Data.List (isPrefixOf) +import Data.List (isPrefixOf, find) import Text.Pandoc.Class (PandocIO, extractMedia, fillMediaBag, getCommonState, getVerbosity, putCommonState, report, runIOorExplode, setVerbosity) @@ -330,10 +330,12 @@ getResultingPDF logFile pdfFile = do runTeXProgram :: Verbosity -> String -> [String] -> Int -> Int -> FilePath -> Text -> PandocIO (ExitCode, ByteString, Maybe ByteString) runTeXProgram verbosity program args runNumber numRuns tmpDir' source = do + let isOutdirArg x = "-outdir=" `isPrefixOf` x || + "-output-directory=" `isPrefixOf` x let tmpDir = - case [x | x <- args, "-outdir=" `isPrefixOf` x] of - [x] -> drop 8 x - _ -> tmpDir' + case find isOutdirArg args of + Just x -> drop 1 $ dropWhile (/='=') x + Nothing -> tmpDir' liftIO $ createDirectoryIfMissing True tmpDir let file = tmpDir ++ "/input.tex" -- note: tmpDir has / path separators exists <- liftIO $ doesFileExist file -- cgit v1.2.3