Skip to content

parse: don't drop equations on font/mode switches, \smash, or AMS Hebrew - #5

Merged
tannevaled merged 2 commits into
mainfrom
math-robustness-noops
Aug 30, 2026
Merged

parse: don't drop equations on font/mode switches, \smash, or AMS Hebrew#5
tannevaled merged 2 commits into
mainfrom
math-robustness-noops

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

An unknown control sequence drops the whole equation group, so commands that only reach the math layer through macro expansion silently delete content. A 200-paper arXiv census (gotex -lenient -report-skipped) ranked the offenders.

Now transparent (no glyph, no argument)

\normalfont (127 dropped groups), \par (55), plus \rmfamily/\sffamily/\ttfamily/\bfseries/\mdseries/\itshape/\scshape/\upshape/\em, the size switches \small\Huge, and \relax/\protect/\leavevmode/\noindent/\ignorespaces. Handled exactly like \limits — they change nothing this layer models.

\smash / \smashoperator (32)

The height/depth trim isn't modelled, but the content must render. Skip an optional [t]/[b], keep the body.

AMS Hebrew \beth \gimel \daleth (\daleth: 26)

Only \aleph was present.

Deliberately NOT handled

\penalty, \hskip, \kern take unbraced dimension/number arguments the math layer has no scanner for. No-oping them without consuming the argument would leave 3pt as parasitic math text — worse than a clean drop. They stay dropped until a dimension scanner lands.

TestAddedSymbols extended; full suite green.

tannevaled and others added 2 commits August 30, 2026 14:39
An unknown control sequence drops the WHOLE equation group, so commands that
merely reach the math layer through macro expansion silently delete content.
A 200-paper arXiv census ranked the offenders:

  - Text-mode font/size/mode switches (\normalfont 127, \par 55, \bfseries,
    \small, \relax, \ignorespaces, …): no glyph, no argument. Treat as
    transparent, like \limits — they change nothing the layer models.
  - \smash / \smashoperator (32): the height/depth trim is not modelled, but the
    CONTENT must render. Skip an optional [t]/[b], keep the body.
  - AMS Hebrew \beth \gimel \daleth (\daleth 26): only \aleph was present.

Deliberately NOT handled here: \penalty, \hskip, \kern (unbraced dimension/
number arguments the math layer has no scanner for). No-oping them without
consuming the argument would leave "3pt" as parasitic math text — worse than a
clean drop. They stay dropped until a dimension scanner lands.

TestAddedSymbols gains the switches, \smash, and the Hebrew letters.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The macos/windows lanes run the 100% coverage gate; the new \smash case added
two error returns (broken optional [t|b] bracket, broken {body}) that the
success-only tests did not exercise. TestSmashErrors triggers both.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 84fe40b into main Aug 30, 2026
11 checks passed
@tannevaled
tannevaled deleted the math-robustness-noops branch August 30, 2026 13:05
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