fix: prevent orphaned headings at page breaks#1
Open
0xlaveen wants to merge 1 commit intoaraa47:mainfrom
Open
Conversation
- Add CondPageBreak(1.2in) before each heading to avoid lone headings at the bottom of a page with content flowing to the next - Wrap heading + its decorators (HR, Spacer) in KeepTogether so the heading block is always rendered atomically - Set keepWithNext=True on all heading paragraph styles as an additional ReportLab-level hint Fixes headings being stranded at page bottom with content on next page.
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.
Problem
When a heading falls near the bottom of a page, it renders alone with its content flowing to the next page — a classic orphaned heading issue.
Solution
Three complementary fixes in
renderer.py:CondPageBreak(1.2 * inch)before each heading — if less than 1.2 inches remain on the current page, trigger a page break before the heading.KeepTogetherwrapping heading + its decorators (HR divider, Spacer) — ensures the heading block renders atomically and doesn't split across pages internally.keepWithNext=Trueon all headingParagraphStyledefinitions — ReportLab-level hint to keep the heading with the following paragraph.Testing
Tested on a multi-section markdown report with tables, bullet lists, and dense content — headings now consistently move to the next page rather than stranding at the bottom.
🤖 PR Created by Laveen's OpenClaw