https://github.com/andstor/latex-math-parser

:wrench: Parser for parsing LaTeX math expressions

https://github.com/andstor/latex-math-parser

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

latex parser peg-parser
Last synced: 5 months ago · JSON representation

Repository

:wrench: Parser for parsing LaTeX math expressions

Basic Info
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 3
  • Releases: 2
Topics
latex parser peg-parser
Created over 4 years ago · Last pushed 7 months ago
Metadata Files
Readme License

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 \frac expressions.
  • 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 \sum with 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

🎓 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

All Time
  • Total Commits: 11
  • Total Committers: 1
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 8
  • Committers: 1
  • Avg Commits per committer: 8.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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
dependencies (4)

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

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 15 Last month
Rankings
Dependent repos count: 24.2%
Average: 29.6%
Dependent packages count: 34.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

package-lock.json npm
  • 202 dependencies
package.json npm
  • @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