https://github.com/tiny-md/latex-math
A utility for parsing LaTeX math into abstract syntax trees.
https://github.com/tiny-md/latex-math
javascript latex latex-ma markdow mayank1513 nodejs typescript
Last synced: 3 months ago
JSON representation
A utility for parsing LaTeX math into abstract syntax trees.
- Host: GitHub
- URL: https://github.com/tiny-md/latex-math
- Owner: tiny-md
- License: mpl-2.0
- Created: 2025-03-21T13:12:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-21T17:42:56.000Z (about 1 year ago)
- Last Synced: 2025-03-21T17:54:24.696Z (about 1 year ago)
- Topics: javascript, latex, latex-ma, markdow, mayank1513, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 296 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# LaTeX Math to AST 
[](https://github.com/tiny-md/latex-math/actions/workflows/test.yml) [](https://codeclimate.com/github/tiny-md/latex-math/maintainability) [](https://codecov.io/gh/tiny-md/latex-math) [](https://www.npmjs.com/package/latex-math) [](https://www.npmjs.com/package/latex-math)  [](https://gitpod.io/from-referrer/)
> Convert LaTeX math strings into structured abstract syntax trees (ASTs) — lightweight, Vite-compatible, and built for modern tooling.
---
## ✨ Overview
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`](https://www.npmjs.com/package/@unified-latex/unified-latex-util-parse)**, built specifically to address compatibility issues with **Vite** and modern build tools.
---
## 🚀 Features
- 🧠 Converts LaTeX math strings to ASTs
- ⚡️ Lightweight & minimal dependencies
- 🛠 Vite-compatible (unlike `@unified-latex/unified-latex-util-parse`)
- 🔌 Easy to integrate with `remark-math` pipelines
- 📦 Suitable for client-side or server-side rendering
---
### Installation
```bash
pnpm add latex-math
```
**_or_**
```bash
npm install latex-math
```
**_or_**
```bash
yarn add latex-math
```
---
## 🔧 Usage
```ts
import { parseMath } from "latex-math";
const latex = "\\frac{a}{b}";
const ast = parseMath(latex);
console.log(ast);
```
---
## 📚 Why this exists
The original package [`@unified-latex/unified-latex-util-parse`](https://github.com/unified-latex/unified-latex) 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](https://github.com/tiny-md/latex-math) and share it with your friends.
## 📄 License
This library is licensed under the MPL-2.0 open-source license.
>
Please enroll in [our courses](https://mayank-chaudhari.vercel.app/courses) or [sponsor](https://github.com/sponsors/mayank1513) our work.
with 💖 by Mayank Kumar Chaudhari
````