semantics

This page uses <script type="module"> with relative import paths. Browsers usually block those imports from the file:// URL, so the polyfill will not run if you open this file directly from disk. Serve the repository root over HTTP and open this page from there, for example: python -m http.server 8080 then visit http://localhost:8080/semantics/index.html.

Tests for semantics.js: the first element child of semantics should be the presentation fragment (MathML 4). If presentation lives only in annotation-xml with encoding=MathML-Presentation or encoding=application/mathml-presentation+xml, it is hoisted to the front; if a non-presentation child appears first, the first direct presentation sibling is moved before it. After _MathTransforms.transform, use devtools to confirm child order under semantics.

If correct, all examples should display as a + 1 .

semantics — presentation first
Description Math (after transform)
Presentation already first (no structural change) a + 1 a plus one
annotation before presentation; polyfill moves mrow first a plus one a + 1
Presentation only inside annotation-xml (MathML-Presentation) a+1 a + 1
Presentation only inside annotation-xml (application/mathml-presentation+xml) x squared a + 1