Skip to content

Fix inline MathJax equations losing terms - #71

Merged
Divide-By-0 merged 2 commits into
masterfrom
codex/mathjax-single-svg
Sep 18, 2026
Merged

Divide-By-0 merged 2 commits into
masterfrom
codex/mathjax-single-svg

Conversation

@Divide-By-0

@Divide-By-0 Divide-By-0 commented Sep 17, 2026 •

Copy link
Copy Markdown
Owner

Docs Inline rendering could turn 1+1=2 into an image containing only 1. MathJax 4.1.2 returns sibling SVG fragments for ungrouped inline expressions, and our shared renderer selected only the first. This PR groups the full colored expression, preserves trailing comments, and rejects unexpected fragments before rasterization. The fix serves Docs and Slides; Sheets remains server-rendered.

Human intent

Rephrased from the user's request and material follow-ups:

  • Investigate support reports even when a reply draft already exists; reproduce and understand the Inline truncation bug before making a focused fix.
  • Include Auto/Inline equation screenshots and test every renderer × delimiter × Auto/Inline size combination so the result can be reviewed visually.
  • Preserve existing drafts and unrelated local changes; leave merge and deployment to the user.

Screenshots

Actual PNGs produced by the shared renderer in Chromium, shown in a local review gallery. These are not screenshots of the deployed Google Docs/Slides add-on. The images include source hashes and distinguish size Automatic from renderer Automatic.

Docs: Auto and Inline sizes

Docs Auto and Inline

Slides: Auto and Inline sizes

Slides Auto and Inline

External renderers: actual service responses

External renderer Auto and Inline

The optional live probe found Sciweavers HTTP 404 in both modes for both examples on September 17. Codecogs and Texrendr returned the complete equations shown. The probe reports this as failure; it neither substitutes MathJax nor marks Sciweavers working.

Test matrix

Layer Coverage Result
Docs/Slides production scanning and routing 5 renderers × 5 delimiter selections × 2 sizes × 2 apps = 100 combinations, two equations each Pass
Real Chromium MathJax → SVG → canvas → PNG All 40 Automatic/MathJax combinations; four examples; 256 PNG renders including mixed All delimiters Pass
Optional live external endpoints All 60 external-renderer combinations; two examples; 12 distinct requests after URL deduplication Codecogs/Texrendr images verified; 4 Sciweavers requests fail HTTP 404

The matrix reads renderer/delimiter options from the shipped sidebar selectors: Automatic, Codecogs, MathJax, Texrendr, Sciweavers; $$, \[...\], \(...\), $, and All; Automatic/Inline sizes. All contains all four delimiter forms in the same paragraph/text box.

Browser assertions check every required final glyph, one SVG, no TeX errors, visible PNG ink, compact Inline fractions/sums, and identical PNG hashes across delimiters and Automatic/MathJax preferences. PR CI runs both the Node suite and Chromium suite and uploads fresh screenshots plus per-case JSON evidence.

Reproduction and validation

  • Original reproduction: fresh base f1569bc, real MathJax 4.1.2 and production shared renderer. New regression tests originally passed 1/4; Node Inspector confirmed three SVG fragments and first-glyph-only selection. Display mode had one complete SVG.
  • Browser regression control with the unmodified pre-fix renderer fails on Docs / Automatic renderer / $$ / Inline: 3 SVG fragments instead of 1. The patched renderer passes.
  • Clean-checkout validation: npm ci --ignore-scripts, Slides sidebar build, 148/148 Node tests, and browser suite 40 settings / 256 PNG renders.
  • Commands and boundaries: tests/README.md. Use npm run test:matrix, npm run test:render-browser, or optional npm run test:render-services.

Limits

Apps Script document/slide objects and the final image-insertion boundary are doubled in the settings matrix. Server response fixtures keep deterministic CI independent of third-party availability; the separate live probe checks preferred endpoints, not all fallback routes. Browser tests use the real shared renderer and pixels, but do not prove Google insertion, authorization, deployed versions, or complete render/de-render behavior. The locked font component 4.1.3/core 4.1.2 warning remains documented. No merge, Apps Script push, deployment, or Marketplace release performed.

@Divide-By-0
Divide-By-0 merged commit e4910e0 into master Sep 18, 2026
3 checks passed
@Divide-By-0
Divide-By-0 deleted the codex/mathjax-single-svg branch September 18, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant