-
Notifications
You must be signed in to change notification settings - Fork 102
Math Equation Rendering (OMML → MathML) #2681
Copy link
Copy link
Open
Description
SuperDoc converts Office Math (OMML) from Word documents into browser-native MathML. No KaTeX. No MathJax. No external dependencies. The browser renders the math directly.
How it works
.docx → OMML XML → ProseMirror → Layout Engine → DomPainter → <math> DOM
The importer extracts m:oMath elements and stores the full OMML tree as a JSON attribute on atomic ProseMirror nodes. At render time, the DomPainter walks the tree and converts each OMML element to its MathML equivalent via a converter registry. The browser does the rest.
Export round-trips cleanly — the original XML is preserved via carbonCopy.
What's built
- Import pipeline —
m:oMath(inline) andm:oMathPara(display) both import as proper PM nodes - ProseMirror schema —
mathInlineandmathBlockatomic nodes - Layout engine —
MathRuntype, measured as atomic units like images - DomPainter rendering — converter registry,
renderMathRun(), cursor positioning - Leaf nodes —
m:r/m:ttext classification (<mi>,<mo>,<mn>) - Fraction —
m:f→<mfrac>, working proof of concept - 47 unit tests across the pipeline
What's left: 14 converters
Each converter is one function. ~20 lines of TypeScript. One file, two one-line registrations, a test. No schema changes. No adapter changes. No exporter changes.
Contribution guide: CONTRIBUTING.md
Done
- Math: implement m:sSup superscript converter (community) #2595 —
m:sSupsuperscript →<msup> - Math: implement m:sSub subscript converter (community) #2596 —
m:sSubsubscript →<msub> - Math: implement m:bar overbar/underbar converter (community) #2610 —
m:baroverbar/underbar →<mover>/<munder>
Easy
- Math: implement m:sSubSup sub-superscript converter (community) #2597 —
m:sSubSupsub+superscript →<msubsup> - Math: implement m:rad radical/sqrt converter (community) #2598 —
m:radradical/sqrt →<msqrt>/<mroot> - Math: implement m:limLow lower limit converter (community) #2599 —
m:limLowlower limit →<munder> - Math: implement m:limUpp upper limit converter (community) #2600 —
m:limUppupper limit →<mover> - Math: implement m:box and m:borderBox converters (community) #2605 —
m:box+m:borderBox→<mrow>/<menclose> - Math: implement m:phant phantom converter (community) #2608 —
m:phantphantom →<mphantom>
Medium
- Math: implement m:d delimiter converter (community) #2611 —
m:ddelimiter →<mrow>+<mo> - Math: implement m:nary n-ary operator converter (community) #2602 —
m:naryn-ary (∫, ∑, ∏) →<munderover> - Math: implement m:acc accent converter (community) #2604 —
m:accaccent →<mover accent="true"> - Math: implement m:groupChr group character converter (community) #2606 —
m:groupChrgroup character →<munder>/<mover> - Math: implement m:func function apply converter (community) #2603 —
m:funcfunction apply →<mrow> - Math: implement m:sPre pre-sub-superscript converter (community) #2609 —
m:sPrepre-sub-superscript →<mmultiscripts>
Hard
- Math: implement m:m matrix converter (community) #2601 —
m:mmatrix →<mtable> - Math: implement m:eqArr equation array converter (community) #2607 —
m:eqArrequation array →<mtable>
How to pick one up
- Grab an issue from the list above
- Read the contribution guide
- Follow the pattern in
converters/fraction.ts - Each issue has a
.docxtest file attached — upload it to the dev app to verify your converter works - Open a PR
Related
- feat(math): add OMML rendering infrastructure and community contribution scaffolding (SD-2369) #2585 — infrastructure PR (merged)
- ECMA-376 §22.1 — Office Math spec
Reactions are currently unavailable