Skip to content

Commit bb3a4db

Browse files
committed
Try to break pages after a block before trying to break inside it
1 parent 9556781 commit bb3a4db

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

weasyprint/layout/blocks.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,16 @@ def find_earlier_page_break(children, absolute_boxes, fixed_boxes):
855855

856856
previous_in_flow = None
857857
for index, child in reversed_enumerate(children):
858+
if child.is_in_normal_flow():
859+
if previous_in_flow is not None and (
860+
block_level_page_break(child, previous_in_flow) not in
861+
('avoid', 'avoid-page')):
862+
index += 1 # break after child
863+
new_children = children[:index]
864+
# Get the index in the original parent
865+
resume_at = (children[index].index, None)
866+
break
867+
previous_in_flow = child
858868
if child.is_in_normal_flow() and (
859869
child.style.break_inside not in ('avoid', 'avoid-page')):
860870
if isinstance(child, boxes.BlockBox):
@@ -870,16 +880,6 @@ def find_earlier_page_break(children, absolute_boxes, fixed_boxes):
870880
break
871881
elif isinstance(child, boxes.TableBox):
872882
pass # TODO: find an earlier break between table rows.
873-
if child.is_in_normal_flow():
874-
if previous_in_flow is not None and (
875-
block_level_page_break(child, previous_in_flow) not in
876-
('avoid', 'avoid-page')):
877-
index += 1 # break after child
878-
new_children = children[:index]
879-
# Get the index in the original parent
880-
resume_at = (children[index].index, None)
881-
break
882-
previous_in_flow = child
883883
else:
884884
return None
885885

0 commit comments

Comments
 (0)