Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

MathML to MathJax converter in npm

8 views
Skip to first unread message

Matt VanZoest

unread,
Feb 10, 2025, 9:33:16 PMFeb 10
to MathJax Development
Hi, apologies in advance because I am new here if there is an easy answer or if this has already been discussed, but does the mathjax npm package support MathML to MathJax conversion?

For example, I want to convert a fraction like `<mfrac><mrow><mn>1</mn></mrow><mrow><mn>2</mn></mrow></mfrac>` to the string `\frac{1}{2}`.

My use case is to parse the MathML from a web page into a string I can embed in an Anki flashcard, so that I don't need to hand-write each formula, which is as tedious as the expression is complex.

I have written a utility to do this in TypeScript that I have been using to solve this problem for myself. If this does not exist already, would it be compatible with the existing mathjax npm package, or should I plan to create a separate package if I am interested in open-sourcing this utility?

Sorry again if any of this is obvious, if it is asking a question that has already been addressed, or if this would not generally be useful to very many people.

Matt

Davide Cervone

unread,
Feb 11, 2025, 4:40:18 PMFeb 11
to mathj...@googlegroups.com
First, you should note that MathJax can render MathML directly, so there is no need to convert it to LaTeX, provided Anki allows you to enter MathML (or HTML) into your cards.  It looks like this should be possible according to this site;


Since HTML5 includes MathML, you should just be able to paste in the MathML.  Then if you configure MathJax to process MathML (as well as TeX if you want to use both), there should be no need to convert between the two forms.

Otherwise, there are some MathML-to-LaTeX tools out there, but I haven't really investigated them closely, so I don' know if you are re-inventing the wheel or not.

You should make a separate package (and GitHub repository, or similar), and make it available.  I'm sure there are people who would find it useful.

Thanks for being willing to share!

Davide



--
You received this message because you are subscribed to the Google Groups "MathJax Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-dev/aa217bb7-7cc1-415e-aae3-c70639042ab5n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages