ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
447 stars 92 forks source link

Replace MathJax by KaTeX #301

Open ggrossetie opened 3 years ago

ggrossetie commented 3 years ago

MathJax is extremely powerful but does too much. For instance, MathJax is loading additional modules/components at runtime and, currently, it's not straightforward to inline fonts. Also, the rendering is a bit slow and the complete bundle size is pretty heavy.

As an alternative, we could use KaTex: https://katex.org/docs/browser.html

Related issue: https://github.com/asciidoctor/asciidoctor-browser-extension/issues/280

ggrossetie commented 3 years ago

KaTeX does not support AsciiMath out-of-the-box so we need to use https://github.com/christianp/asciimath2tex (or similar) to convert from AsciiMath to LaTeX.

RoxvilleRooster commented 3 years ago

Can you at least make MathJax an optional processor? I was mainly here for the MathJax. I ask because MathJax is very forgiving. We have some complex math equations that I need to convert from MathML to latexmath (via Pandoc) and the conversion is not always ideal. But its good enough for MathJax. Mathjax renders the equation whereas other tools for doing so that I am testing (asciidoctor-latex and asciidoctor-mathematical) are way more fussy and require that I clean up the equations (a non-trivial task when you have thousands of equations). I believe that asciidoctor-mathematical uses the katex library currently...

ggrossetie commented 3 years ago

Can you at least make MathJax an optional processor?

That's a good idea, we could have more than one processor for math formulas (a default processor and one or more alternative processors).

Please note that MathJax is still the current processor and as mentioned in https://github.com/Mogztter/asciidoctor-web-pdf/pull/315 KaTeX lacks some features so we won't make the switch anytime soon.