Add support for html_math_renderer = 'mathml'
Fixes https://github.com/jbms/sphinx-immaterial/issues/233.
I did a bit of experimentation and was able to get MathML output working fairly easily. However, it could benefit from some CSS styling to fix spacing issues.
This would actually be better suited as a change to Sphinx itself, though.
Tagging https://github.com/sphinx-doc/sphinx/issues/6092 for visibility.
could benefit from some CSS styling to fix spacing issues
We could probably use the fonts from the npm mathjax dist when #231 gets finalized, but the code points might need translation or metrics might not match up. It might be easier to switch the font caching source to fontsource. I'm not nearly an expert though.
could benefit from some CSS styling to fix spacing issues
We could probably use the fonts from the npm mathjax dist when #231 gets finalized, but the code points might need translation or metrics might not match up. It might be easier to switch the font caching source to fontsource. I'm not nearly an expert though.
Assuming it is a regular font I expect it will work fine. MathML just encodes math as an element tree but leaves all of the actual layout up to the browser. The MathML converter doesn't know anything about fonts.
I think the choice of font is independent of the issue I had noticed, where using "&" for alignment caused there to be extra space on either side, due to the default padding.
I played around a bit with the rendered RTD build... I think the columnspacing can't be adjusted via CSS:
mtable.align {
columnspacing: 1em;
}
But, setting the columnspacing attr on the element does have a desirable effect. Setting comunmalign="right left" seems to work well also.
Removing the attrs on mtable elements all together seems to use sane defaults (at least for Firefox).
docutils release notes list (under 0.20 changes)
- "html5" writer:
- Change the default value for math_output to "MathML" in Docutils 0.22.
I added some minimal CSS to try to account for missing attribute support in Chrome. I also copied in the docutils math example doc, and modified it to use rst-example.
I couldn't figure out how to make \mathrm and similar styles work in Chrome with CSS. Firefox supports them by default.
Overall it seems like the MathML support isn't quite ready, though maybe it is adequate for light use.