Skip to content

compiler: page and paragraph control commands as penalty, discretionary and parameter nodes (#64) - #568

Merged
GoKubar merged 4 commits into
mainfrom
agent/daniel-parent/page-para-control
Sep 15, 2026
Merged

GoKubar merged 4 commits into
mainfrom
agent/daniel-parent/page-para-control

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

Compiler side of issue #64: the page and paragraph control commands become nodes and parameters the render pipeline can act on, instead of unknown commands whose numbers leak onto the page.

  • New AST (crates/compiler/src/parser.rs):
    • Inline::Penalty { value, span, unskip }: \penalty, \nobreak, \allowbreak, \linebreak[n], \nolinebreak[n] (latex.ltx \@getpen 0/51/151/301/10000; unskip is \@no@lnbk's space move).
    • Inline::PagePenalty { value, span }: \pagebreak[n] / \nopagebreak[n] inside a paragraph (\vadjust). The paragraph is no longer broken.
    • Inline::Discretionary { pre, post, nobreak, hyphen, span, style }: \- (now a command in the lexer and the expansion pass, never a hyphen character) and \discretionary{}{}{}.
    • Block::Penalty { value, fil, span }: vertical-mode \penalty/\nobreak/\allowbreak, \pagebreak[n<4], \nopagebreak[n], \goodbreak, \filbreak.
  • Parsed::parameters (BreakParameter + the group end that restores it): \tolerance, \pretolerance, \looseness, \widowpenalty, \clubpenalty, \interlinepenalty, \emergencystretch (also \setlength), \sloppy, \fussy, sloppypar, \samepage (command and environment), \raggedbottom, \flushbottom, \enlargethispage(*) (including n\baselineskip). Parsed::hyphenation: \hyphenation words.
  • Core 14 layout: a forced penalty breaks (a justified line / a page); \pagebreak inside a paragraph ends the page after its line (FlowState carries the pending eject).
  • Inventory, vocabulary and the generated supported-LaTeX artefacts regenerated with render_supported_latex.sh (kernel coverage 183/410 -> 190/410).

Why

pdflatex evidence (full table below): \- was painted as a hyphen, \penalty10000 typeset 10000, \pagebreak inside a paragraph split it and added a page, \linebreak was set ragged, and 15 of the 24 audited commands were unsupported. The render pipeline builds against vendor/compiler, so this PR changes no rendered output by itself. The companion draft render-pipeline PR consumes these nodes and needs a re-pin of vendor/compiler past this PR.

Overlap check

Test results

cargo test (crates/compiler, before the inventory move): 573 passed; 0 failed
cargo test --lib: test result: ok. 347 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
cargo test --test supported_latex: test result: ok. 8 passed; 0 failed
cargo test --test hw1_preamble: test result: ok. 2 passed; 0 failed
cargo test --test hw2_gate: test result: ok. 6 passed; 0 failed
cargo test --test corpus_gate: test result: ok. 1 passed; 0 failed; 1 ignored
cargo test --test pinned_fixtures: test result: ok. 5 passed; 0 failed
cargo test --test incremental_json_identity / local_recovery / preamble_page_commands / line_break_skip: all ok
cargo check --all-targets (crates/paragraph-layout, crates/bridge): clean

New tests, each pinned to pdflatex \showlists/\showthe or its PDF: horizontal_penalties_carry_latex_values, vertical_penalties_are_blocks_with_latex_values, goodbreak_ends_the_paragraph_it_is_written_in, vertical_penalty_forces_a_page_only_at_eject, penalty_line_break_is_still_a_line_break_in_the_core14_layout, discretionaries_are_nodes_not_text, breaking_parameters_are_reported_with_their_scope, pagebreak_inside_a_paragraph_ends_the_page_after_its_line_not_the_paragraph. pagebreak_at_default_or_explicit_priority_four_forces_a_fresh_page now puts the command between paragraphs: pdflatex sets First page\pagebreak Second page on one page. They fail first on origin/main: the node tests do not compile there (no such variants), and the layout assertions (1 page for an in-paragraph \pagebreak, no - item for manu\-scripts, no 10000 text) contradict main's output (main's own test asserted 2 pages).

cargo clippy --all-targets -D warnings and cargo fmt --check are not clean on origin/main (20 clippy findings, 119 rustfmt hunks in parser.rs). None of the clippy findings are in lines this PR adds. Only this PR's own hunks were formatted.

Not done

  • Render-pipeline effects: in the companion draft PR, blocked on the vendor/compiler re-pin (integrator action).
  • \nobreakdash (amsmath, 6 files): untouched.
  • \discretionary keeps only the plain text of its arguments.
  • \samepage reports only \interlinepenalty (not its list, display and section penalties).
  • \enlargethispage and \looseness are parsed and reported here, but the pipeline does not apply them (see the draft PR).

Audit: page and paragraph control commands (GH-64)

State on origin/main @ 36fe7ec3, measured with flashtex check/build (render pipeline, vendor compiler pin c95977d6) against pdflatex (TeX Live 2026, article 10pt, \pagestyle{empty}). Line and page outcomes were read from both PDFs with PyMuPDF (words grouped by baseline) on engineered documents; each engineered probe was checked to discriminate (pdflatex sets different lines/pages without the command). Node values come from pdflatex \showlists/\showthe.

"After" is the compiler PR plus the render-pipeline draft, built together in a scratch export with vendor/compiler replaced by the compiler branch (the repository's vendor/ is untouched).

Usage = files using the command among the 12,038 .tex files of TeX Live 2026 texmf-dist/doc (real documents; the in-repo corpus has almost none of these commands).

Command Usage (files) Before (origin/main) After pdflatex evidence
\newpage 1348 supported unchanged a\newpage b: 2 pages (FlashTeX 2)
\clearpage 1043 supported unchanged a\clearpage b: 2 pages (FlashTeX 2)
\- 452 wrong: the hyphen is painted even when the line does not break (manu-scripts) Inline::Discretionary; a flagged \hyphenpenalty break with the face's hyphen, invisible unbroken; the word gets no automatic points (TeX §899) unbroken: manuscripts; engineered: line 1 ends qwrtzp-, with 2 more xx in front qwrtzplkjhgfd starts line 2
\pagebreak[n] 431 wrong: inside a paragraph it splits the paragraph and starts a page; [n<4] still forces a page vertical mode: Block::PageBreak (n=4) / Block::Penalty -\@getpen{n}; in a paragraph Inline::PagePenalty after the line it is set on a\pagebreak{} b and a\pagebreak[1] b: one line a b, 1 page (FlashTeX 2); a\par\pagebreak[1] b: 1 page (FlashTeX 2); \showlists: \vadjust \penalty -10000
\nobreak 297 unsupported (unknown_command error) Inline::Penalty/Block::Penalty 10000 Figure\nobreak\ 7: line 1 ends Figure 7; between paragraphs 46/47: page 1 ends Line 45.
\penalty 217 unsupported; the number is typeset as text (Fig-ure10000) node in either mode, span covers the number \penalty10000\ : Figure 7; \penalty-10000 after Line 43.: page 1 ends there
\sloppy / \fussy / sloppypar 212 / 21 / 41 partial: a top-level \sloppy only (source scan); \fussy unknown; sloppypar warned and ignored Parsed::parameters (tolerance 9999, emergencystretch 3em, hfuzz .5pt / 200, 0, .1pt) with the group end that restores them; read where each paragraph ends sloppypar: floccinaucini- / hilipilification ... hippopotomon-; \sloppy\fussy: floccinaucinihilip-
\hyphenation{} 200 unsupported diagnostic, exceptions ignored Parsed::hyphenation; the pipeline adds them to the English patterns \hyphenation{flocc-inaucinihilipilification}: line 1 ends with the whole word (control: floccinaucinihilip-)
\enlargethispage / * 187 unsupported (plus an error for \baselineskip) compiler: EnlargeThisPage {pt, shrink} (pt, cm, ..., n\baselineskip), no diagnostic. Pipeline: not applied \enlargethispage{2\baselineskip}: page 1 holds 47 lines; FlashTeX 46
\linebreak[n] 173 wrong: a forced break is set ragged like \\; [n<4] ignored Inline::Penalty -\@getpen{n} with the space before it moved after it; a forced break ends a justified line line 1 Short words here ends at x 477.5 bp (FlashTeX before: 207.8, the \\ position); \showlists: \penalty -151 for [2]
\cleardoublepage 157 wrong when two-sided: no empty page compiler unchanged (Block::PageBreak); pipeline: the odd-page test \chapter already uses book: a\cleardoublepage b 3 pages (FlashTeX 2); article: 2
\tolerance / \pretolerance 134 / 53 unsupported, value typeset as text parameters, read per paragraph \tolerance=9999: floccinaucini- (control floccinaucinihilip-); \pretolerance probe did not discriminate
\raggedbottom / \flushbottom 130 / 32 unknown commands; only the class default FlushBottom parameter; the last top-level one decides the page glue 42 lines + an unbreakable paragraph: last baseline y 627 (article) → 675 with \flushbottom; book 674 → 626 with \raggedbottom
\nopagebreak[n] 115 accepted no-op (the page could still break there) \@getpen{n} penalty, both modes between Line 46. and Line 47.: page 1 ends Line 45. (FlashTeX before Line 46.)
\widowpenalty / \clubpenalty 97 / 79 unsupported, value typeset as text parameters, used by the page builder 4-line paragraph after Line 43.: 45 lines on page 1, 46 with \widowpenalty=0; after Line 45.: 45, 46 with \clubpenalty=0
\emergencystretch 91 unsupported; \setlength{\emergencystretch} warned parameter (both forms) \emergencystretch=3em: floccinaucini-
\allowbreak 84 unsupported \penalty0 node Figure/\allowbreak seven/: line 1 ends Figure/
\discretionary{}{}{} 63 unsupported; the three arguments typeset as text Inline::Discretionary (plain text of each argument); pipeline breaks with the pre-break text. Non-empty post-break/no-break text: the no-break text is set with no break (painter limitation) qwrtzp\discretionary{=}{}{}lkjhgfd: line 1 ends qwrtzp=
\interlinepenalty 58 unsupported parameter \interlinepenalty=10000: the 4-line paragraph moves whole, page 1 holds 43 lines
\looseness 54 unsupported, value typeset as text compiler: Looseness parameter, no diagnostic. Pipeline: not applied (paragraph-layout has no looseness) probe did not discriminate
\goodbreak / \filbreak 46 / 31 unsupported \par + Block::Penalty -500 / -200 with \vfil…\vfilneg after Line 43.: page 1 ends Line 43. (FlashTeX before Line 46.)
\samepage 32 unsupported (command and environment) InterlinePenalty(10000) for the group the paragraph after Line 43./44. moves whole to page 2
\nolinebreak[n] 22 accepted no-op (the break stayed legal) Inline::Penalty \@getpen{n}, space moved after it Figure \nolinebreak 7: Figure 7 (FlashTeX before: Figure / 7 shows)
\nobreakdash 6 unsupported (amsmath) unchanged not done

Counts (24 rows). Before: supported 2, accepted no-op 2, partial 1, wrong 4, unsupported 15. After: 21 rows match pdflatex on their probes (one, \discretionary, with the post-break/no-break limitation); not done 3 (\enlargethispage and \looseness parsed by the compiler but not applied by the pipeline; \nobreakdash untouched). Still open: under \flushbottom a page ended by a vertical \pagebreak keeps natural glue (pdflatex stretches it; FlashTeX treats it like \newpage).

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

…ry and parameter nodes (#64)

What changed:
- New AST: Inline::Penalty {value, unskip} (\penalty, \nobreak, \allowbreak,
  \linebreak[n], \nolinebreak[n]), Inline::PagePenalty (\pagebreak[n] and
  \nopagebreak[n] inside a paragraph: \vadjust, the paragraph is not broken),
  Inline::Discretionary (\-, \discretionary{}{}{}), Block::Penalty {value, fil}
  (vertical-mode \penalty/\nobreak, \pagebreak[n<4], \nopagebreak[n],
  \goodbreak, \filbreak). Values are latex.ltx's \@getpen 0/51/151/301/10000.
- Parsed::parameters: \tolerance, \pretolerance, \looseness, \widowpenalty,
  \clubpenalty, \interlinepenalty, \emergencystretch (also \setlength),
  \sloppy, \fussy, sloppypar, \samepage (and its environment), \raggedbottom,
  \flushbottom, \enlargethispage(*), each with the group end that restores it.
  Parsed::hyphenation: \hyphenation words.
- \- is a command in the lexer and the expansion pass, so it is never typeset
  as a hyphen; \penalty's number and parameter values no longer leak as text.
- Core 14 layout: forced penalties break lines/pages; \pagebreak in a paragraph
  ends the page after its line (FlowState carries the pending eject).
- Inventory, vocabulary and generated supported-LaTeX artefacts regenerated.

What was run:
- cargo test (crates/compiler): 573 passed; 0 failed before the inventory move,
  then --lib: test result: ok. 347 passed; 0 failed
- --test supported_latex: test result: ok. 8 passed; 0 failed
- --test hw1_preamble/hw2_gate/corpus_gate/pinned_fixtures/incremental_json_identity/
  local_recovery/preamble_page_commands/line_break_skip: all ok
- pdflatex \showlists / \showthe oracle for every value (in the PR body).

Next step: render-pipeline consumes the nodes after vendor/compiler is re-pinned.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
#64)

What changed:
- Inline::Penalty/PagePenalty spans now include `[n]` and `\penalty`'s number,
  so a consumer reading the source after a node starts past them (the
  pipeline decides whether LaTeX ate the blanks after the command from this).

What was run:
- cargo test --lib (crates/compiler): test result: ok. 347 passed; 0 failed

Next step: open the compiler PR and the render-pipeline draft.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Kept both sides of the supported.rs inventory (main's \xspace entry plus this
branch's penalty-based page/paragraph-control entries) and regenerated
docs/user/compiler.md, supported-latex.json, coverage.md and the Mac bundled
copy via render_supported_latex.sh.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…followups

Brings in origin/main via the parent PR #568 branch's merge commit; regenerated
docs/user/compiler.md and the supported-latex inventories.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
Kept main's \fnsymbol dispatch arm alongside this branch's penalty-based
\linebreak/\nolinebreak arms; regenerated the supported-latex artefacts.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…wups

Records the parent PR #568 branch's own origin/main merge; no tree changes.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
@GoKubar
GoKubar merged commit 4da51be into main Sep 15, 2026
10 of 21 checks passed
GoKubar added a commit that referenced this pull request Sep 15, 2026
…rew the inventory

docs/user/compiler.md (generated) conflicted once more after main's page
and paragraph control commands (#568) landed. Took main's copy and
regenerated via crates/compiler/scripts/render_supported_latex.sh so \Box
and main's additions both appear; Mac bundled supported-latex.json synced,
--check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
/#568)

Conflicts:
- crates/compiler/src/parser.rs: both sides appended P fields; kept both.
- crates/compiler/src/expansion.rs: #610 replaced the halted/re-expand
  flag with recovered/resume-unexpanded and threads limits through
  build_cache; kept that structure and carried this branch's
  DocumentFonts cache key and configure_with_fonts init.
- crates/tex-expansion/src/expand.rs, incremental.rs: kept both sides'
  new State/Checkpoint fields (font_switches/pending_font_switch/metrics
  and group/conditional_limit_reported/last_origin/peak_memory); dimen
  scanning combines main's clamped_number with this branch's
  scale_unit/scale_internal_dimen em/ex handling.
Regenerated supported-latex artifacts; bundled copy in sync.

Implementation-Agent: fable-rebase-d
Commit-Executor: fable-rebase-d (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
Parent #568 is squashed on main; kept this branch's own changes (nobreakdash,
bare-penalty vertical \pagebreak, doc comments) over the squash and main's
#610 parser changes. Regenerated the supported-latex artefacts.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…fields

The #568 squash and this branch both carried
pagebreak_inside_a_paragraph_ends_the_page_after_its_line_not_the_paragraph
(byte-identical); kept one. kernel_untested_b.rs's Block::VSpace pattern now
ignores #606's stretch_pt/shrink_pt (it asserts only pt) - note main's tip has
the same flat pattern and needs the same fix.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…NMENTS; regenerate docs; fix main's VSpace pattern break

crates/compiler/src/vocabulary.rs conflicted because this branch removed
dcases/rcases (now implemented here) while main removed samepage/sloppypar
(implemented by #568); kept both removals (the intersection).
docs/user/compiler.md and the supported artefacts were regenerated via
render_supported_latex.sh; Mac bundled copy sync --check clean.

Also carries the one-line semantic fix current main needs: #606 added
stretch_pt/shrink_pt to Block::VSpace but tests/kernel_untested_b.rs:251
still matched 'Block::VSpace { pt }' (E0027); widened to '{ pt, .. }'.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…NMENTS; regenerate docs; fix main's VSpace pattern break

crates/compiler/src/vocabulary.rs conflicted because this branch removed
'frame' (implemented here) while main removed samepage/sloppypar
(implemented by #568); kept both removals. Regenerated the supported-latex
artefacts via render_supported_latex.sh; Mac bundled copy sync --check
clean. Also the one-line fix current main needs:
tests/kernel_untested_b.rs:251 'Block::VSpace { pt }' fails E0027 after
#606 added stretch_pt/shrink_pt; widened to '{ pt, .. }'.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…#64; stacked on #568) (#583)

* compiler: page and paragraph control commands as penalty, discretionary and parameter nodes (#64)

What changed:
- New AST: Inline::Penalty {value, unskip} (\penalty, \nobreak, \allowbreak,
  \linebreak[n], \nolinebreak[n]), Inline::PagePenalty (\pagebreak[n] and
  \nopagebreak[n] inside a paragraph: \vadjust, the paragraph is not broken),
  Inline::Discretionary (\-, \discretionary{}{}{}), Block::Penalty {value, fil}
  (vertical-mode \penalty/\nobreak, \pagebreak[n<4], \nopagebreak[n],
  \goodbreak, \filbreak). Values are latex.ltx's \@getpen 0/51/151/301/10000.
- Parsed::parameters: \tolerance, \pretolerance, \looseness, \widowpenalty,
  \clubpenalty, \interlinepenalty, \emergencystretch (also \setlength),
  \sloppy, \fussy, sloppypar, \samepage (and its environment), \raggedbottom,
  \flushbottom, \enlargethispage(*), each with the group end that restores it.
  Parsed::hyphenation: \hyphenation words.
- \- is a command in the lexer and the expansion pass, so it is never typeset
  as a hyphen; \penalty's number and parameter values no longer leak as text.
- Core 14 layout: forced penalties break lines/pages; \pagebreak in a paragraph
  ends the page after its line (FlowState carries the pending eject).
- Inventory, vocabulary and generated supported-LaTeX artefacts regenerated.

What was run:
- cargo test (crates/compiler): 573 passed; 0 failed before the inventory move,
  then --lib: test result: ok. 347 passed; 0 failed
- --test supported_latex: test result: ok. 8 passed; 0 failed
- --test hw1_preamble/hw2_gate/corpus_gate/pinned_fixtures/incremental_json_identity/
  local_recovery/preamble_page_commands/line_break_skip: all ok
- pdflatex \showlists / \showthe oracle for every value (in the PR body).

Next step: render-pipeline consumes the nodes after vendor/compiler is re-pinned.

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

* compiler: penalty nodes' spans cover their number and priority bracket (#64)

What changed:
- Inline::Penalty/PagePenalty spans now include `[n]` and `\penalty`'s number,
  so a consumer reading the source after a node starts past them (the
  pipeline decides whether LaTeX ate the blanks after the command from this).

What was run:
- cargo test --lib (crates/compiler): test result: ok. 347 passed; 0 failed

Next step: open the compiler PR and the render-pipeline draft.

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

* compiler: \include clears the page, vertical \pagebreak is a bare penalty, \nobreakdash (#64)

What changed:
- \include{file} emits latex.ltx \@include's \clearpage before the file and
  after it (expansion.rs: the closing one precedes the first token read once
  the engine has left the file). A file \includeonly skips keeps only the
  first; a missing file keeps both. \input is unchanged.
- A vertical-mode \pagebreak (priority 4) is Block::Penalty { value: -10000 }
  instead of Block::PageBreak: latex.ltx has no \vfil before it, unlike
  \newpage, so a \flushbottom page it ends is stretched.
- amsmath \nobreakdash: the following -, -- or --- as text, then
  Inline::Penalty 10000 (\setboxz@h{--\nobreak}\unhbox\z@). Supported-LaTeX
  artefacts regenerated.

What was run:
- cargo test --lib: test result: ok. 349 passed; 0 failed
- cargo test --no-fail-fast (whole crate): every target ok after
  render_supported_latex.sh (supported_latex: ok. 8 passed; includeonly: ok. 10 passed)
- pdflatex probes with the render pipeline (scratch export): include 3/3 pages,
  include-para, include-two 4, include-last 2, includeonly-excluded 2: all match.

Next step: render-pipeline draft consumes the bare penalty (flushbottom) and
\nobreakdash's hyphenation; vendor re-pin past #568 and this PR.

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

* compiler: leave \include's page breaks to #578 (#64)

What changed:
- Reverted the \include \clearpage emission in expansion.rs and the
  includeonly test changes from the previous commit: #578 (render pipeline,
  agent/daniel-parent/include-float-numbering) already clears the page before
  and after an \include'd file, and the coordinator moved that item there.
  The vertical \pagebreak penalty and \nobreakdash stay.

What was run:
- cargo test --lib: test result: ok. 349 passed; 0 failed
- cargo test --test includeonly: test result: ok. 9 passed; 0 failed
- cargo test --test supported_latex: test result: ok. 8 passed; 0 failed

Next step: render-pipeline draft for \pagebreak under \flushbottom,
\nobreakdash hyphenation, \enlargethispage and the \clearpage float flush.

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

* Post-merge fixups: dedupe squashed test, VSpace pattern gains rubber fields

The #568 squash and this branch both carried
pagebreak_inside_a_paragraph_ends_the_page_after_its_line_not_the_paragraph
(byte-identical); kept one. kernel_untested_b.rs's Block::VSpace pattern now
ignores #606's stretch_pt/shrink_pt (it asserts only pt) - note main's tip has
the same flat pattern and needs the same fix.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)

---------

Co-authored-by: GoKubar <[email protected]>
GoKubar added a commit that referenced this pull request Sep 15, 2026
Parents #568/#583 are squashed on main; kept this branch's own mode-based
horizontal-\pagebreak logic, comment and test over the squash state, and took
main's #587 parser state fields (length_scopes, pending_global,
latin_modern, preamble_latin_modern). Regenerated supported-latex artefacts.

Implementation-Agent: fable-rebase-c
Commit-Executor: fable-rebase-c (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…rizontal (GH-PAGEBREAK-MIDPARAGRAPH; stacked on #583) (#616)

* compiler: page and paragraph control commands as penalty, discretionary and parameter nodes (#64)

What changed:
- New AST: Inline::Penalty {value, unskip} (\penalty, \nobreak, \allowbreak,
  \linebreak[n], \nolinebreak[n]), Inline::PagePenalty (\pagebreak[n] and
  \nopagebreak[n] inside a paragraph: \vadjust, the paragraph is not broken),
  Inline::Discretionary (\-, \discretionary{}{}{}), Block::Penalty {value, fil}
  (vertical-mode \penalty/\nobreak, \pagebreak[n<4], \nopagebreak[n],
  \goodbreak, \filbreak). Values are latex.ltx's \@getpen 0/51/151/301/10000.
- Parsed::parameters: \tolerance, \pretolerance, \looseness, \widowpenalty,
  \clubpenalty, \interlinepenalty, \emergencystretch (also \setlength),
  \sloppy, \fussy, sloppypar, \samepage (and its environment), \raggedbottom,
  \flushbottom, \enlargethispage(*), each with the group end that restores it.
  Parsed::hyphenation: \hyphenation words.
- \- is a command in the lexer and the expansion pass, so it is never typeset
  as a hyphen; \penalty's number and parameter values no longer leak as text.
- Core 14 layout: forced penalties break lines/pages; \pagebreak in a paragraph
  ends the page after its line (FlowState carries the pending eject).
- Inventory, vocabulary and generated supported-LaTeX artefacts regenerated.

What was run:
- cargo test (crates/compiler): 573 passed; 0 failed before the inventory move,
  then --lib: test result: ok. 347 passed; 0 failed
- --test supported_latex: test result: ok. 8 passed; 0 failed
- --test hw1_preamble/hw2_gate/corpus_gate/pinned_fixtures/incremental_json_identity/
  local_recovery/preamble_page_commands/line_break_skip: all ok
- pdflatex \showlists / \showthe oracle for every value (in the PR body).

Next step: render-pipeline consumes the nodes after vendor/compiler is re-pinned.

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

* compiler: penalty nodes' spans cover their number and priority bracket (#64)

What changed:
- Inline::Penalty/PagePenalty spans now include `[n]` and `\penalty`'s number,
  so a consumer reading the source after a node starts past them (the
  pipeline decides whether LaTeX ate the blanks after the command from this).

What was run:
- cargo test --lib (crates/compiler): test result: ok. 347 passed; 0 failed

Next step: open the compiler PR and the render-pipeline draft.

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

* compiler: \include clears the page, vertical \pagebreak is a bare penalty, \nobreakdash (#64)

What changed:
- \include{file} emits latex.ltx \@include's \clearpage before the file and
  after it (expansion.rs: the closing one precedes the first token read once
  the engine has left the file). A file \includeonly skips keeps only the
  first; a missing file keeps both. \input is unchanged.
- A vertical-mode \pagebreak (priority 4) is Block::Penalty { value: -10000 }
  instead of Block::PageBreak: latex.ltx has no \vfil before it, unlike
  \newpage, so a \flushbottom page it ends is stretched.
- amsmath \nobreakdash: the following -, -- or --- as text, then
  Inline::Penalty 10000 (\setboxz@h{--\nobreak}\unhbox\z@). Supported-LaTeX
  artefacts regenerated.

What was run:
- cargo test --lib: test result: ok. 349 passed; 0 failed
- cargo test --no-fail-fast (whole crate): every target ok after
  render_supported_latex.sh (supported_latex: ok. 8 passed; includeonly: ok. 10 passed)
- pdflatex probes with the render pipeline (scratch export): include 3/3 pages,
  include-para, include-two 4, include-last 2, includeonly-excluded 2: all match.

Next step: render-pipeline draft consumes the bare penalty (flushbottom) and
\nobreakdash's hyphenation; vendor re-pin past #568 and this PR.

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

* compiler: leave \include's page breaks to #578 (#64)

What changed:
- Reverted the \include \clearpage emission in expansion.rs and the
  includeonly test changes from the previous commit: #578 (render pipeline,
  agent/daniel-parent/include-float-numbering) already clears the page before
  and after an \include'd file, and the coordinator moved that item there.
  The vertical \pagebreak penalty and \nobreakdash stay.

What was run:
- cargo test --lib: test result: ok. 349 passed; 0 failed
- cargo test --test includeonly: test result: ok. 9 passed; 0 failed
- cargo test --test supported_latex: test result: ok. 8 passed; 0 failed

Next step: render-pipeline draft for \pagebreak under \flushbottom,
\nobreakdash hyphenation, \enlargethispage and the \clearpage float flush.

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

* compiler: \pagebreak right after \noindent, \indent or \textbf{ is horizontal (GH-PAGEBREAK-MIDPARAGRAPH)

What changed:
- The `\pagebreak`/`\nopagebreak` arm decided the mode from whether the
  paragraph had collected any inline. `\noindent`, `\indent` and the text
  font commands (`\hmode@bgroup` = `\leavevmode\bgroup`) start the
  paragraph without adding one, so `\noindent\pagebreak text` was a
  vertical penalty before the paragraph (on an empty page it was dropped
  entirely). A new parser flag `paragraph_started` is set by those
  commands and cleared when a block is pushed or the paragraph is flushed;
  with it set the command is `Inline::PagePenalty` (latex.ltx `\@no@pgbk`'s
  `\vadjust`).
- A paragraph holding only `\label`s is still vertical:
  `\label{a}\pagebreak text` is a `Block::Penalty` again.

pdflatex (TeX Live 2026, article): `\noindent\pagebreak`, `\indent\pagebreak`
and `\textbf{\pagebreak Bold}` before a two-line paragraph end page 1 after
the paragraph's first line; `\label{a}\pagebreak` ends it before the
paragraph. A mid-paragraph `\pagebreak` (inline, on its own line, `[1]`,
`[2]`, `\nopagebreak`) was already right on this stack.

What was run:
- cargo test --lib -- pagebreak: test result: ok. 6 passed; 0 failed
- cargo test (crates/compiler): see the PR

Next step: re-pin vendor/compiler for the pipeline tests in the stacked
pipeline PR.

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

---------

Co-authored-by: GoKubar <[email protected]>
@GoKubar
GoKubar deleted the agent/daniel-parent/page-para-control branch September 16, 2026 04:16
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
What changed:
- `crates/render-pipeline/Cargo.toml` declares a new off-by-default feature
  `compiler-node-surface`. It carries no behaviour of its own: every arm it
  adds is the inert answer the pipeline already gave for a compiler node the
  current pin (`c95977d6`) cannot produce.
- The pipeline's exhaustive matches and node constructors now cover main's
  compiler surface behind that feature: `parser::Block::Penalty`/`Tabbing`,
  `parser::Inline::ThePage`/`PageNumbering`/`TabStop`/`TabJump`/`Marginpar`/
  `Penalty`/`PagePenalty`/`Discretionary`, `VSpace`/`HSpace` glue components,
  `math::Nucleus::TextRun`/`SideSet`/`Lap` and `math::Accent::Mathring`
  (compiler flash-tex#549, flash-tex#551, flash-tex#555, flash-tex#568, flash-tex#581, flash-tex#583, flash-tex#587, flash-tex#606, flash-tex#616).
  `adapter::vspace_block` is a new cfg'd constructor beside the existing
  `line_break_inline`; the one open-coded `Inline::LineBreak { .. }` left in
  the `\opening` lowering now goes through `line_break_inline` too.
- `tabbing` is lowered to flush-left paragraphs with one `unsupported_block`
  limitation, the way `LetterBlock` is, so no row is dropped by the re-pin.
- `docs/integration/repin-runbook.md`: the exact re-pin commands, the three
  vendor directories that must move (`compiler`, `tex-expansion`, and a new
  `bibliography`), the lockfile and `#[ignore]` edits `--locked` CI needs, the
  measured test deltas and the PRs the pin unblocks.

No file under `vendor/` is touched: the vendor swap used to measure all of
this was scratch-only and reverted. `git diff --stat origin/main...HEAD`
contains zero `vendor/` paths.

What was run:
Whole `crates/render-pipeline` suite, CARGO_BUILD_JOBS=4, --no-fail-fast:
  origin/main, pinned vendor, feature off:   469 passed, 13 failed
  this branch, pinned vendor, feature off:   469 passed, 13 failed (same 13)
  this branch, vendor re-pinned, feature on: 485 passed, 0 failed
The 13 red-on-main tests (letter_class_geometry x5, frame_env, underline_sout
x4, uline x2, xcolor_oracle) all pass after the re-pin.
Two re-pin-gated #[ignore]s also pass against the re-pinned vendor:
  test frame_draws_a_rule_border_around_its_content ... ok
  test coloneqq_decomposes_like_mathtools ... ok
crates/flashtex-cli against the same re-pinned vendor:
  test result: ok. 58 passed; 0 failed
cargo check --all-targets on this branch at the current pin: 0 errors.

Next step:
The integration lane applies docs/integration/repin-runbook.md section 3 --
swap the three vendor trees, move `compiler-node-surface` (and
`linebreak-skip`) into `default`, refresh both Cargo.locks, drop the two
`#[ignore]`s, update vendor/VENDORING.md.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
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