aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-11-06 00:12:46 +0100
committerJohn MacFarlane <[email protected]>2025-11-06 00:12:46 +0100
commit5c3144feb8b8eecf39f64c510caed6192bbf15cf (patch)
tree89a401c9f0ef833a0f402bfbb01b9c8e45ec832b
parent940c22bc3125385e1185063940219b4f17a88d03 (diff)
PDF: avoid converting SVG to PDF when non-TeX PDF engine is used.
This fixes a 3.8 regression, which caused documents with SVGs to raise an error when converted to PDF using WeasyPrint. Closes #11275.
-rw-r--r--src/Text/Pandoc/PDF.hs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index ff0c7d4e3..22cc9918a 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -104,7 +104,13 @@ makePDF program pdfargs writer opts doc = withTempDir (program == "typst") "medi
opts{ writerExtensions = disableExtension Ext_smart
(writerExtensions opts) }
else opts
- source <- handleImages opts' tmpdir doc >>= writer opts'
+ source <- fillMediaBag doc
+ >>= extractMedia tmpdir
+ >>= (if isTeXFormat program
+ then walkM (convertImages opts' tmpdir)
+ else return)
+ >>= writer opts'
+
verbosity <- getVerbosity
let compileHTML mkOutArgs = do
-- check to see if there is anything in mediabag, and if so,
@@ -212,16 +218,7 @@ makeWithWkhtmltopdf program pdfargs writer opts doc@(Pandoc meta _) = do
verbosity <- getVerbosity
liftIO $ toPdfViaTempFile verbosity program args (:[]) ".html" source
-handleImages :: (PandocMonad m, MonadIO m)
- => WriterOptions
- -> FilePath -- ^ temp dir to store images
- -> Pandoc -- ^ document
- -> m Pandoc
-handleImages opts tmpdir doc =
- fillMediaBag doc >>=
- extractMedia tmpdir >>=
- walkM (convertImages opts tmpdir)
-
+-- convert SVG to PDF, and pixel formatst to PNG or JPEG, for TeX formats
convertImages :: (PandocMonad m, MonadIO m)
=> WriterOptions -> FilePath -> Inline -> m Inline
convertImages opts tmpdir (Image attr ils (src, tit)) = do