aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-10-30 17:49:46 +0100
committerJohn MacFarlane <[email protected]>2025-10-30 17:49:46 +0100
commit2c6cd8327aaaaa64f4a5fd340d6805ec625de8d6 (patch)
treebcc7babb7cbbbf11b6548678470dc9cad47b6b71
parent379e389e20af3d8770a7642b72e222c81265ddfc (diff)
PDF: fix regression with typst and smart quotes.
Before 3.8, the default behavior when producing a PDF `-t typst` was to produce smart quotes according to typst's defaults. (This could be defeated by specifying `-t typst-smart`.) This behavior broke in 3.8 because of a change to Text.Pandoc.PDF. This change caused `smart` to be disabled for all formats when producing PDFs, when before it was only disable for TeX-based formats (to avoid bad ligatures). This commit restores the old behavior. Possibly the regression also other affects other non-TeX formats, e.g. HTML. Closes #11256.
-rw-r--r--src/Text/Pandoc/PDF.hs26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index e7804b00d..ff0c7d4e3 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -90,11 +90,21 @@ makePDF program pdfargs writer opts doc = withTempDir (program == "typst") "medi
#else
let tmpdir = mediaDir
#endif
- doc' <- handleImages opts tmpdir doc
- source <- writer opts{ writerExtensions = -- disable use of quote
- -- ligatures to avoid bad ligatures like ?`
- disableExtension Ext_smart
- (writerExtensions opts) } doc'
+ let isTeXFormat "context" = True
+ isTeXFormat "tectonic" = True
+ isTeXFormat "latexmk" = True
+ isTeXFormat "lualatex" = True
+ isTeXFormat "lualatex-dev" = True
+ isTeXFormat "pdflatex" = True
+ isTeXFormat "pdflatex-dev" = True
+ isTeXFormat "xelatex" = True
+ isTeXFormat _ = False
+ let opts' = if isTeXFormat program
+ then -- disable quote ligatures to avoid bad ligatures like ?`
+ opts{ writerExtensions = disableExtension Ext_smart
+ (writerExtensions opts) }
+ else opts
+ source <- handleImages opts' tmpdir doc >>= writer opts'
verbosity <- getVerbosity
let compileHTML mkOutArgs = do
-- check to see if there is anything in mediabag, and if so,
@@ -106,7 +116,7 @@ makePDF program pdfargs writer opts doc = withTempDir (program == "typst") "medi
liftIO $
toPdfViaTempFile verbosity program pdfargs mkOutArgs ".html" source'
case takeBaseName program of
- "wkhtmltopdf" -> makeWithWkhtmltopdf program pdfargs writer opts doc
+ "wkhtmltopdf" -> makeWithWkhtmltopdf program pdfargs writer opts' doc
"pagedjs-cli" -> compileHTML (\f -> ["-o", f])
"prince" -> compileHTML (\f -> ["-o", f])
"weasyprint" -> compileHTML (:[])
@@ -114,7 +124,7 @@ makePDF program pdfargs writer opts doc = withTempDir (program == "typst") "medi
toPdfViaTempFile verbosity program ("compile":pdfargs) (:[]) ".typ" source
"pdfroff" -> do
let paperargs =
- case lookupContext "papersize" (writerVariables opts) of
+ case lookupContext "papersize" (writerVariables opts') of
Just s
| T.takeEnd 1 s == "l" -> ["-P-p" <>
T.unpack (T.dropEnd 1 s), "-P-l"]
@@ -127,7 +137,7 @@ makePDF program pdfargs writer opts doc = withTempDir (program == "typst") "medi
generic2pdf program args source
"groff" -> do
let paperargs =
- case lookupContext "papersize" (writerVariables opts) of
+ case lookupContext "papersize" (writerVariables opts') of
Just s
| T.takeEnd 1 s == "l" -> ["-P-p" <>
T.unpack (T.dropEnd 1 s), "-P-l"]