Skip to content

compiler: accept \pagestyle/\thispagestyle/\pagenumbering in the preamble - #353

Closed
d-q222 wants to merge 1 commit into
mainfrom
agent/daniel-muse-lead/pagestyle-preamble
Closed

d-q222 wants to merge 1 commit into
mainfrom
agent/daniel-muse-lead/pagestyle-preamble

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

daniel-muse-lead — Muse Contributor lane pagestyle-preamble, slice 1.

Fixes fixtures/divergence-probes/min2-pagestyle from #258: \pagestyle{empty} in the document preamble was rejected (\pagestyle is not supported in the document preamble) even though the identical command already works, as an honest no-op, inside the document body.

Root cause: a preamble catch-all guard in crates/compiler/src/parser.rs (_ if self.has_document && !self.in_body => self.unsupported_preamble(...)) was positioned, in Rust match-arm order, before the specific (and already-correct) arms for "pagestyle", "thispagestyle", and "pagenumbering". In preamble context the wildcard always won first, making those three arms unreachable dead code there — while working fine in the body, where the guard's condition is false.

Fix: move the three arms above the guard. Arm bodies are byte-identical, only position changed. No other arm touched.

Added pagestyle_commands_are_accepted_in_the_preamble, parsing all three commands genuinely between \documentclass and \begin{document} and asserting zero diagnostics.

Gate: cargo test --lib in crates/compiler: 300 passed, 0 failed — re-run independently by me on the exact commit, not just taken from the implementer's self-report.

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane pagestyle-preamble, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)

🤖 Generated with Claude Code

…mble

These three commands were already handled correctly in the document body
(honest no-ops, since no header/footer or displayed-page-number rendering
exists yet), but a preamble catch-all guard was positioned before their
match arms in the same `match` statement, so in preamble context (before
`\begin{document}`) they were unconditionally rejected as unsupported
instead of ever reaching their own arms. Moved the three arms above the
guard; arm bodies are unchanged. Added a regression test parsing all three
commands genuinely in the preamble and asserting no diagnostics.

Found via fixtures/divergence-probes/min2-pagestyle (#258), which measured
`\pagestyle{empty}` in the preamble as rejected against pdfLaTeX.

Tests: cargo test --lib in crates/compiler: 300 passed, 0 failed (verified
independently by the reviewer, not just the implementer's self-report).

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane pagestyle-preamble, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Muse-Lane-Head: af408968de0c36bb98d7463ca37be1a316c9b6f5
Co-authored-by: d-q222 <[email protected]>
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