Skip to content

d2latex: replace MathJax JavaScript with mathjax-go - #2824

Merged
alixander merged 2 commits into
masterfrom
agent/use-mathjax-go
Aug 9, 2026
Merged

d2latex: replace MathJax JavaScript with mathjax-go#2824
alixander merged 2 commits into
masterfrom
agent/use-mathjax-go

Conversation

@alixander

@alixander alixander commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace the embedded MathJax 3.2.2 JavaScript component with mathjax-go v0.1.0
  • preserve D2 LaTeX SVG and measurement output exactly, including native and WASM rendering
  • delete the MathJax, polyfill, and setup assets plus both embed shims
  • delete lib/jsrunner and remove Goja and its orphaned indirect dependencies
  • add frozen integration hashes and complete third-party notices

Compatibility

The native port targets the exact custom MathJax 3.2.2 component previously embedded by D2. The unchanged D2 E2E golden suite passes byte-for-byte; no golden was refreshed. This includes AMS, Mathtools, AMS-CD, braket, chemistry, physics, colors, errors, scripts, tables, and the historical backslash boundary.

The dependency is pinned to the signed mathjax-go v0.1.0 tag, with no local replace or pseudo-version.

Validation

  • GOWORK=off go mod tidy -diff
  • GOWORK=off go mod verify
  • GOWORK=off go test ./d2renderers/d2latex ./d2renderers/d2svg/...
  • GOWORK=off go test -race ./d2renderers/d2latex ./d2renderers/d2svg/...
  • GOWORK=off go test ./e2etests -run ^TestE2E$
  • GOWORK=off go test across every package except the browser-dependent e2etests-cli package
  • GOWORK=off go vet ./...
  • GOOS=js GOARCH=wasm GOWORK=off go build ./d2js

The two GIF cases in e2etests-cli cannot produce browser frames in this local environment and fail identically on untouched D2; all non-browser packages pass.

Size impact

Measured against the parent D2 revision with identical build flags:

  • native binary: 47.10 MB to 41.39 MB, down 12.13%
  • WASM: 30.87 MB to 35.06 MB, up 13.57% raw and 8.13% gzip

Standalone port

Merged: d2lang/mathjax-go#1

@alixander
alixander marked this pull request as ready for review August 9, 2026 15:24
@alixander
alixander merged commit 443ffe7 into master Aug 9, 2026
8 of 9 checks passed
@alixander
alixander deleted the agent/use-mathjax-go branch August 9, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant