quarto-dev / quarto-dev/quarto-cli

[Docusaurus] html-math-method: webtex config ignored - math rendered as tex_math_dollars

Open
#13,853 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug docusaurus
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

The html-math-method: webtex configuration in _extension.yml is not being applied. Math equations are output as $$..$$ (tex_math_dollars) instead of webtex image URLs.

Expected behavior

Per documentation:

"By default, Quarto renders LaTeX math within Docusaurus projects using WebTeX"

Expected output:

![](https://latex.codecogs.com/svg.latex?e%20%3D%20mc%5E2)
Actual behavior

Output:

$$e = mc^2$$
Root cause

PR #7996 changed the docusaurus architecture:

Before:

writer: docusaurus_writer.lua  # Custom writer honored all options

After:

quarto-custom-format: docusaurus
filters:
  - at: post-finalize
    path: docusaurus_citeproc.lua

The docusaurus_citeproc.lua filter calls pandoc.write() with a hardcoded format string and only passes columns in options (added in PR #8365):

local cli_opts = { columns = PANDOC_WRITER_OPTIONS.columns }
local result_str = pandoc.write(result, 'markdown_strict+...+tex_math_dollars+...', cli_opts)

The html-math-method and other writer options from _extension.yml are not forwarded.

Evidence

The test snapshot at tests/docs/smoke-all/2024/01/18/docusaurus/equations.mdx.snapshot (created Jan 2024) contains $$ syntax, not webtex URLs - indicating this was already broken when the test was created.

Related
  • PR #7996 - Architectural change that removed custom writer
  • PR #8365 - Partial fix for columns only
  • Issue #8332 - Table column wrapping (led to PR #8365)
Files
  • src/resources/extensions/quarto/docusaurus/_extension.yml (line 31: html-math-method: webtex)
  • src/resources/extensions/quarto/docusaurus/docusaurus_citeproc.lua (line 13-14: pandoc.write call)

This was uncovered while trying to understand snapshot change at #13249

And probably math is not the only problem we missed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/resources/extensions/quarto/docusaurus/docusaurus_citeproc.lua and compare its pandoc.write call with the html-math-method setting in src/resources/extensions/quarto/docusaurus/_extension.yml. Run the Docusaurus equations smoke test and inspect tests/docs/smoke-all/2024/01/18/docusaurus/equations.mdx.snapshot. Done means the configured webtex output is preserved and the regression is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.