engine: a collected environment body that finds no \end puts back what it read - #121
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #115.
The environments this engine collects in Go read their body up front, scanning for
\end{name}. That assumes the\endis IN the input. It need not be.beamer's rounded block opens
\begin{minipage}inside\beamerboxesroundedand produces the matching\endonly 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
\endnever 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: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.