{"id":20000286,"url":"https://github.com/andstor/latex-math-parser","last_synced_at":"2025-07-31T14:11:22.986Z","repository":{"id":42584481,"uuid":"393060229","full_name":"andstor/latex-math-parser","owner":"andstor","description":":wrench: Parser for parsing LaTeX math expressions","archived":false,"fork":false,"pushed_at":"2023-03-06T13:21:47.000Z","size":111,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-01T23:41:36.131Z","etag":null,"topics":["latex","parser","peg-parser"],"latest_commit_sha":null,"homepage":"","language":"PEG.js","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andstor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-05T13:52:12.000Z","updated_at":"2022-03-27T15:42:02.000Z","dependencies_parsed_at":"2025-01-12T12:53:54.642Z","dependency_job_id":"25489a98-c0ac-4e6b-9f83-610065590a46","html_url":"https://github.com/andstor/latex-math-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andstor/latex-math-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andstor%2Flatex-math-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andstor%2Flatex-math-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andstor%2Flatex-math-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andstor%2Flatex-math-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andstor","download_url":"https://codeload.github.com/andstor/latex-math-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andstor%2Flatex-math-parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263250594,"owners_count":23437288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["latex","parser","peg-parser"],"created_at":"2024-11-13T05:14:21.072Z","updated_at":"2025-07-31T14:11:22.980Z","avatar_url":"https://github.com/andstor.png","language":"PEG.js","funding_links":[],"categories":[],"sub_categories":[],"readme":"# latex-math-parser\n\n\u003e A parser for LaTeX math expressions.\n\nThis 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.\n\n## Installation\n\n```bash\nnpm install @andstor/latex-math-parser\n```\n\n## Usage\n\n```js\nconst { parse } = require('@andstor/latex-math-parser');\n\nconst latex = '\\\\frac{a}{b} + \\\\sqrt{x}';\nconst ast = parse(latex);\n\nconsole.log(JSON.stringify(ast, null, 2));\n```\n\n## Generators\n\nThis parser can be used with various code generators to convert the AST into different programming languages or formats. Currently supported generators include:\n- **[maxima-codegen](https://github.com/andstor/maxima-codegen)**: Maxima is a computer algebra system that can manipulate symbolic expressions.\n\n## Features\nThe complete grammar for this parser can be found at [src/grammars/latex.pegjs](src/grammars/latex.pegjs). Following are some of the key features supported by the parser:\n\n- **Arithmetic operations**: Addition, subtraction, multiplication, division, modulo, exponentiation, and implied multiplication.\n- **Logical and bitwise operations**: Logical AND/OR, bitwise AND/OR/XOR, relational and equality operators.\n- **Assignment expressions**: Standard and compound assignments (e.g., `=`, `+=`, `*=`, etc.).\n- **Function calls**: Built-in and user-defined functions, including support for argument lists and nested calls.\n- **Fractions**: Parsing of LaTeX `\\frac` expressions.\n- **Limits**: Parsing of limit expressions (e.g., `\\lim`).\n- **Logarithms**: Parsing of logarithms with arbitrary bases, including `\\log`, `\\ln`, and `\\lg`.\n- **Binomial coefficients**: Parsing of `\\binom`.\n- **Summations**: Parsing of `\\sum` with lower and upper bounds.\n- **Integrals**: Parsing of definite and indefinite integrals (`\\int`).\n- **Differentials**: Parsing of differential expressions.\n- **Trigonometric functions**: Parsing of all standard and inverse trigonometric functions.\n- **Roots**: Parsing of square roots and nth roots (`\\sqrt`).\n- **Absolute value**: Parsing of absolute value expressions.\n- **Grouping**: Parentheses and LaTeX groupings (`\\left(...\\right)`).\n- **Indexing**: Array and matrix indexing.\n- **Lists and sets**: Parsing of lists (`[1,2,3]`) and sets (`\\{1,2,3\\}`).\n- **Identifiers and constants**: Unicode and ASCII identifiers, mathematical constants (e.g., `\\pi`, `e`, `\\infty`).\n- **Numbers**: Integer and floating-point literals.\n- **Booleans and strings**: Parsing of boolean (`true`, `false`) and string literals.\n- **Matrix environments**: Parsing of LaTeX matrix environments (e.g., `matrix`, `pmatrix`, etc.).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandstor%2Flatex-math-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandstor%2Flatex-math-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandstor%2Flatex-math-parser/lists"}