mathjax / mathjax/MathJax

process MathML nested inside mtext

Open
#3,583 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Code Example Feature Request v4
Dominant language
JavaScript
Stars
10.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.
The <mtext> element is allowed to contain arbitrary HTML, and this is now properly supported via allowHtmlInTokenNodes. There are two inconsistencies, though:

  1. if a <math> element appears as direct children of <mtext>, MathJax returns the error 'Improper nesting of math tags'
  2. otherwise, <math> is accepted, but MathJax does not process it

Describe the solution you'd like
<math> descendants of <mtext> should be processed like any other <math>.

Describe alternatives you've considered
To work around 1, it is enough to generate better MathML and split <mtext>, or to wrap the content into a further <div>. For 2, MathML support in browsers is not too bad. So all in all this is a minor issue.

Additional context
This is a rare circumstance, as far as I know. The mathtools documentation has an (artificial!) LaTeX example that can't be replicated properly without nesting MathML-in-HTML-in-MathML, but I haven't encountered it in practice.

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 by tracing MathML handling for and the allowHtmlInTokenNodes path. Reproduce both cases described in the issue—direct and nested

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.