Skip to content

[v2.0.35] PR into master from dev/olga/Add-option-to-display-mathml-latex-insted-of-svg#400

Draft
OlgaRedozubova wants to merge 20 commits intomasterfrom
dev/olga/Add-option-to-display-mathml-latex-insted-of-svg
Draft

[v2.0.35] PR into master from dev/olga/Add-option-to-display-mathml-latex-insted-of-svg#400
OlgaRedozubova wants to merge 20 commits intomasterfrom
dev/olga/Add-option-to-display-mathml-latex-insted-of-svg

Conversation

@OlgaRedozubova
Copy link
Contributor

@OlgaRedozubova OlgaRedozubova commented Jan 29, 2026

branch: dev/olga/Add-option-to-display-mathml-latex-insted-of-svg

Related PR https://github.com/Mathpix/monorepo/pull/17963

What's been changed:

  • Math Output Format (output_format option)

    • Added output_format option to TOutputMath to control which math format is placed in HTML output:
      • 'svg' (default): Pre-rendered SVG with hidden format elements. Works offline.
      • 'mathml': Native <math> elements only. Smaller output, requires client-side rendering.
      • 'latex': Raw LaTeX source (HTML-escaped). Smallest output, requires client-side rendering.
  • Browser Bundles

    • auto-render.js (es5/browser/auto-render.js) — New client-side rendering bundle.
      • Scans .math-inline and .math-block elements for TeX delimiters or raw MathML
      • Renders to SVG via MathJax, generates hidden format elements for context menu
      • Skips already-rendered elements (data-mathpix-typeset marker)
      • Configurable via window.MathpixRenderConfig or renderMathInElement(container, config)
      • Accessibility support via MathpixAccessibilityConfig:
        • assistive_mml: Add <mjx-assistive-mml> for screen readers
        • include_speech: Add aria-label with speech text via SRE
    • add-speech.js (es5/browser/add-speech.js) — New client-side speech bundle.
      • Adds speech accessibility to already-rendered SVG math (e.g. server-rendered with assistiveMml: true)
      • Loads SRE asynchronously, generates aria-label, role="math", tabindex="0" on each mjx-container
      • Auto-runs on DOMContentLoaded or callable via window.MathpixSpeech.addSpeechToRenderedMath(container)
  • Fixes

    • math-block[data-width=full] centering: Scoped style to avoid affecting equation numbering layout
    • SRE pinned to 4.0.7: Prevents browser compatibility issues with newer SRE versions
  • Tests

    • tests/_output_format.js — SVG/MathML/LaTeX routing, include_* flag interaction, accessibility, parseMarkdownByHTML, edge cases including malformed LaTeX
    • tests/_auto_render.js — TeX delimiter recognition, MathML input, skip logic, data-mathpix-typeset, accessibility config
    • tests/_add_speech.jsaddSpeechToMathContainer DOM mutations, addAriaToMathHTML string API, speech content validation
  • Docs

    • Added implementation details in pr-specs/2026-01-html-math-output-options.md.
    • Updated README.md and doc/changelog.md

TODO:

  • Add tests

@OlgaRedozubova OlgaRedozubova self-assigned this Jan 29, 2026
@OlgaRedozubova OlgaRedozubova changed the title Created pr-specrs for TML Math Output Options and Browser Render Script Created pr-specrs for HTML Math Output Options and Browser Render Script Jan 29, 2026
@OlgaRedozubova OlgaRedozubova changed the title Created pr-specrs for HTML Math Output Options and Browser Render Script [v2.0.34] PR into master from dev/olga/Add-option-to-display-mathml-latex-insted-of-svg Feb 4, 2026
@OlgaRedozubova OlgaRedozubova changed the title [v2.0.34] PR into master from dev/olga/Add-option-to-display-mathml-latex-insted-of-svg [v2.0.35] PR into master from dev/olga/Add-option-to-display-mathml-latex-insted-of-svg Feb 9, 2026
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.

1 participant