From 11385a68dcb7544da87357d8b27ea9fdf7d89e3b Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 23 May 2026 14:53:16 +0800 Subject: [PATCH] feat: force page break after heading blocks for clean chapter layout --- src/reader.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/reader.rs b/src/reader.rs index ea20b47..3b086a7 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -180,6 +180,12 @@ pub fn recalculate_pages( } else { current_height += needed; } + + if block.heading_level >= 1 && i + 1 < section.blocks.len() { + page_block_ranges.push((page_start_block, i + 1)); + page_start_block = i + 1; + current_height = 0.0; + } } if page_start_block < section.blocks.len() {