Skip to content

Formulas as text: an accent on an accent adds one mark - #794

Open
Deicyde wants to merge 5 commits into
mainfrom
fix/tex-plain-nested-accents
Open

Deicyde wants to merge 5 commits into
mainfrom
fix/tex-plain-nested-accents

Conversation

@Deicyde

@Deicyde Deicyde commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Premise

  • User: a reader of a blueprint whose formulas nest accents, such as \hat{\hat{x}} or \bar{\hat{x}}, wherever a formula reads as plain text: a page's <title>, its sidebar entry, the map's labels and accessible names.
  • Problem: both readers, assets/tex-plain.js and its port ui/tex_plain.py, put an accent's combining mark after every character of its argument, the marks an inner accent left there included. So each level of nesting doubles the marks. \hat{\hat{x}} reads with three hats, \bar{\hat{x}} puts the bar on the hat as well as on the x, and twenty levels give 1,048,575 marks.
  • Replaces: the loop over characters. A character and the marks after it, Unicode's nonspacing marks (\p{Mn} in JavaScript, category Mn in Python), now take the accent once, after those marks.
  • Deletes: nothing.

What changes

  • autoform_cli/ui/assets/tex-plain.js: the accent branch puts the accent after each character and its marks.
  • autoform_cli/ui/tex_plain.py: _clusters groups the same way, so the port still reads each formula as the reducer does.
  • autoform_cli/ui/assets/blueprint-explorer.min.js: rebuilt with npm run build:explorer (esbuild 0.28.2, Terser 5.51.2), since it bundles tex-plain.js. The same compiler rebuilds main's bundle byte for byte.
  • tests/fixtures/tex-plain-cases.json: two cases, which both readers must read as the table says. They cover \hat{\hat{x}}, \bar{\hat{x}}, \vec{\dot{ab}}, an accent over \not\alpha, and an accent whose argument starts with a mark.
  • tests/ui/test_tex_plain.py: twenty nested hats read as twenty marks, in both readers.
  • CHANGELOG.md: a Fixed line.

Checks

Posted by Claude Code, at Jack's request.

An accent appended its combining mark after every character of its argument,
the marks an inner accent had put there included, so each level of nesting
doubled the marks: \hat{\hat{x}} read with three hats, \bar{\hat{x}} put a bar
on the hat, and twenty levels gave a million marks. Both readers now take a
character with the marks after it (Unicode's Mn) as one, and accent it once.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@Deicyde
Deicyde marked this pull request as ready for review November 13, 2026 03:01
@Deicyde

Deicyde commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Review at 2e0a965: no blockers, one nit. Both readers now give a character and the nonspacing marks after it a single accent, so nested accents stack instead of doubling: \hat{\hat{x}} reads with two hats and twenty levels with twenty, where main's tex-plain.js gave 1,048,575 marks. I ran tex-plain.js in Node 22 and the port on 30 accent formulas, including a leading mark, an astral letter, a variation selector, a joiner, and enclosing (Me) and spacing (Mc) marks, which neither reader groups. They agree on all 30 under Python 3.14. The bundle diff is only the banner's source hash and the accent branch, each banner matches its sources' hash, and CI's check:explorer rebuilds the bundle byte for byte. The nit: the readers now ask their own runtime's Unicode tables, so they can disagree on a mark newer than Python's. On Python 3.13 (Unicode 15.1) the port doesn't group U+10D69, a Unicode 16 mark, while tex-plain.js in Node 22 (Unicode 17) does, so x followed by that mark takes one hat in the reducer and two in the port. Before this change both treated every character alike. It's rare enough to leave, perhaps with a word in _clusters' docstring. The six mutants each fail a test:
https://github.com/facebookresearch/autoform-bot/actions/runs/43347138027

Posted by Claude Code, at Jack's request.

Deicyde and others added 3 commits November 12, 2026 21:27
CHANGELOG.md was the only conflict: the Fixed entry follows #780's at the end
of Unreleased's Fixed section.
…accents

# Conflicts:
#	CHANGELOG.md
#	autoform_cli/ui/assets/blueprint-explorer.min.js
@Deicyde Deicyde mentioned this pull request Nov 14, 2026
2 tasks done
@Deicyde

Deicyde commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Blockers-only check of the rebuild at 1035509 (main ff33adc merged in): no blockers.

Posted by Claude Code, at Jack's request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant