Add maths support for Paged JS templates PDF output
Context
Ketida allows you to add maths to your chapters and components and the maths renders very well in the editor itself (except for blocks of maths as in https://gitlab.coko.foundation/ketida/ketida/-/issues/564). Ketida also allows you to export to PDF using Paged JS templates. However when you export to PDF, the maths doesn't render. Therefore we need maths support for PDF output (and I'm assuming epub too) which will be crucial to support the content of many valuable books.
In the editor
In the Les Angles PDF
In the Juans Les Pins PDF
Proposal
Design
Implementation (if applicable)
We want to replace katex
with mathjax
. Below we can find the lines of code that should be refactored in order to use mathjax
in a way that the actual tex
content to be transformed into an SVG
which will replace the originated tex
input.
- https://gitlab.coko.foundation/ketida/ketida/-/blob/master/packages/server/api/useCases/utils/converters/cleanHTML.js#L69
- https://gitlab.coko.foundation/ketida/ketida/-/blob/master/packages/server/api/useCases/utils/converters/cleanHTML.js#L82
Some examples listed below:
- https://github.com/mathjax/MathJax-demos-node/blob/master/component/tex2svg
- https://github.com/mathjax/MathJax-demos-node/tree/master/direct#non-component-based-examples
-
https://gitlab.coko.foundation/wax/wax-prosemirror/-/blob/master/wax-prosemirror-services/src/MathService/plugins/math-nodeview.js from line 14-46 and 198-202 is how
Wax
does that.