Latex to MathML in Hugo

Different solutions

The most common solution to display math formula in browser with hugo is mathjax, the readability is really good but the javascript frontend implementation is a no go for me. I chose to develop this website without it.

Previously, some users try to develop without success a backend alternative to convert the formula in HTML with style. Another viable alternative is to use a shortcode to convert the formula to SVG using math.vercel.app.

Last alternative is MathML, a markup language for math in browser. It is not used because it tooks a long time to implement in current browsers (can-i-use/mathml) and converter for formula are missing.

From LaTeX to MathML

One important policy of hugo is to include only go dependancy in the code. This block most implementation of backend alternative and the development of a converter from scratch looks really hard.

The language I use the most in my work is Python and because of the amazing work of Ronie Martinez on latex2mathml, a pure Python for LaTeX to MathML conversion.

I took the time to naively rewrite it to go latex2mathml-go and include it in hugo hugo-latex2mathml.

You can see it in use in this Restricted Boltzmann Machines note.