w3c / mathml-core

MathML Core draft
https://w3c.github.io/mathml-core
38 stars 14 forks source link

behavior of `display: math` on mainline HTML ? #176

Closed dginev closed 1 year ago

dginev commented 1 year ago

I was trying to read up on the discussions around display: math, and I seem to have a question/topic of discussion that is not yet explicitly addressed.

Reading through 2.3.1 The display: block math and display: inline math value, I see:

For elements that are not MathML elements, if the specified value of display is inline math or block math then the computed value is block flow and inline flow respectively.

I am wondering if that is (long-term) a bit of a missed opportunity, or if this fallback is already the most reasonable course of action. Likely what I am thinking of is quite naive, but here it is:

Would it be beneficial if MathML Core could provide a mainline HTML dialect that can be mapped to the (superior) MathML rendering, simply by adding a display style annotation? For example, would it be helpful/possible to make the following two trees render identically (MathML left, mixed HTML+MathML right):

```xml 2 x + y = ( a1 a2 ) 2 ``` ```html 2 x + y = (
a 1
a 2
)
2
```

There seem to be roughly three levels of matching up:

  1. some elements have temptingly simple "cousins" in HTML, such as

    • span for mrow
    • table, tr and td for mtable, mtr and mtd.
    • sub and sup are rather similar to msub and msup, except for the base being outside, rather than inside.
  2. others have no obvious equivalents and (maybe?) would need to be mixed in directly

    • mfrac, msqrt, mroot
  3. Some almost fit, but need an extra styling annotation. Notably the token elements.

    • mi, mo, mn, ms all remind of variations on span with attached custom styling
    • e.g. I have seen em employed for what would be a MathML mi in HTML publications in the past.

Probably not practical in the short-term, but it makes me wonder. I know that there is a very large body of simple math expressions that have been authored in old school HTML, and can be studied in e.g. the large PubMedCentral corpus, which is larger than arXiv in size. Here is a concrete real-world example from PMC1797058, paragraph 16, which I could imagine getting enhanced with a few extra HTML elements until a display:inline-math can map it into MathML-grade rendering:

<em>I</em> = <em>G</em><sub>max</sub> × 
  (<em>V</em> − <em>V<sub>re</sub></em><sub>v</sub>)
  /
  (1+ exp(−(<em>V</em> − <em>V</em><sub>50,act</sub>)/<em>k</em>))

Comments welcome, and apologies in advance if the suggestion has been discussed before, or is too simplistic to be workable.

bkardell commented 1 year ago

As discussed in the call, we already have some open issues discussing some of this in CSS which will likely be still for v2 or beyond - but none of them would allow an update to the above without touching markup, nor would they convey anything particularly as accessible as MathML - so, in those cases specifically, even if we had the CSS abilities it's probably better to just convert to MathML while you're making the necessary markup changes.