Skip to content

compiler: report \\[<dimen>]'s optional argument on Inline::LineBreak - #478

Merged
GoKubar merged 1 commit into
mainfrom
agent/nixos-cv-lecture/compiler-linebreak-skip
Sep 15, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/nixos-cv-lecture/compiler-linebreak-skip

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

compiler: report \\[<dimen>]'s optional argument on Inline::LineBreak

The parser has always consumed the [<dimen>] of \\[<dimen>] -- it must
never reach the page as text -- but threw the parsed value away, leaving every
consumer to re-read the brackets out of the source bytes that follow the
node's span.

That re-reading is only correct for a \\ written literally in the document.
Expanded out of a macro body, the node's span is the invocation
(expansion::Converter::place places a replacement-text token at the call
site), so the bytes after it are the call's own arguments -- the {Education}
of \cvsection{Education} -- and the skip is unreachable. latex.ltx's \\ is
\@normalcr, and \@xnewline turns the argument into a \vspace{<dimen>}
after the broken line, so what is lost is real vertical space: in
fixtures/real-world/cv the \\[-6pt] inside \cvsection is worth 5.977 bp
per call, five calls on its single page.

Inline::LineBreak now carries skip_pt: Option<f64>, filled from the
skip_line_break_length() the parser was already calling. The value is
reported, not acted on: the compiler's own fallback layout is untouched, so
this changes no compiler output and no golden.

Wiring it into layout.rs's newline as well is deliberately left out: it
moves a \begin{align} recovery paragraph onto another page and fails
local_recovery::half_typed_input_never_changes_layout_after_its_paragraph,
which is a question for that path's owner, not for this one.

Consumer side: crates/render-pipeline reads the field behind a
linebreak-skip feature (a separate PR), so this change has to reach
crates/render-pipeline/vendor/compiler in a re-pin before that feature can
be turned on. Another lane owns re-pinning today; no vendor file is touched
here.

Test: crates/compiler/tests/line_break_skip.rs (5 cases -- literal, absent,
inside a \newcommand body, two calls of one macro, unit conversion plus the
argument never being typeset). On main the file does not compile:

error[E0026]: variant flashtex_compiler::parser::Inline::LineBreak does
not have a field named skip_pt
--> tests/line_break_skip.rs:41:40

Gates: cargo test --release --no-fail-fast on crates/compiler: 56 test
binaries, 0 failed (local_recovery included).

Implementation-Agent: Claude Opus 5 (lane nixos-cv-lecture, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-Authored-By: Claude Opus 5 [email protected]
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

The parser has always *consumed* the `[<dimen>]` of `\\[<dimen>]` -- it must
never reach the page as text -- but threw the parsed value away, leaving every
consumer to re-read the brackets out of the source bytes that follow the
node's span.

That re-reading is only correct for a `\\` written literally in the document.
Expanded out of a macro body, the node's span is the *invocation*
(`expansion::Converter::place` places a replacement-text token at the call
site), so the bytes after it are the call's own arguments -- the `{Education}`
of `\cvsection{Education}` -- and the skip is unreachable. latex.ltx's `\\` is
`\@normalcr`, and `\@xnewline` turns the argument into a `\vspace{<dimen>}`
after the broken line, so what is lost is real vertical space: in
`fixtures/real-world/cv` the `\\[-6pt]` inside `\cvsection` is worth 5.977 bp
per call, five calls on its single page.

`Inline::LineBreak` now carries `skip_pt: Option<f64>`, filled from the
`skip_line_break_length()` the parser was already calling. The value is
reported, not acted on: the compiler's own fallback layout is untouched, so
this changes no compiler output and no golden.

Wiring it into `layout.rs`'s `newline` as well is deliberately left out: it
moves a `\begin{align}` recovery paragraph onto another page and fails
`local_recovery::half_typed_input_never_changes_layout_after_its_paragraph`,
which is a question for that path's owner, not for this one.

Consumer side: `crates/render-pipeline` reads the field behind a
`linebreak-skip` feature (a separate PR), so this change has to reach
`crates/render-pipeline/vendor/compiler` in a re-pin before that feature can
be turned on. Another lane owns re-pinning today; no vendor file is touched
here.

Test: `crates/compiler/tests/line_break_skip.rs` (5 cases -- literal, absent,
inside a `\newcommand` body, two calls of one macro, unit conversion plus the
argument never being typeset). On main the file does not compile:

  error[E0026]: variant `flashtex_compiler::parser::Inline::LineBreak` does
  not have a field named `skip_pt`
     --> tests/line_break_skip.rs:41:40

Gates: `cargo test --release --no-fail-fast` on `crates/compiler`: 56 test
binaries, 0 failed (`local_recovery` included).

Implementation-Agent: Claude Opus 5 (lane nixos-cv-lecture, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
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.

1 participant