Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asnunes/mathml-to-latex
A JavaScript tool to convert mathml string to LaTeX equation string.
https://github.com/asnunes/mathml-to-latex
Last synced: 4 days ago
JSON representation
A JavaScript tool to convert mathml string to LaTeX equation string.
- Host: GitHub
- URL: https://github.com/asnunes/mathml-to-latex
- Owner: asnunes
- License: mit
- Created: 2020-08-30T19:52:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-09T11:57:22.000Z (about 2 months ago)
- Last Synced: 2024-12-26T19:04:01.765Z (12 days ago)
- Language: TypeScript
- Size: 526 KB
- Stars: 55
- Watchers: 3
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# mathml-to-latex
It converts [MathML](https://en.wikipedia.org/wiki/MathML) to [LaTeX](https://pt.wikipedia.org/wiki/LaTeX).
## Installation
If you use NPM
```
npm install mathml-to-latex --save
```If you use Yarn
```
yarn add mathml-to-latex
```## Usage
```javascript
import { MathMLToLaTeX } from 'mathml-to-latex';
// const { MathMLToLaTeX } = require('mathml-to-latex');const mathml = `
a
+
b
`;MathMLToLaTeX.convert(mathml);
// => a + b
``````javascript
import { MathMLToLaTeX } from 'mathml-to-latex';
// const { MathMLToLaTeX } = require('mathml-to-latex');const mathml = `
A
=
x
y
z
w
`;MathMLToLaTeX.convert(mathml);
// => A = \begin{bmatrix} x & y \\ z & w \end{bmatrix}
```## Browser
Package is also available directly in the browser through CDN:
```html
MathML to LaTeX Converter
MathML to LaTeX Converter
Convert to LaTeX
const mathmlInput = document.getElementById('mathmlInput');
const latexOutput = document.getElementById('latexOutput');
const convertButton = document.getElementById('convertButton');mathmlInput.value = `\
<math>
<mrow>
<mn>2</mn>
<mo>+</mo>
<mn>2</mn>
<mo>=</mo>
<mn>4</mn>
</mrow>
</math>`;convertButton.addEventListener('click', function () {
const latex = MathMLToLaTeX.MathMLToLaTeX.convert(mathmlInput.value);
latexOutput.textContent = latex;
});
```
Output:
![Browser DEMO](./docs/browser-demo.gif)