I wrote a KaTeX (essentially "MathJax") parser in Python/Lark

I wrote a Lark EBNF grammar (Python) that is fed to Lark which generates a parser that can parse a huge subset of KaTeX if anyone is interested. This means you can do various things with the resulting parse tree, like: 1. LaTeX-based calculators. 2. Parsing LaTeX to CAS's. 3. A LaTeX-based proof assistant. 4. Standardizing KaTeX formulas so that say \mathscr{A}_1'' is the same thing as \mathscr{A}''_1 (because they appear 100% the same to the user when rendered, so that is important). 5. Extracting your custom definition of variable from KaTeX (and/or MathJax - same difference here) formulas. 6. Converting the parse tree to a Regex so that you can match similar formulas up to variable-substitution. 7. Scraping http://math.stackexchange.com for some killer math app you're working on. And so on... The grammar is huge. Though it can easily be extended should your users request other currently unsupported operators. You may license it ($), and receive some free updates thereafter as it gets beta tested on a Math webapp I'm coding. It currently supports about 25% of the functionality seen on this page: https://katex.org/docs/supported.html but that includes the most common math operators / symbols found in 90% of mathematics roughly. 🤓😎

Comments

Popular posts from this blog

90% visual proof of Contravariant Yoneda Lemma

Every Map $X \xrightarrow{f} \Omega$ is the Characteristic Map of a Monomorphism

Elementary counting formula for the number of $2k$-separated prime pair averages in an interval.