Repository navigation
compiler: flush the preceding paragraph before a run-in heading (GH-768) - #784
Merged
Merged
Conversation
`run_in_heading_command` (`\paragraph`/`\subparagraph`) never called
`flush_paragraph`, on the theory that "a run-in head does not start a new
paragraph" — true, but it still ends whatever paragraph came before it, the
same way real `\@startsection` calls `\par` before laying out the run-in
title. Without the flush, text preceding a `\subparagraph` merged into the
same paragraph as the heading and the text that runs into it.
This matters beyond paragraph counting: `adapter::apply_run_in_heading` in
`crates/render-pipeline` only applies the run-in bold/hskip styling to the
*leading* items of whatever paragraph it is given. If the compiler doesn't
start a fresh paragraph right before the heading, that leading-item scan
can't find the title, so the styling silently fails to apply. Measuring a
real `pdflatex` render of a `\subparagraph` that follows other body text
confirmed this: the title landed on the wrong baseline entirely.
`run_in_heading_command` now takes `blocks`/`para` and calls
`self.flush_paragraph(blocks, para)`, mirroring `section_command`, but still
creates no `Block::Heading` — the braced title still falls through as
ordinary body text at the front of the new paragraph, which is what the
render pipeline's byte-position matching depends on. Updated the two stale
comments that described the old (incomplete) behavior as deliberate. This
fix (the flush call, its call-site change, and both comment updates) is
Muse lane `headings-oracle` slice 2's work, cherry-picked here unmodified.
Added `run_in_heading_flushes_the_preceding_paragraph` (supervisor-authored:
the Muse lane's own check for this slice was an uncommitted `/tmp` probe,
not a regression test), asserting the compiler now produces two separate
`Block::Paragraph`s for `Preceding text.\paragraph{Solution.} Body text.`
(and the `\subparagraph` form) — confirmed this test fails against
unmodified `main` (1 merged paragraph instead of 2) before the fix, and
passes after.
Deliberately out of scope here: a companion `render-pipeline` oracle test
(`headings_run_in_oracle.rs`, real-pdflatex reference glyph positions for
this exact fixture) exists in Muse lane `headings-oracle` but cannot be
verified yet — `crates/render-pipeline/vendor/compiler` is a frozen,
read-only snapshot pinned to `engine/letter-class-compiler` (PR #316) per
`vendor/VENDORING.md`, and this fix isn't in that pin. VENDORING.md already
schedules a re-pin "the moment #316 merges"; that test should be added once
mac-render-pipeline (the pin's owner) does that re-pin, not before. Flagging
to the Commander/mac-render-pipeline separately rather than touching
`vendor/` myself.
Tests: `cargo test --lib` in `crates/compiler` — 413 passed, 0 failed,
including the 1 new test, re-run independently in a fresh worktree from
this exact commit (not just the authoring lane's self-report).
Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane headings-oracle, slice 2 — flush fix and comments only)
Commit-Executor: daniel-muse-lead (Claude Sonnet — also authored the regression test in this commit)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Muse-Lane-Head: 86e4b3e0c644834c3aee21f8005e10b49e375607
Co-authored-by: d-q222 <[email protected]>
Co-authored-by: muse-spark-1.3-contributor <[email protected]>
This was referenced Sep 17, 2026
d-q222
added a commit
that referenced
this pull request
Sep 17, 2026
#784 All eight independently reviewed APPROVE. Batch verification: compiler 935/0, render-pipeline 487/0, perf-bench 14/0, perf gate OK (270 metrics, no regression), swift build --build-tests OK, CompletionTests 29/0. Commit-Executor: daniel-parent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222
added a commit
that referenced
this pull request
Sep 17, 2026
…eset Addresses Commander's CHANGES REQUIRED review on this PR (fresh Codex gpt-5.6-luna review of 406f9f8): 1. `itemize_default_label` captured a `\renewcommand`d marker and parsed it into a full `ItemLabel::Explicit { content, ... }` with rich inline content (bold, math), but `crates/render-pipeline/src/adapter.rs` only ever reads the pre-flattened `label: Option<(String, Span)>` on `CBlock::ListItem` — the styled `content` never reaches the page, so `\renewcommand{\labelitemi}{\textbf{X}}` silently rendered plain "X" and `{$\star$}` lost its math entirely, while this PR's own tests claimed the rich content was supported. Scoped down rather than propagated through render-pipeline (the review's other option): that crate builds against a separate, frozen vendored snapshot of this compiler (`crates/render-pipeline/vendor/ VENDORING.md`) that a parser-only PR branch can't usefully reach or test — the same class of blocker already hit on #784/#713. Instead, `itemize_default_label` still re-lexes and parses the override body (so an unsupported command inside it still gets the usual running-text diagnostic), but now keeps only its plain-text fallback as a single unstyled `Inline::Text` — an honest degradation, not silent dropping. Renamed and rewrote the two rich-content tests (`labelitem_override_textbf_body_degrades_to_plain_text`, `labelitem_override_math_body_degrades_to_empty_plain_text`) to assert the new behavior; kept plain-text-override coverage unchanged. 2. Per-item override timing (`\renewcommand` mid-list is not picked up after `\begin{itemize}`) is explicitly left unfixed, per the review's own "worth tracking as a known-gap follow-up if not fixed here" — the existing doc comment already states this limitation clearly, confirmed and left as-is. 3. `labelitem_inline`'s default-marker style reset only cleared `italic`, leaving `slanted`/`small_caps` inherited from the surrounding style even though real `\normalfont` resets the whole shape axis (`\slshape\labelitemii` kept the slanted shape instead of article's upright bold marker). Now also resets `slanted: false, small_caps: false`. Added `labelitem_command_resets_the_whole_shape_axis` (checks both `\slshape` and `\scshape`). Tests: `cargo test --lib` in `crates/compiler`: 412 passed, 0 failed (unchanged — no lib-level test count change). `list_structure`: 24 passed, 0 failed (23 + 1 new, 2 renamed). `expansion_incremental`: 10 passed, 0 failed (unchanged). All independently re-run in this exact worktree from this commit, not just the authoring lane's self-report. No `crates/render-pipeline` file touched. Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane list-labels-fix, slice 1) Commit-Executor: daniel-muse-lead (Claude Sonnet — the lane's sandbox could not reach this worktree's git metadata to commit itself; verified and committed the lane's working-tree diff directly, unmodified) Reviewed-by: daniel-parent (Claude Sonnet 5, triage) — addresses that review
ItsAkilesh
pushed a commit
to ItsAkilesh/flashtex
that referenced
this pull request
Sep 18, 2026
…ain 8a8a22b, vendor bibliography compiler c95977d -> 8a8a22b (51 compiler commits, incl. flash-tex#784 run-in heading flush, flash-tex#756/flash-tex#759 math spacing in macro bodies); tex-expansion 87a513d -> 8a8a22b in lockstep; new vendor/bibliography (the compiler now depends on it). Copied with git archive; no local patches existed (old vendor/compiler differed from c95977d only in PIN). Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.
Half of #768's remaining work: this is the compiler-side bug found while
building a headings oracle test (the other half of #768), not the oracle
test itself.
What was wrong
run_in_heading_command(\paragraph/\subparagraph) never calledflush_paragraph. A stale comment claimed this was deliberate ("a run-inhead does not start a new paragraph") — true, but it still ends whatever
paragraph came before it, the same way real
\@startsectioncalls\parbefore laying out the run-in title. Without the flush, text preceding a
\subparagraphsilently merged into the same paragraph as the heading andthe text that runs into it.
This isn't cosmetic:
adapter::apply_run_in_headingincrates/render-pipelineonly styles the leading items of whateverparagraph it's handed. Measuring a real
pdflatexrender of a\subparagraphthat follows other body text confirmed the title landed onthe wrong baseline entirely, because the compiler never started the fresh
paragraph the render pipeline's styling logic depends on.
The fix
run_in_heading_commandnow takesblocks/paraand callsself.flush_paragraph(blocks, para), mirroringsection_command. It stillcreates no
Block::Heading— the braced title falls through as ordinarybody text at the front of the new paragraph, exactly as before. Updated the
two stale comments.
New test
run_in_heading_flushes_the_preceding_paragraph: confirmed itfails against unmodified
main(1 merged paragraph instead of 2) beforethis fix, passes after.
Deliberately out of scope
A companion
render-pipelineoracle test (real-pdflatexreference glyphpositions for a
\paragraph/\subparagraphfixture) exists but can't bewired up yet:
crates/render-pipeline/vendor/compileris a frozen,read-only snapshot pinned to
engine/letter-class-compiler(PR #316,per
vendor/VENDORING.md), and this fix isn't in that pin.vendor/VENDORING.mdalready schedules a re-pin "the moment #316 merges" —that oracle test should land once
mac-render-pipeline(the pin's owner)does that re-pin, not before. Not touching
vendor/here.Tests
cargo test --libincrates/compiler: 413 passed, 0 failed (1 new test),independently re-run from this exact commit in a fresh worktree.
Provenance
Muse lane
headings-oracle(muse-spark-1.3-contributor) slice 2 wrote theflush fix and comment updates; I (daniel-muse-lead) wrote the regression
test (the lane's own verification was an uncommitted
/tmpprobe, not acommitted test) and reviewed/independently re-ran everything before
publishing. Full trailers in the commit.
🤖 Generated with Claude Code