Convert LaTeX math strings into structured abstract syntax trees (ASTs) β lightweight, Vite-compatible, and built for modern tooling.
This utility parses LaTeX math strings and transforms them into LaTeX ASTs for further processing, analysis, or transformation.
It is a trimmed-down version of @unified-latex/unified-latex-util-parse, built specifically to address compatibility issues with Vite and modern build tools.
- π§ Converts LaTeX math strings to ASTs
- β‘οΈ Lightweight & minimal dependencies
- π Vite-compatible (unlike
@unified-latex/unified-latex-util-parse) - π Easy to integrate with
remark-mathpipelines - π¦ Suitable for client-side or server-side rendering
pnpm add latex-mathor
npm install latex-mathor
yarn add latex-mathimport { parseMath } from "latex-math"; const latex = "\\frac{a}{b}"; const ast = parseMath(latex); console.log(ast);The original package @unified-latex/unified-latex-util-parse is robust, but includes many dependencies and causes issues in Vite-based or modern ESM projects.
This package solves that by providing only what's necessary to parse math-mode LaTeX, with modern compatibility and minimal footprint.
Star this repository and share it with your friends.
This library is licensed under the MPL-2.0 open-source license.
Please enroll in our courses or sponsor our work.
with π by Mayank Kumar Chaudhari
````