Is there currently any way in javascript to convert a KaTeX formular to MathJax, I want to support exporting to Anki which just works with MathJax.
If not, is there a table which shows which commands of KaTeX are not supported in MathJax, I can't seem to find one.
I just need the conversion from KaTeX to MathJax, not the other way around
Asked
Active
Viewed 637 times
2

Paul Müller
- 103
- 8
1 Answers
1
A workaround might be the new addon for anki that supports katex. I'm not ready to use it yet (there appears to be some bugs with line-breaking. See comments on the link).
https://ankiweb.net/shared/info/1087328706
I have the same use case as you. I write markdown and katex in vscode (with Markdown+Math extension), and export to anki (using ankdown - slightly modified).
I find that sometimes mathjax causes problems - for example with tags.

Graham A
- 71
- 1
- 3
-
fun thing you shared it here because thats the addon I created after asking this question, thanks for the free promotion :D I'll look into the bugs, didn't see your comment on anki yet because I don't get emails if someone comments there – Paul Müller Mar 07 '21 at 18:49
-
So I tracked down one error in the $$...$$ environment where & is converted to & by anki which you can fix by adding `str = str.replace(/&/g, "&");` but I haven't yet found the bug you mentioned in the comment, could you please provide an example where you get that error? – Paul Müller Mar 07 '21 at 19:46
-
1Try pasting this gist into a card https://gist.github.com/universemaster/8d5a7194599a517d38faa4f8bf20620b – Graham A Mar 08 '21 at 15:51
-
1Ahh I think the reason for that is not the addon but anki in combination with vs code, this is an error I experienced as well, I think the reason for that is that vscode adds colors to the text and if you copy it directly into anki the colors are then added by adding `` tags. If you copy it into a text editor and then into anki the example works. I think adding the code you used in the comment could therefor break some other cases together with VSCode so as a workaround just copy it into a text file and from there into anki! – Paul Müller Mar 08 '21 at 19:42
-
@PaulMüller You are correct that pasting text in the anki editor from elsewhere can cause `` elements. However, this occurs regardless of where the text is pasted *from*. If I paste directly into anki from with the *edit HTML* menu, then I do not get `` elements. I agree, that this isn't a problem with your addon! – Graham A Mar 12 '21 at 15:53
-
Okay I've just noticed that I got the `span` regex anyways in the Cloze card type and it worked till now, you're probably right, I'll add the regex to the addon, thank alot! – Paul Müller Mar 13 '21 at 21:35