Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion src/command/render/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions tests/smoke/render/render-math-method-flag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[^>]*>\(<\/mo><mn>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, [/<sup>2<\/sup>\s*\(1\)/]),
], {}, ["--math-method=plain"]);
Loading