Source provenance

August 9, 2026 ยท View on GitHub

mathjax-go is a source-shaped Go translation of the TeX-to-SVG subset in MathJax 3.2.2 that D2 executes.

SourceVersion / commitLicenseRelevant surface
MathJax source3.2.2 / ad8f5c21cb810236551da8c6512ba733e67357eeApache-2.0ts/core, ts/input/tex, ts/output/common, ts/output/svg, and TeX SVG fonts
MathJax components3.2.2 / 600692ad9d3552cc25f85510d5797bc942ecc9f7Apache-2.0component build used to identify the frozen module surface
mhchemParser4.1.1 npm package, SHA-1 a2142fdab37a02ec8d1b48a445059287790becd5Apache-2.0src/mhchemParser.ts for \ce and \pu
Luo-Studio/go-texcommit 60635a3613c51e710fd5cb57e1d7eeb7b3163a1fMITinitial Go translation structure for internal/mhchem; behavior was then corrected against mhchemParser 4.1.1
D2 custom-component assetsD2 commit 541941e895fcdc69ad3109770296dcac670c5be7mathjax.js: Apache-2.0; polyfills.js: MIT; D2-authored setup.js: MPL-2.0asset-origin commit used to extract the semantic manifests and exact package/configuration surface
D2 formula/integration snapshotD2 commit 5666d9337c77a4803b9cd60cb1c5a24439d0f949MPL-2.0D2 formula corpus and CI fetch commit; the three oracle assets are byte-identical to the asset-origin commit above and retain their per-file licenses listed in the preceding row

Frozen D2 oracle

The optional differential runner accepts only these files:

FileSHA-256
mathjax.jscbbc1051a1f8abb1a181b6aa0fe927c020e3631ca630d19f52d9abb65b5ee869
polyfills.js7fe1d048c78b0e09854c1259f7413868a51cc8f0c822489eb1ac36ae6c85ce01
setup.jsa52cb0bbabfbd7796b9fedd793b9386c474e3123e788ee151cbe47ca1fa6e881

The semantic manifests were extracted from the three assets at D2 commit 541941e895fcdc69ad3109770296dcac670c5be7. The formula corpus and CI fetch the same byte-for-byte assets at D2 commit 5666d9337c77a4803b9cd60cb1c5a24439d0f949; the hashes above are the authoritative identity check for either commit.

The bundle reports MathJax version 3.2.2. Its configured TeX packages are base, mathtools, ams, amscd, braket, cancel, cases, color, gensymb, mhchem, and physics. Its SVG output uses fontCache: 'none'. The call boundary is html.convert(tex, {em: 16, ex: 8}), whose default is display mode, followed by serialization of the container's inner HTML.

polyfills.js is used only by the external oracle. It contains code from XMLDOM and Wicked Good XPath under their respective MIT licenses; none of that code is translated into, embedded in, or distributed as part of the production Go library.

Go source mapping

Go pathUpstream source or role
internal/mml/attributes.gots/core/MmlTree/Attributes.ts, translated and modified
internal/mml/node.gots/core/Tree/Node.ts and ts/core/MmlTree/MmlNode.ts, translated and modified into a compositional Go tree
internal/mml/factory.gots/core/MmlTree/MmlFactory.ts, translated and modified
internal/tex/compiler.go, parser.go, nodes.go, inheritance.go, mml_definitions.gots/input/tex/TexParser.ts, Stack.ts, StackItem.ts, NodeFactory.ts, Configuration.ts, and ts/core/MmlTree/MmlNodes/*.ts
internal/tex/commands.go, environments.go, newcommand.go, symbols.go, operator_dictionary_generated.gots/input/tex/base/*.ts, ts/input/tex/newcommand/*.ts, ts/core/MmlTree/OperatorDictionary.ts, and command/environment methods from the selected AMS, AMS-CD, braket, cancel, cases, color, empheq, enclose, gensymb, mathtools, mhchem, and physics packages; each aggregate file header lists its exact source paths
internal/tex/*_handlers.go, internal/tex/extensions/**, internal/tex/source_tables_*.goselected MathJax 3.2.2 TeX package configurations, mappings, and methods for AMS, AMS-CD, braket, cancel, cases, color, empheq, enclose, gensymb, mathtools, mhchem, newcommand, and physics
internal/mhchem/**mhchemparser@4.1.1/src/mhchemParser.ts, translated and modified; the initial Go structure identified above is retained under the accompanying MIT notice
internal/layout/**ts/output/common/BBox.ts, Wrapper.ts, OutputJax.ts, FontData.ts, and ts/util/lengths.ts
internal/svg/**ts/output/common/Wrappers/*.ts, ts/output/svg/Wrappers/*.ts, ts/output/svg/Notation.ts, and the SVG DOM/serializer behavior of ts/output/svg.ts
internal/font/generate.py, internal/font/data_*_gen.go, font.go, delimiter.go, smp.gomechanically generated and translated from ts/output/common/fonts/tex/** and ts/output/svg/fonts/tex/**; exact MathJax numeric literals, delimiter records, and SVG glyph paths are preserved
internal/jscompat/number.goECMAScript Number behavior used by ts/output/common/OutputJax.ts and ts/util/lengths.ts
internal/ordered/map.godeterministic replacement for observable JavaScript object/DOM insertion ordering
internal/pipeline, root APIGo-specific adapter seam replacing MathJax's document/handler startup layer
internal/oracle, differential_test.go, internal/tex/testdata/d2_rich_mml_mathjax_3_2_2.jsonGo-specific, test-only compatibility harnesses and the rich semantic manifest extracted from the pinned D2 component assets
internal/tex/testdata/handler_oracle_mathjax_3_2_2.jsontest-only MathML manifest extracted from pinned MathJax 3.2.2 with the explicitly recorded augmented package set
internal/tex/testdata/operator_dictionary_mathjax_3_2_2.jsontest-only source manifest extracted from ts/core/MmlTree/OperatorDictionary.ts at the pinned MathJax source commit
internal/tex/testdata/source_tables_mathjax_3_2_2.jsontest-only source manifest extracted from pinned MathJax package mappings/configurations and constrained by D2's configured package closure
testdata/differential/oracle.mjsGo-specific test driver for the unmodified, externally supplied D2 assets

Translated files retain upstream copyright attribution, identify the Apache License 2.0 with an SPDX header, and state that they are Go translations and modifications. Generated font files retain MathJax's applicable copyright and Apache 2.0 license notice. No JavaScript oracle asset is embedded in or needed by the production library.