JuliaDocs / Documenter.jl

A documentation generator for Julia.
https://documenter.juliadocs.org
MIT License
799 stars 474 forks source link

Use mathml as an alternative `mathengine` #2504

Open Doublonmousse opened 1 month ago

Doublonmousse commented 1 month ago

It is possible to use server-side rendering for math, converting all math node element to mathml code using pandoc_jll whilst building the website.

On the browser's side, support for mathml (with mathml core) has improved in recent years.

The upside for documentation website is that this removes the need for a (somewhat) large js payload and removes a layout shift upon loading the page as math is rendered at the same time as the rest of the html page. Though maybe there are additional considerations to take into account (support for older browsers ?)

I'm kinda testing this on a fork https://github.com/Doublonmousse/Documenter.jl and checking here if other people think this is a good idea or not.

mortenpi commented 1 month ago

This seems like a reasonable option to have. If it works well, we can maybe even switch the default over.

Though maybe there are additional considerations to take into account (support for older browsers ?)

How old is old? I think that generally it's fine to assume the people run relatively recent browsers.

Doublonmousse commented 1 month ago

From the compatibility standpoint, it seems that outside of chromium-based browser (support only dates back to the start of 2023 with version 109), there isn't an issue with compatibility for older browsers. (see https://www.igalia.com/2023/01/10/Igalia-Brings-MathML-Back-to-Chromium.html and https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math)

For now, the display of math equation seems a little smaller using raw mathml compared to the other two engine, so some additional css might be needed to match the size. I haven't checked how much time the conversion takes on math heavy sites (only that it works reasonably well)

fredrikekre commented 1 month ago

https://caniuse.com/mathml suggests 94% coverage. Perhaps people reading programming docs generally use up-to-date browsers though.