From 506b0e98334e882fd24ee1d4ae309d37b1547fe7 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 13 Nov 2026 16:31:13 +0100 Subject: [PATCH 1/2] Keep HTML equation numbers when the math method comes from a CLI flag Crossref equation numbering picks \tag{n} for MathJax and KaTeX and \qquad(n) for every other method, reading the html-math-method filter param. That param came from the Pandoc defaults only, so a method chosen on the command line never reached the filter. On Bootstrap HTML the defaults say mathjax, so --mathml, --math-method=mathml and --math-method=plain got \tag{1}, which those methods drop: the equation number disappeared from the output. The param now comes from resolveHtmlMathMethod when a flag chose the method, as the KaTeX post-processor, the template patch and llms.md output already do. Without a flag it keeps the defaults value, so the default webtex URL Quarto fills in is unchanged. The flag is not written into the defaults or format.pandoc: the template patch relies on telling a flag apart from html-math-method. One visible change: --katex or --mathjax on HTML without Bootstrap now numbers with \tag{1} instead of \qquad(1), as Bootstrap HTML already does. --- src/command/render/filters.ts | 8 +++++++- .../render/render-math-method-flag.test.ts | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/command/render/filters.ts b/src/command/render/filters.ts index a3f8fe4d477..2c9c75ede4e 100644 --- a/src/command/render/filters.ts +++ b/src/command/render/filters.ts @@ -76,6 +76,7 @@ import { mergeConfigs } from "../../core/config.ts"; import { projectType } from "../../project/types/project-types.ts"; import { readCodePage } from "../../core/windows.ts"; import { formatHasBootstrap } from "../../format/html/format-html-info.ts"; +import { resolveHtmlMathMethod } from "../../format/html/format-html-math.ts"; import { activeProfiles, kQuartoProfile } from "../../quarto-core/profile.ts"; import { filterBuiltInExtensions, @@ -608,7 +609,12 @@ async function quartoFilterParams( params[kShortcodes] = params[kShortcodes] || []; (params[kShortcodes] as string[]).push(...extShortcodes); } - params[kHtmlMathMethod] = defaults?.[kHtmlMathMethod]; + // a command line math flag overrides html-math-method for Pandoc, so the + // filters (e.g. equation numbering) must see it too + const flagMathMethod = resolveHtmlMathMethod(format, options.flags); + params[kHtmlMathMethod] = flagMathMethod?.fromFlag + ? flagMathMethod.method + : defaults?.[kHtmlMathMethod]; const figResponsive = format.metadata[kFigResponsive] === true; if (figResponsive) { diff --git a/tests/smoke/render/render-math-method-flag.test.ts b/tests/smoke/render/render-math-method-flag.test.ts index 0aa2f56ea50..b40acf55f4b 100644 --- a/tests/smoke/render/render-math-method-flag.test.ts +++ b/tests/smoke/render/render-math-method-flag.test.ts @@ -30,3 +30,21 @@ testRender(input, "html", false, [ /window\.backupDefine = window\.define/, ]), ], {}, ["--math-method", "katex"]); + +// The equation number must survive a method that ignores \tag. The number is +// matched in the rendered MathML, not in its TeX annotation. +const mathmlNumber = /]*>\(<\/mo>1<\/mn>/; +testRender(input, "html", false, [ + noErrorsOrWarnings, + ensureFileRegexMatches(output.outputPath, [mathmlNumber]), +], {}, ["--math-method=mathml"]); + +// --mathml is deprecated since Pandoc 3.11 and warns, so no warning check +testRender(input, "html", false, [ + ensureFileRegexMatches(output.outputPath, [mathmlNumber]), +], {}, ["--mathml"]); + +testRender(input, "html", false, [ + noErrorsOrWarnings, + ensureFileRegexMatches(output.outputPath, [/2<\/sup>\s*\(1\)/]), +], {}, ["--math-method=plain"]); From 9d8225db3cfb7d1f24f95771a5bee972ebe68b84 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 13 Nov 2026 16:45:05 +0100 Subject: [PATCH 2/2] Add changelog entry for equation numbers with CLI math flags --- news/changelog-1.12.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.12.md b/news/changelog-1.12.md index c4bf00005c8..362b716a4ed 100644 --- a/news/changelog-1.12.md +++ b/news/changelog-1.12.md @@ -78,6 +78,7 @@ All changes included in 1.12: ### `quarto render` - ([#15321](https://github.com/quarto-dev/quarto-cli/pull/15321)): Support Pandoc's `--math-method` option, so `--math-method=katex` works with `--embed-resources` and in `llms.md` output, as `--katex` does. +- ([#15358](https://github.com/quarto-dev/quarto-cli/pull/15358)): Fix equation numbers missing from HTML output when the math method is chosen with `--mathml` or `--math-method`. ## Extensions