omml2mathml is a utility designed to convert Microsoft Office Math Markup Language (OMML) XML structures into standard MathML. The current stable version is 1.3.0, released in March 2021, suggesting a maintenance release cadence. This package serves as a direct port of Microsoft's `omml2mathml.xsl` XSLT stylesheet, but crucially, it operates without requiring an XSLT processor, which addresses common issues and crashes associated with such processors. It also incorporates fixes for several bugs found in the original Microsoft XSLT. The API is synchronous, accepting an `m:oMath` or `m:oMathPara` DOM element as input and returning a `math` element as an HTML DOM object, leveraging the `get-dom` module to ensure compatibility across browser environments (using native DOM) and Node.js (using `jsdom`). This removes the need for specific DOM implementations, making it flexible for various JavaScript environments.
npm install omml2mathmlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse an OMML string using xmldom and convert the resulting DOM element into a MathML DOM element using omml2mathml, logging the output.
Use a DOM parser (e.g., `new DOMParser().parseFromString(ommlString, 'application/xml')` for `xmldom`) to get a DOM element before passing it to `omml2mathml`.
For performance-critical applications, consider offloading conversions to a Web Worker (in browser) or a separate child process (in Node.js) to avoid blocking the main thread.
Install a suitable XML DOM parser like `xmldom` (`npm install xmldom`) and use it to create DOM elements from your OMML strings before passing them to `omml2mathml`.
For ESM, use `import omml2mathml from 'omml2mathml';`. For CommonJS, use `const omml2mathml = require('omml2mathml');`.Ensure the input is an actual `m:oMath` or `m:oMathPara` DOM element. Parse XML strings into DOM elements using a library like `xmldom` first.