sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.67k stars 99 forks source link

MathML mathvariant support is incomplete #2146

Closed Omikhleia closed 3 weeks ago

Omikhleia commented 1 month ago

Our implementation of thee MathML mathvariant attribute only supports but a few of the possibilities from MathML3.[^1]

It's true that MathML4 and MathML Core both encourage the direct use of Unicode characters, making mathvariant somewhat legacy... but the logic is useful for parity with LaTeX in our TeX math like syntax...

--> I'm on this one.

Fonts such as Libertinus Serif have a good coverage for these characters, so a show case demo even becomes easy:

image

One always need a nice target, bits by bits... Eventually... Say the Schwinger–Dyson equation

\left\langle\psi\left|\mathcal{T}\left\{\frac{\delta}{\delta\phi}F[\phi]\right\}\right|\psi\right\rangle = -\mathrm{i}\left\langle\psi\left|\mathcal{T}\left\{F[\phi]\frac{\delta}{\delta\phi}S[\phi]\right\}\right|\psi\right\rangle`

Should give what's expected...

image

(Firefox rendered MathML from Pandoc's output for Wikipedia's TeX-based formula).

We are not yet there (oh those \left and \right... on another day), but there's a way. Don't you think oh my dear "math friends"? -- or here, rather, my "theoretical physicist friends" :clown_face:

[^1]: See our of mathVariantToScriptType and related code: 5 out of 18 (we might not support all of them, see next note, but we can support most. [^2]: There's some arabic stuff too, but I'll likely suggest to keep it out of this issue for now.

Omikhleia commented 1 month ago

Interesting side effect... Before:

image

After:

image

EDIT: MathJax has the capital greek macros in the mathchar7 parsing method (= defaults to "normal") and the lowercase greek macro in mathchar0mi (= defaults to italic). So it would seem the expectation is: image

(\Gamma upright, but \zeta italic)