https://github.com/andstor/latex-math-parser
:wrench: Parser for parsing LaTeX math expressions
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.7%) to scientific vocabulary
Keywords
Repository
:wrench: Parser for parsing LaTeX math expressions
Basic Info
- Host: GitHub
- Owner: andstor
- License: mit
- Language: PEG.js
- Default Branch: main
- Homepage: https://www.npmjs.com/package/@andstor/latex-math-parser
- Size: 120 KB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
- Releases: 2
Topics
Metadata Files
README.md
latex-math-parser
A parser for LaTeX math expressions.
This parser converts LaTeX math syntax into an abstract syntax tree (AST) representation. It is built using PEG.js and supports a mostly complete set of standard LaTeX math expressions.
Installation
bash
npm install @andstor/latex-math-parser
Usage
```js const { parse } = require('@andstor/latex-math-parser');
const latex = '\frac{a}{b} + \sqrt{x}'; const ast = parse(latex);
console.log(JSON.stringify(ast, null, 2)); ```
Generators
This parser can be used with various code generators to convert the AST into different programming languages or formats. Currently supported generators include: - maxima-codegen: Maxima is a computer algebra system that can manipulate symbolic expressions.
Features
The complete grammar for this parser can be found at src/grammars/latex.pegjs. Following are some of the key features supported by the parser:
- Arithmetic operations: Addition, subtraction, multiplication, division, modulo, exponentiation, and implied multiplication.
- Logical and bitwise operations: Logical AND/OR, bitwise AND/OR/XOR, relational and equality operators.
- Assignment expressions: Standard and compound assignments (e.g.,
=,+=,*=, etc.). - Function calls: Built-in and user-defined functions, including support for argument lists and nested calls.
- Fractions: Parsing of LaTeX
\fracexpressions. - Limits: Parsing of limit expressions (e.g.,
\lim). - Logarithms: Parsing of logarithms with arbitrary bases, including
\log,\ln, and\lg. - Binomial coefficients: Parsing of
\binom. - Summations: Parsing of
\sumwith lower and upper bounds. - Integrals: Parsing of definite and indefinite integrals (
\int). - Differentials: Parsing of differential expressions.
- Trigonometric functions: Parsing of all standard and inverse trigonometric functions.
- Roots: Parsing of square roots and nth roots (
\sqrt). - Absolute value: Parsing of absolute value expressions.
- Grouping: Parentheses and LaTeX groupings (
\left(...\right)). - Indexing: Array and matrix indexing.
- Lists and sets: Parsing of lists (
[1,2,3]) and sets (\{1,2,3\}). - Identifiers and constants: Unicode and ASCII identifiers, mathematical constants (e.g.,
\pi,e,\infty). - Numbers: Integer and floating-point literals.
- Booleans and strings: Parsing of boolean (
true,false) and string literals. - Matrix environments: Parsing of LaTeX matrix environments (e.g.,
matrix,pmatrix, etc.).
Owner
- Name: André Storhaug
- Login: andstor
- Kind: user
- Location: Trondheim 🇳🇴
- Company: NTNU
- Website: https://andre.storhaug.no
- Repositories: 87
- Profile: https://github.com/andstor
🎓 CS PhD student @ Norwegian University of Science and Technology (NTNU)
GitHub Events
Total
- Release event: 1
- Push event: 4
- Create event: 1
Last Year
- Release event: 1
- Push event: 4
- Create event: 1
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| André Storhaug | a****g@g****m | 11 |
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 0
- Total pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 11 months
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.25
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 4
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- dependabot[bot] (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- npm 15 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
npmjs.org: @andstor/latex-math-parser
Parser for parsing LaTeX math expressions
- Homepage: https://github.com/andstor/latex-math-parser
- License: MIT
-
Latest release: 1.0.1
published 7 months ago
Rankings
Maintainers (1)
Dependencies
- 202 dependencies
- @types/chai ^4.2.21 development
- @types/mocha ^9.0.0 development
- @types/node ^16.4.12 development
- chai ^4.3.4 development
- mocha ^9.0.3 development
- npm-watch ^0.11.0 development
- pegjs-backtrace ^0.2.1 development
- source-map-support ^0.5.19 development
- ts-node ^10.1.0 development
- typescript ^4.3.5 development
- peggy ^1.2.0
- ts-pegjs ^1.1.1