Skip to content

engine: a collected environment body that finds no \end puts back what it read - #121

Merged
tannevaled merged 1 commit into
mainfrom
minipage-restore
Aug 30, 2026
Merged

engine: a collected environment body that finds no \end puts back what it read#121
tannevaled merged 1 commit into
mainfrom
minipage-restore

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Fixes #115.

The environments this engine collects in Go read their body up front, scanning for \end{name}. That assumes the \end is IN the input. It need not be.

beamer's rounded block opens \begin{minipage} inside \beamerboxesrounded and produces the matching \end only later, from \endbeamerboxesrounded — several tokens into a macro the scanner cannot see through. So the scan drained what was pending, carried on into the document TEXT, and swallowed the rest of it. With \useinnertheme{rounded} — the inner theme of Warsaw, Madrid, Copenhagen and Frankfurt — a talk with one block rendered zero pages.

When the \end never comes, the scan now restores the input it read, so the material flows as ordinary text: a locally wrong box instead of a lost document.

Only when the scan stayed on one input level. A mark records where the mouth stood in the buffer it was reading, and a file opened or finished mid-scan makes that position meaningless. Restoring across one was measured and cost two arXiv papers — one of them everything it had, 21 713 glyphs → 0. With the guard both render as before.

Measured

200 talks and 200 arXiv papers, against main:

pages glyph paths up down
beamer 1121 → 1197 (+76) 188 933 → 202 558 (+13 625) 12 0
arXiv 4184 → 4253 (+69) 9 493 784 → 9 561 555 (+67 771) 5 0

Not one talk draws fewer glyphs. Talks that rendered a single page now render what they have: 1 → 15, 2 → 9, 1 → 4.

Against the 16 talks with a tectonic PDF beside them — ground truth — the absolute page error falls from 14 to 10, and no talk moves away from the reference.

Tests

Two: an unterminated minipage inside a box that is never placed no longer drags the text after it into that box (fails on main), and a terminated minipage still boxes its body at the width it was given.

…t it read

The environments this engine collects in Go read their body up front, scanning for
\end{name}. That assumes the \end is IN the input. It need not be.

beamer's rounded block opens \begin{minipage} inside \beamerboxesrounded and
produces the matching \end only later, from \endbeamerboxesrounded — several
tokens into a macro the scanner cannot see through. So the scan drained what was
pending, carried on into the document TEXT, and swallowed the rest of it: with
\useinnertheme{rounded} — the inner theme of Warsaw, Madrid, Copenhagen and
Frankfurt — a talk with one block rendered ZERO pages (issue #115).

When the \end never comes, the scan now restores the input it read, so the
material flows as ordinary text: a locally wrong box instead of a lost document.

Only when the scan stayed on ONE input level. A mark records where the mouth
stood in the buffer it was reading, and a file opened or finished mid-scan makes
that position meaningless; restoring across one was measured and cost two arXiv
papers, one of them everything it had (21 713 glyphs → 0). With the guard both
render as before.

Measured, 200 talks and 200 arXiv papers, against main:

	beamer   1121 → 1197 pages (+76)   188 933 → 202 558 glyphs (+13 625)
	         12 talks up, NONE down, and not one draws fewer glyphs
	arXiv    4184 → 4253 pages (+69)   9 493 784 → 9 561 555 (+67 771)
	         5 papers up, NONE down

Talks that rendered a single page now render what they have: 1 → 15, 2 → 9,
1 → 4. Against the 16 talks with a tectonic PDF beside them, the absolute page
error falls from 14 to 10 and no talk moves away from the reference.

Fixes #115.
@tannevaled
tannevaled merged commit 28376b6 into main Aug 30, 2026
18 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.

beamer: a rounded block swallows the document (\useinnertheme{rounded} — Warsaw, Madrid, Copenhagen, Frankfurt)

1 participant