Skip to content

Support Pandoc's --math-method option in quarto render - #15321

Draft
cderv wants to merge 2 commits into
chore/deps-v1.12-pandocfrom
fix/html-math-method
Draft

cderv wants to merge 2 commits into
chore/deps-v1.12-pandocfrom
fix/html-math-method

Conversation

@cderv

@cderv cderv commented Nov 9, 2026

Copy link
Copy Markdown
Member

Stacked on #15320 (Pandoc 3.13).

Pandoc 3.11 added --math-method=METHOD[:URL] and deprecated --katex, --mathjax, --mathml, --webtex and --gladtex. With 3.13 bundled, quarto render --katex prints Pandoc's deprecation warning pointing to --math-method, but Quarto ignored that option when deciding which math method the command line chose. It kept acting on html-math-method (MathJax by default for Bootstrap HTML):

  • with --math-method=katex --embed-resources, Quarto injected its MathJax loader while Pandoc still emitted the KaTeX render call, so KaTeX was never embedded and math showed as raw TeX;
  • the KaTeX post-processing Quarto does for --katex did not run;
  • llms.md output lost the math delimiters and doubled backslashes.

Fix

quarto render now reads --math-method (and its optional URL) like the legacy flags, and the HTML math handling uses it as the command line choice. The argument still goes to Pandoc unchanged. Output with --math-method=X is now identical to output with the matching legacy --X flag.

The legacy flags are not translated to --math-method: they keep working, and Pandoc's deprecation warning stays, as its advice is now accurate.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone, Pandoc changelog and source
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

@cderv cderv mentioned this pull request Nov 9, 2026
2 of 5 tasks
@posit-snyk-bot

posit-snyk-bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv added this pull request to stack #15322 November 9, 2026 16:45
Pandoc 3.11 added --math-method=METHOD[:URL] and deprecated --katex,
--mathjax, --mathml, --webtex and --gladtex, whose deprecation warning
now points users to the new option. Pandoc honours it, but Quarto only
looked at the old flags to learn which math method the command line
chose, so with --math-method it kept acting on html-math-method (MathJax
by default for Bootstrap HTML):

- with --embed-resources, the template patch swapped Pandoc's $math$
  for Quarto's MathJax loader while Pandoc's KaTeX render call stayed,
  so the KaTeX library was never embedded and math showed as raw TeX;
- the KaTeX post-processor (the require.js define guard) didn't run;
- llms.md output lost the math delimiters and doubled backslashes.

parseRenderFlags now records the method and optional URL, the HTML math
resolver returns it as a command line choice, and the template patch
asks the resolver instead of checking the five legacy flags. The rest
of mathConfig is left as is, so html-math-method behaves as before. The
argument still goes to Pandoc unchanged. Output with --math-method=X is
now byte-identical to output with the matching legacy --X flag.
@cderv
cderv force-pushed the fix/html-math-method branch from c0c74e0 to b8e7dbc Compare November 10, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants