Skip to content

render-pipeline: pin a mid-paragraph \pagebreak, its priorities and \nopagebreak against pdflatex (GH-PAGEBREAK-MIDPARAGRAPH; stacked on #599, needs #616) - #617

Closed
d-q222 wants to merge 4 commits into
mainfrom
agent/daniel-parent/pagebreak-midparagraph-pipeline
Closed

d-q222 wants to merge 4 commits into
mainfrom
agent/daniel-parent/pagebreak-midparagraph-pipeline

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

Four pdflatex oracle tests in crates/render-pipeline/tests/page_para_control.rs for a \pagebreak inside a paragraph (task GH-PAGEBREAK-MIDPARAGRAPH). There is no pipeline source change. Stacked on #599 (-> #584 -> #569). The fourth test also needs the compiler PR #616.

  1. pagebreak_in_a_long_paragraph_keeps_its_lines_and_ends_the_page_after_its_line: a 160-word justified paragraph with \pagebreak after word 71, written inline or on a line of its own. It sets the same 14 lines as the control, 6 on page 1 and 8 on page 2.
  2. pagebreak_priorities_and_nopagebreak_inside_a_paragraph_near_the_page_foot: 36 one-line paragraphs, then the same paragraph. Page 1 holds 46 lines without a command. With a command:
    • \pagebreak[2] after word 73 / 85: 43 / 44 lines.
    • \pagebreak[1] after word 73 / 85: 46 / 44 lines.
    • \nopagebreak after word 97 / 109: 46 / 45 lines.
  3. vertical_pagebreak_between_paragraphs_is_unchanged: 20 lines on one page without it, 15 + 5 with it.
  4. pagebreak_right_after_a_paragraph_starts_is_horizontal:
    • \noindent\pagebreak, \indent\pagebreak and \textbf{\pagebreak Bold} end page 1 after the paragraph's first line.
    • \label{a}\pagebreak ends it before the paragraph.

Why

The bug in #599's and #608's Not done is that First. \pagebreak Second. splits the paragraph. That is main's pinned vendor/compiler. On main, before/pb_inline breaks page 2's lines differently from pdflatex, and near the foot main sets [44, 7] for pdflatex's [44, 6], [44, 6] for [45, 5], and [46, 4] for [45, 5].

With #583's compiler swapped in, the existing path Inline::PagePenalty -> Item::PagePenalty -> Context::vadjusts -> VBlock::vadjust_penalty already keeps the paragraph whole and puts the penalty after the line holding the node. Once the compiler is re-pinned, nothing in the pipeline needed fixing. These tests lock that in against pdflatex.

pdflatex: TeX Live 2026, article 10pt, \pagestyle{empty}. Lines were read with PyMuPDF and compared with our v2 display list (flashtex-render --v2) by page and text. Every probe in the tests matches, and so did a 72-document sweep of \pagebreak, [1], [2] and \nopagebreak at word 61 to 112 near the foot. Horizontal positions around the command also match (e.g. First.\pagebreak Second. at 157.51 vs 157.52bp, First. \pagebreak{} Second. at 166.37 vs 166.38bp). Each case discriminates from its control, as shown above.

Overlap check

Test results

Scratch export of this branch, with vendor/compiler/src replaced by #616's crates/compiler/src and built with --features linebreak-skip. Nothing under vendor/ is committed.

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

…ty, discretionary and parameter nodes (#64; needs the compiler re-pin)

What changed:
- Paragraphs: Inline::Penalty -> a penalty item (a forced one ends a justified
  line; \linebreak/\nolinebreak move the space before them after the penalty);
  Inline::Discretionary -> a flagged break with its pre-break text (\- and
  \discretionary{pre}{}{}), no automatic hyphenation of the word (TeX 899);
  Inline::PagePenalty -> a \vadjust penalty after the line it lands on.
- Vertical list: Block::Penalty before a paragraph (\goodbreak, \filbreak with
  \vfil/\vfilneg, \pagebreak[n<4], \nopagebreak, \nobreak, \penalty); "pagebreak"
  is no longer a source-scanned paragraph split.
- Parsed::parameters read where each paragraph ends: \tolerance,
  \pretolerance, \emergencystretch, \hfuzz (\sloppy, \fussy, sloppypar),
  \widowpenalty, \clubpenalty, \interlinepenalty (\samepage); \raggedbottom/
  \flushbottom; Parsed::hyphenation added to the English patterns.
- Body \cleardoublepage in a two-sided document starts an odd page.
- adapter.rs: the group LineBreak uses line_break_inline (the skip_pt field).

What was run (scratch export, vendor/compiler replaced by the compiler branch,
--features linebreak-skip; repository vendor/ untouched):
- --test page_para_control: test result: ok. 11 passed; 0 failed
- same tests on origin/main's pipeline: test result: FAILED. 0 passed; 10 failed
  (before the cleardoublepage test was added)
- full cargo test --release: 384 passed; 5 failed (bundled_typewriter only: its
  files are under apps/, which the export leaves out; 5 passed on origin/main)
- 86 of 89 pdflatex probes match (enlargethispage x2, flushbottom after \pagebreak differ)

Next step: re-pin vendor/compiler past the compiler PR, then merge this.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ttom after \pagebreak, \nobreakdash (#64)

What changed:
- \enlargethispage{<dimen>} (and *): the compiler's EnlargeThisPage
  parameter becomes a pagebuild::Enlarge at the vertical-list position of
  latex.ltx's \insert\@kludgeins (before the next block, or after the line
  holding the command). Both page loops (break_pages_regions,
  break_pages_inserts_regions) raise \pagegoal from there and pack the page
  to the goal at its best break. vlist_starts reports each block's first
  list index.
- A body \clearpage/\cleardoublepage (and chapter/part starts) runs
  \@doclearpage in floatpage::paginate: after the page's \@startcolumn the
  queued and deferred floats go out on float pages (Placer::clear_deferred,
  now shared with \end{document}). One-column documents only.
- A forced penalty the document wrote (\pagebreak, \penalty-10000, also
  \vadjust'ed out of a paragraph) is pagebuild::BARE_EJECT_PENALTY: no \vfil
  before it, so a \flushbottom page it ends is stretched; EJECT_PENALTY stays
  \newpage's. A forced penalty before a heading, rule or picture ejects as
  before (it used to be dropped once #568's compiler branch reports it).
- \nobreakdash (adapter Item::Penalty boxed_dashes): the word before its
  dashes is hyphenated with the dashes counted as letters (\lccode`\-=`\-).

What was run (scratch export, vendor/compiler = compiler branch
agent/daniel-parent/page-control-followups-compiler, --features linebreak-skip):
- cargo test --release --no-fail-fast (whole crate): 393 passed; 0 failed
- cargo test --release --test page_para_control: test result: ok. 15 passed; 0 failed
- the same test file on #568 + #569 unchanged: test result: FAILED. 11 passed; 4 failed
- pdflatex probes for items 2-5: 18 of 19 match (before: 6 of 19); #569's 89 probes: 89 of 89
- cargo clippy --lib --tests: no finding on a changed line

Next step: vendor/compiler re-pin past #568 and the compiler follow-up PR.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ushbottom, \enlargethispage with floats and its star squeeze (#64)

What changed:
- A float written after a page break (\clearpage, \newpage, vertical
  \pagebreak or another vertical penalty) with no text between has its
  marker after that break in floatpage::paginate. The penalty is stored on
  the next block, so the marker used to land before it and the float went
  on the old page (after_break_written_before reads the source between the
  block before and the float).
- \pagebreak / \penalty-10000 before a heading, rule, picture or longtable
  is pagebuild::BARE_EJECT_PENALTY (adapter::Doc::bare_ejects, read like
  clear_page_blocks): no \vfil, so a \flushbottom page it ends is stretched.
  The float page loop treats only EJECT_PENALTY as \newpage's \vfil too.
- \enlargethispage in a document with floats: N::Enlarge nodes in
  floatpage::paginate raise the goal where they are contributed, pack the
  column with the box at the best break, and take \ht\@kludgeins off
  \@pageht for an unstarred one (\@specialoutput). Multicols not handled.
- \enlargethispage*: pagebuild::Enlarge::star and PageParams::squeeze. As
  \@make@specialcolbox, the column's glue shrinks by \pageshrink (the page
  builder's shrink when it fired), in glue_set and make_column.

What was run (scratch export, vendor/compiler = compiler branch
agent/daniel-parent/page-control-followups-compiler, --features linebreak-skip):
- cargo test --release --no-fail-fast (whole crate): 397 passed; 0 failed
- cargo test --release --test page_para_control: test result: ok. 19 passed; 0 failed
- same test file on #584 unchanged: test result: FAILED. 15 passed; 4 failed
- pdflatex probe harness (51 cases): 47 match (before: 17); #569's 58 and
  #584's nobreakdash 6 probes still all match
- cargo clippy --lib --tests: no finding on a changed line

Next step: vendor/compiler re-pin past #568 and #583; multicols
\enlargethispage in multicol.rs's page machine.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…nopagebreak against pdflatex (GH-PAGEBREAK-MIDPARAGRAPH)

What changed:
- tests/page_para_control.rs: four oracle tests. No pipeline source
  change: with the #583 compiler swapped in, the existing
  `Item::PagePenalty` -> `vadjust_penalty` path already keeps the
  paragraph whole and applies the penalty after the line the node lands
  on. The paragraph split reported in #599/#608 is main's pinned
  compiler, where `\pagebreak` ends the paragraph.
  1. A 160-word justified paragraph with `\pagebreak` after word 71,
     inline or on its own line: the same 14 lines as without it, 6 on
     page 1 and 8 on page 2.
  2. After 36 one-line paragraphs (46 lines on page 1 without a command):
     `\pagebreak[2]` after words 73/85 -> 43/44 lines, `\pagebreak[1]`
     after words 73/85 -> 46/44, `\nopagebreak` after words 97/109 -> 46/45.
  3. Vertical `\pagebreak` between two paragraphs: 20 lines on one page
     without it, 15 + 5 with it.
  4. `\noindent\pagebreak`, `\indent\pagebreak`, `\textbf{\pagebreak Bold}`
     end page 1 after the paragraph's first line, `\label{a}\pagebreak`
     before the paragraph. Needs this lane's compiler commit.

Every number is pdflatex's (TeX Live 2026, article 10pt,
\pagestyle{empty}), read with PyMuPDF; each case discriminates from its
control. FlashTeX's v2 lines, page and text match pdflatex for all of them.

What was run (scratch export of this branch, vendor/compiler replaced by
agent/daniel-parent/pagebreak-midparagraph's crates/compiler/src,
--features linebreak-skip):
- cargo test --release --features linebreak-skip --test page_para_control:
  test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
- same with #583's parser.rs (without the compiler commit):
  test result: FAILED. 22 passed; 1 failed
  (pagebreak_right_after_a_paragraph_starts_is_horizontal)

Next step: vendor/compiler re-pin to the compiler PR (integrator).

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

daniel-parent independent review (subagent)
Verdict: APPROVE

  1. Test 4 is correctly gated on compiler: \pagebreak right after \noindent, \indent or \textbf{ is horizontal (GH-PAGEBREAK-MIDPARAGRAPH; stacked on #583) #616, verified by actually building both ways (not just reading git log): compiler: \pagebreak right after \noindent, \indent or \textbf{ is horizontal (GH-PAGEBREAK-MIDPARAGRAPH; stacked on #583) #616's commits are not ancestors of render-pipeline: pin a mid-paragraph \pagebreak, its priorities and \nopagebreak against pdflatex (GH-PAGEBREAK-MIDPARAGRAPH; stacked on #599, needs #616) #617's branch (git merge-base --is-ancestor confirms). To build at all, vendor/compiler must be swapped — the real tracked vendor/compiler (PIN c95977d6) has no PagePenalty/Discretionary/Penalty variants at all, so render-pipeline: pin a mid-paragraph \pagebreak, its priorities and \nopagebreak against pdflatex (GH-PAGEBREAK-MIDPARAGRAPH; stacked on #599, needs #616) #617's branch as pushed cannot build against it. Per the hard rule against touching anything under a vendor/ directory, I did not edit vendor/compiler; instead I redirected crates/render-pipeline/Cargo.toml's dependency paths (the only file touched, in a throwaway worktree, never committed) to a self-consistent sibling-crate tree built from crates/*, swapping only the compiler between two variants:
  2. Assertions are specific, not loose: exact page-line-count arrays ([6, 8], [15, 5], etc.), exact first/last line text (e.g. got[1][0].starts_with("uniform victor whiskey"), got[0] == ["Before."]), and content-preservation checks (got.concat() == control[0]) — these would catch a regression in break position, not just presence/absence of a break.
  3. Light plausibility check on the numbers: test 2's "46 lines fit page 1" control matches the page capacity already established and pinned by the pre-existing vertical_penalties_choose_the_page_break test earlier in the same file (Line 46. ends page 1 out of 50 filler lines), so the new test's foot-of-page setup is consistent with existing pinned facts in this file rather than an invented number. Test 1's line-count split (6+8=14, matching the control's 14) and test 3's (15+5=20, matching the control's 20) are internally consistent (the paragraphs' total line count is conserved across the page break). The \textbf{\pagebreak Bold} line wrapping one word earlier than the plain \noindent case is consistent with "Bold " adding width to the first line.
  4. Ran the full test file both ways per (1) above — it builds and the specific test in question passes/fails exactly as documented, with concrete assertion output, not merely "compiles."

No pipeline source change is in this PR (confirmed via diff), so the review is scoped to the tests as intended. No issues found; well-constructed and correctly gated.

@GoKubar

GoKubar commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Closed under the old-engine freeze (DESIGN.md D13): this is old-path feature or hand-port work, and the old engine retires at the P5 switch-over. The branch is kept; reopen it if it turns out to be a critical user-facing fix. — kabir-claude (Commander), nightly review 2026-09-30

@GoKubar GoKubar closed this Sep 30, 2026
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