Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viktorstrate/algebra-latex
Parse and calculate latex formatted math
https://github.com/viktorstrate/algebra-latex
algebra asciimath cas latex math nodejs parse parser
Last synced: 3 months ago
JSON representation
Parse and calculate latex formatted math
- Host: GitHub
- URL: https://github.com/viktorstrate/algebra-latex
- Owner: viktorstrate
- License: mit
- Created: 2017-02-08T11:03:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T04:53:02.000Z (over 1 year ago)
- Last Synced: 2024-09-27T01:53:05.246Z (3 months ago)
- Topics: algebra, asciimath, cas, latex, math, nodejs, parse, parser
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/algebra-latex
- Size: 856 KB
- Stars: 28
- Watchers: 3
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# algebra-latex
[![Build Status](https://travis-ci.org/viktorstrate/algebra-latex.svg?branch=master)](https://travis-ci.org/viktorstrate/algebra-latex)
[![npm version](https://badge.fury.io/js/algebra-latex.svg)](https://www.npmjs.com/package/algebra-latex)An npm module, with no dependencies, for parsing LaTeX math to a regular math string ([ascii math](http://asciimath.org/)),
that can be parsed to other algebra or math libraries like [algebrite](http://algebrite.org/) and [algebra.js](http://algebra.js.org/)## Example
```javascript
const AlgebraLatex = require('algebra-latex')// Parse from LaTeX ...
const latexInput = '\\frac{1}{\\sqrt{2}}\\cdot x=10'
const algebraObj = new AlgebraLatex().parseLatex(latexInput)// ... or parse from regular math string
const mathInput = '1/sqrt(2)*x=10'
const algebraObj = new AlgebraLatex().parseMath(mathInput)console.log(algebraObj.toMath()) // output: 1/sqrt(2)*x=10
console.log(algebraObj.toLatex()) // output: \frac{1}{\sqrt{2}}\cdot x=10
```### Parse to other libraries
**Supported libraries**
- [algebra.js](http://algebra.js.org/)
- [algebrite](http://algebrite.org/)
- [coffeequate](http://coffeequate.readthedocs.io/)> NOTE: The above libraries are optional, and have to be installed before use
_continuing from example above_
```javascript
...var algebraJS = require('algebra.js')
var algebrite = require('algebrite')
var coffeequate = require('coffeequate')// For algebra.js
algebraObj.toAlgebra(algebraJS) // Will either return an algebra.js expression or equation// For algebrite
algebraObject.toAlgebrite(algebrite)// For coffequate
algebraObject.toCoffeequate(coffeequate)
```