Currently it is not maintained. See also the project https://github.com/insysbio/mathjs-mathml which provides the similar functionality but does not use DOM.
Extends mathjs http://mathjs.org/ library by function translating the internal object to content MathML https://www.w3.org/Math/
Addon can be used in both NodeJS and in the browser.
npm install mathjs-cmathml
NodeJS version uses external DOM from library xmldom
.
const math = require('mathjs');
math.import(require('mathjs-cmathml'));
let doc = math
.parse('x*sin(y/z)')
.toCMathML();
let mathml = doc.toString(); // stringify MathML
console.log(mathml);
Browser version can be downloaded from https://github.com/insysbio/mathsjs-cmathml/tree/master/dist
Browser version uses internal default DOM.
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/4.2.2/math.min.js"></script>
<script src="./mathjs.toCMathML.min.js"></script>
math.import(cmathml);
let doc = math
.parse('x*sin(y/z)')
.toCMathML();
let mathml = new XMLSerializer().serializeToString(doc); // stringify MathML
console.log(mathml);
The another entry point is used for webpack building. Webpack version uses browser DOM.
const math = require('mathjs');
math.import(require('mathsjs-cmathml/webpack'));
let doc = math
.parse('x*sin(y/z)')
.toCMathML();
let mathml = new XMLSerializer().serializeToString(doc); // stringify MathML
console.log(mathml);
- Viktoria Tkachenko @vetedde
- Evgeny Metelkin @metelkin
InSysBio, Moscow, 2017-2018 http://insysbio.com