Keep tables that fit on a single page intact

This commit is contained in:
gloamxun committed 2026-10-20 01:30:22 +08:00
1 parent 9ae7353376
commit d248a84764
1 file changed
+10
+10
View File
@@ -3016,6 +3016,16 @@ pub(super) fn build_positioned_pages(
continue;
}
// Keep a table that fits on one page intact instead of
// splitting its rows at the bottom of the current page.
if table_height > 0 && total_height <= page_goal.saturating_sub(top_skip) {
let page_nonempty = pages.last().is_some_and(|page| !page.items.is_empty());
if page_nonempty && cursor.saturating_add(total_height) > page_goal {
pages.push(PositionedPage::default());
cursor = top_skip;
}
}
let mut line_index = 0;
let mut has_caption_lines = false;
for line in caption_lines {