Closed jannikgohr closed 4 weeks ago
I have never used KaTex. Could you provide an example of what content needs to be supported for rendering? Or add a unit test?
I am not exactly sure how to best integrate unit tests here, but I can give a few examples on what KaTeX renders here.
KaTeX is used to render math expressions like:
$$f'_{3}(x)=4$$
So they are rendered like that:
$$f'_{3}(x)=4$$
There are 2 types of math expressions
Joplin uses KaTeX internally as well for that.
But default KaTeX rules were slightly altered when implemented in Joplin:
\$x^2$
; this wouldn't render as math in Joplin)$x^2 $
or $ x^2$
wouldn't be rendered as math in Joplin for that reasonSince I wanted the extension to render by the same rules, I had to make a few modifications.
escapeJoplinMathExceptions() is used to eliminate 'potential' math expressions start and end marker that wouldn't be valid in Joplin
This was done by replacing $ with its Unicode representation $
After the math rendering was done, I undid that with the help of unescapeJoplinMathExceptions()
The rendering itself is done with KaTeX. I had to reference to the original Markdown content of the node to confirm whether the math expression is supposed to be inline or a block, since mdast-util-math sadly doesn't differentiate this.
Hope I could clear up what I wanted to achieve with this Pull Request!
Released 0.10.2. ref: https://github.com/rxliuli/joplin-utils/releases/tag/joplin-search-integration%400.10.2