{"library":"omml2mathml","title":"OMML to MathML Converter","description":"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.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install omml2mathml"],"cli":null},"imports":["import omml2mathml from 'omml2mathml';","const omml2mathml = require('omml2mathml');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { DOMParser } from 'xmldom';\nimport omml2mathml from 'omml2mathml';\n\nconst parser = new DOMParser();\n\n// Example OMML input (a simple equation)\n// This OMML represents 'x_a'. Real OMML can be significantly more complex.\nconst ommlString = `\n<m:oMath xmlns:m=\"http://schemas.microsoft.com/office/2006/math\">\n  <m:r>\n    <m:t>x</m:t>\n  </m:r>\n  <m:sSub>\n    <m:e>\n      <m:r>\n        <m:t>a</m:t>\n      </m:r>\n    </m:e>\n    <m:sub>\n      <m:r>\n        <m:t>i</m:t>\n      </m:r>\n    </m:sub>\n  </m:sSub>\n</m:oMath>\n`;\n\nconst oMathDocument = parser.parseFromString(ommlString, 'application/xml');\nconst oMathElement = oMathDocument.documentElement; // This should be the <m:oMath> element\n\nif (oMathElement && (oMathElement.nodeName === 'm:oMath' || oMathElement.nodeName === 'm:oMathPara')) {\n  const mathmlElement = omml2mathml(oMathElement);\n  console.log('Converted MathML:');\n  // In a browser, you would append mathmlElement to the DOM\n  // In Node.js, you might serialize it for output or further processing\n  console.log(mathmlElement.outerHTML || new (require('xmldom').XMLSerializer)().serializeToString(mathmlElement));\n} else {\n  console.error(\"Could not find a valid m:oMath or m:oMathPara element in the input.\");\n}","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}