Skip to content

Fix duplicate labels in live formula previews - #20

Merged
yuema137 merged 2 commits into
mainfrom
fix/math-preview-labels
Sep 12, 2026
Merged

yuema137 merged 2 commits into
mainfrom
fix/math-preview-labels

Conversation

@yuema137

@yuema137 yuema137 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Opening a formula containing \label{eq:demo} could show “Label 'eq:demo' multiply defined” because the paper and live preview registered the same equation in shared MathJax state. Draft previews and edited-formula rendering now use a fresh TeX input instance and separate MathDocument, copy existing document references, and suppress label registration only in that draft instance. Editor text and saved feedback retain the complete source, including labels.

Async preview results only update the current draft. Saving multiple formula edits also uses each formula's own original source for its feedback anchor, rather than the last-opened editor's baseline.

Validation:

  • The new real-CDN browser regression reproduces the duplicate-label failure on 0.1.1 and passes with this fix.
  • It checks labelled/unlabelled equations, reopening, repeated and rapid input, multiple labels, visible preview content and error nodes, unchanged document label/ID/reference state, saved labels, and per-formula source anchors. Canonical source remains unchanged.
  • The label suite additionally covers inline fractions/roots, aligned and equation environments, label whitespace/Unicode, local and configured macros, and recovery after a rejected conversion.
  • All three Playwright suites pass in Chromium, including existing offline/delayed loading and edit/comment/refresh regressions.
  • All 16 Python tests, JavaScript syntax checks, and git diff whitespace checks pass.

The isolated conversion uses MathJax 3's exposed startup constructors and conversion machinery; the browser regression should be rerun when upgrading MathJax. Browser suites use a separately installed Playwright and are documented in docs/renderer-adapters.md; the existing GitHub CI covers the Python matrix.

Fixes #19

@yuema137
yuema137 merged commit cf3b0a9 into main Sep 12, 2026
4 checks passed
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.

Live math preview reports duplicate labels for valid labelled equations

1 participant