The running head skips the page the chapter opens on - #30
Merged
Conversation
Since #20 a chapter's title ran top-centre on every page of that chapter, including the chapter's own opening page -- where the title is already set two inches below in 1.8em, and where book typography conventionally drops the running head. #29 recorded this as a limitation on the grounds that named page groups cannot express it, and that part was right. WeasyPrint reads `:first` as the first page of the document rather than of the page group, so `@page chapter:first` suppresses only the very first chapter's opener. Alternating the names between chapters, which should have broken the grouping, does not help either -- verified on 69.0, where four chapters given alternating names still print their titles on openers two, three and four. The mechanism that does work is not page groups at all. CSS Paged Media gives `string()` a second argument for exactly this case: `first-except` yields the empty string on the page where the string was set, and the set happens on the chapter's own opening page. One keyword, no named pages, no alternating classes, and continuation pages are untouched. Verified across the four books in the series: 67 chapter and appendix openers, none carrying a running head, and 328 continuation pages that still do. Closes #29. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #29.
Since #20 a chapter's title ran top-centre on every page of that chapter — including the chapter's own opening page, where the title is already set two inches below in 1.8em, and where book typography conventionally drops the running head.
#29 recorded this as a limitation because named page groups cannot express it, and that part was right. WeasyPrint reads
:firstas the first page of the document rather than of the group, so@page chapter:firstsuppresses only the very first chapter's opener. Alternating the names between chapters — which should have broken the grouping — does not help either. Verified on 69.0 with four chapters given alternating names:Openers two, three and four still print.
The mechanism that works is not page groups at all. CSS Paged Media gives
string()a second argument for exactly this case —first-exceptyields the empty string on the page where the string was set, and the set happens on the chapter's own opening page:One keyword. No named pages, no alternating classes, continuation pages untouched.
Verified across all four books in the series — 67 chapter and appendix openers, none carrying a running head; 328 continuation pages that still do:
144 tests pass, ruff clean, 4 import contracts kept. The new test pins the keyword itself, since the behaviour rests entirely on it and a well-meaning simplification back to
string(chaptertitle)would silently restore the bug.🤖 Generated with Claude Code