Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested math in token elements. #522

Open
davidcarlisle opened this issue Dec 15, 2024 · 0 comments
Open

nested math in token elements. #522

davidcarlisle opened this issue Dec 15, 2024 · 0 comments
Assignees
Labels
MathML 4 Issues affecting the MathML 4 specification need specification update Issues requiring specification changes

Comments

@davidcarlisle
Copy link
Collaborator

davidcarlisle commented Dec 15, 2024

The following issue arose while working on examples using MathML for accessibility tagging in PDF, looking at typical tex cases
such as a display containing nested text such as

\[
f(n) = \begin{cases}
        1 & \text{if $n$ is prime} \\
        0 & \text{otherwise}
       \end{cases}
\]

$$ f(n) =\begin{cases} 1 & \text{if $n$ is prime} \\ 0 & \text{otherwise} \end{cases} $$

MathML3 and 4 allow HTML elements in presentation token elements when used in html, deferring to the HTML(5) spec for exactly which elements are allowed.

HTML specifies the phrasing content is allowed

https://html.spec.whatwg.org/#phrasing-content-2

The schema used with mathml3 and the current draft mathml-core schema interpreted this by extending the content model of token elements to take text or html, this means that to make a valid version of the above with a nested $n$
in <mtext> you need an intervening html <span>

<mtext><span>if <math><mi>n</mi></math> is prime</span></mtext>

However it was pointed out, correctly I think, that phrasing content at the above link, explicitly lists mathml namespace <math> and svg namespace <svg> as phrasing content, so that they should be valid children of <mtext> and that current browsers do all implement that correctly and this mathml does render as intended.

<mtext>if <math><mi>n</mi></math> is prime</mtext>

This could be fixed in the draft core schema by changing the textorHTML production

https://w3c.github.io/mathml/#parsing_textorHTML

to include | math | svg

and possibly to highlight this in the section on mathml in html at

https://w3c.github.io/mathml/#interf_html

Given that HTML has always specified phrasing content this way and that it is implemented this way in browsers, I think changing the schema is essentially an editorial correction (especially as only draft versions of it have been published so far anyway)

Apart from allowing simpler markup and matching current browser implementations, allowing math directly under mtext means that the common case of nested math which just has text and math such as \text{when $x<0$} can be modelled just using a single, mathml, namespace. You only need to bring in the additional html namespace to model nested textual markup such as \text{something \textbf{bold} about $x$} which is far less common.

So while arguing that this could be viewed as an editiorial correction I think it's a big enough change that it should be logged as an issue, hence this issue.

@davidcarlisle davidcarlisle self-assigned this Dec 15, 2024
@davidcarlisle davidcarlisle added MathML 4 Issues affecting the MathML 4 specification need specification update Issues requiring specification changes labels Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MathML 4 Issues affecting the MathML 4 specification need specification update Issues requiring specification changes
Projects
None yet
Development

No branches or pull requests

1 participant