aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-12-17 17:30:29 -0800
committerJohn MacFarlane <[email protected]>2024-12-17 17:30:29 -0800
commitd6edb57797b2d043715a23ba1de19c0c654b0f37 (patch)
tree09d4a77298b05967b4754371df4e231894739976
parent7d1962b61721784c18ddfd063102f5cbaa4996c7 (diff)
Text.Pandoc.PDF: fix temp file extension in `toPdfViaTempFile`.
We used to set this to `.html`, but this seemed inappropriate once we started using this function for `--pdf-engine=typst`. So we changed it in pandoc 3.6 to `.source`. But apparently `wkhtmltopdf` needs it to be `.html`. So now we have added a parameter to `toPdfViaTempFile` that allows the extension to be specified. Closes #10468.
-rw-r--r--src/Text/Pandoc/PDF.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index 2565b24b8..5896e2e84 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -91,12 +91,12 @@ makePDF program pdfargs writer opts doc =
else [f]
source <- writer opts doc
verbosity <- getVerbosity
- liftIO $ toPdfViaTempFile verbosity program pdfargs mkOutArgs source
+ liftIO $ toPdfViaTempFile verbosity program pdfargs mkOutArgs ".html" source
"typst" -> do
source <- writer opts doc
verbosity <- getVerbosity
liftIO $
- toPdfViaTempFile verbosity program ("compile":pdfargs) (:[]) source
+ toPdfViaTempFile verbosity program ("compile":pdfargs) (:[]) ".typ" source
"pdfroff" -> do
source <- writer opts doc
let paperargs =
@@ -184,7 +184,7 @@ makeWithWkhtmltopdf program pdfargs writer opts doc@(Pandoc meta _) = do
-- see #6474
source <- writer opts doc
verbosity <- getVerbosity
- liftIO $ toPdfViaTempFile verbosity program args (:[]) source
+ liftIO $ toPdfViaTempFile verbosity program args (:[]) ".html" source
handleImages :: (PandocMonad m, MonadIO m)
=> WriterOptions
@@ -469,10 +469,11 @@ toPdfViaTempFile ::
-> String -- ^ Program (program name or path)
-> [String] -- ^ Args to program
-> (String -> [String]) -- ^ Construct args for output file
+ -> String -- ^ extension to use for input file (e.g. '.html')
-> Text -- ^ Source
-> IO (Either ByteString ByteString)
-toPdfViaTempFile verbosity program args mkOutArgs source =
- withTempFile "." "toPdfViaTempFile.source" $ \file h1 ->
+toPdfViaTempFile verbosity program args mkOutArgs extension source =
+ withTempFile "." ("toPdfViaTempFile" <> extension) $ \file h1 ->
withTempFile "." "toPdfViaTempFile.pdf" $ \pdfFile h2 -> do
hClose h1
hClose h2