DEPRECATION NOTICE: This repository is no longer maintained. Please visit Plurimath-JS for the latest updates and features.
-
Download Latexmath.js (or a minified version) directly.
-
Or in the terminal, you can clone the repository:
$ git clone https://github.com/plurimath/latexmath-js.git $ cd latexmath.js/dist/
-
Add a <script> tag in your HTML:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="path/to/latexmath.js"></script> </head> <body> </body> <script> // here you can use latexmath.js </script> </html>
-
Convert a LaTeX math formula to MathML
<script> var latex = "$$f_i = \sum_{j=1}^2 s_{ij} n_j \quad {\rm for} \quad i = 1,2$$"; var mathml = Opal.Latexmath.$parse(latex).$to_mathml(); </script>
Note
|
Latexmath is not bundled as a well-behaved module yet; requiring it defines a global Opal identifier.
|
Install:
yarn add latexmath
Use:
require('latexmath');
const latex = "$$f_i = \sum_{j=1}^2 s_{ij} n_j \quad {\rm for} \quad i = 1,2$$";
const mathml = Opal.Latexmath.$parse(latex).$to_mathml();
console.log(mathml);
Latexmath.js is generated through Opal on the latexmath
gem in Ruby.