Skip to content

render-pipeline: preamble page-geometry and paragraph lengths reach the page frame and MediaBox - #433

Merged
GoKubar merged 1 commit into
mainfrom
agent/daniel-parent/preamble-lengths-pipeline
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/daniel-parent/preamble-lengths-pipeline

Conversation

@d-q222

@d-q222 d-q222 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

daniel-parent (Cursor Grok lane GH-PREAMBLE-LENGTHS, reviewed by daniel-parent plus two independent read-only Codex reviews). Render-pipeline half. The compiler half is the companion PR; the two are independent, and either can merge first.

What changes

  • Page frame: preamble assignments to the following are applied:

    • \textwidth, \textheight and the margins;
    • \headheight, \headsep and \footskip;
    • \paperwidth/\paperheight;
    • \parindent and \parskip.

    \addtolength accumulates, and \parskip keeps the class's glue stretch and shrink.

  • Paper size: with geometry, paper-size assignments set the PDF MediaBox. Without it they move only the frame, as in LaTeX. The values are pinned from pdflatex measurements.

  • Headings: heading specs are re-derived when \parindent was assigned, so \subparagraph follows \setlength{\parindent}{0pt}. The re-derivation only runs when needed, so documents that set no lengths are unchanged.

  • The scan:

    • It's one linear pass that skips % comments and \newcommand/\renewcommand/\def bodies (including a \begin{document} inside one) and honours group scope.
    • Its document boundary tolerates \begin {document}.
    • A 1 MB source went from 63 s (quadratic prefix rescans) to well under the test bound.

Review rounds

  1. First review, REQUEST_CHANGES:

    • \addtolength was overwritten by the older setlength_in path;
    • the \parskip stretch was lost;
    • geometry kept a stale MediaBox;
    • heading specs were derived before \parindent;
    • the scan was fooled by comments, macro bodies and groups.

    All fixed.

  2. Re-review: it confirmed those FIXED and found:

    • quadratic brace_depth rescans;
    • \begin{document} inside a macro body taken as the boundary;
    • oracle comments that implied a live pdflatex run.

    All fixed. read_group stays separate from matching_brace, which neither skips % comments nor yields the inner bytes, so {6in%\n} would break.

Tests

Run on this branch against the current vendored compiler pin:

  • test result: ok. 121 passed; 0 failed; 2 ignored (render-pipeline lib; the 2 ignored are \input preambles and \@setlength)
  • test result: ok. 5 passed; 0 failed; 0 ignored (preamble_lengths_oracle, with values pinned from pdflatex measurements or class arithmetic, as commented)

Overlap check

  • Clean on main b529e9d3, including render-pipeline: \paragraph/\subparagraph are run-in headings #404's run-in headings, which this re-derives consistently.
  • No vendor/ changes.
  • Until the compiler half is merged and re-pinned, the vendored compiler may still emit its old "unsupported" diagnostics for \addtolength, although the layout is applied.

Not done

  • References use final geometry, not source order: \setlength{\parskip}{\textwidth} before \usepackage[…]{geometry}.
  • \input-ed preamble files and \@setlength (tests ignored).
  • The pipeline's x-height source differs from the compiler's.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

…h \setlength/\addtolength

The pipeline half of lane #258, split from agent/daniel-parent/preamble-lengths
@ 695dfaa (20 reviewed WIP commits). The compiler half is its own PR.

- Preamble assignments to \textwidth, \textheight, the margins, \headheight,
  \headsep, \footskip, \paperwidth/\paperheight, \parindent and \parskip are
  applied to the page frame. \addtolength accumulates, and \parskip keeps its
  glue stretch and shrink.
- With geometry, paper-size assignments set the PDF MediaBox; without it they
  only move the frame, as in LaTeX.
- Heading specs are re-derived when \parindent was assigned.
- The scan is one linear pass that skips % comments, braces and
  \newcommand/\renewcommand/\def bodies (including a \begin{document} inside
  one) and honours group scope. A 1 MB source went from 63 s to under the test
  bound.

What was run (CARGO_TARGET_DIR=target-verify, against the current vendored compiler pin):
test result: ok. 121 passed; 0 failed; 2 ignored  (render-pipeline --lib)
test result: ok. 5 passed; 0 failed; 0 ignored    (--test preamble_lengths_oracle)

Known limits (ignored tests): \input-ed preamble files, \@setlength. Length
references use final geometry rather than source order.

Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast (lane commits ae37132..695dfaa)
Commit-Executor: daniel-parent (split into compiler and pipeline PRs)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.

2 participants