Skip to content

Commit

Permalink
Try to break pages after a block before trying to break inside it
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Aug 18, 2017
1 parent 9556781 commit bb3a4db
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions weasyprint/layout/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,16 @@ def find_earlier_page_break(children, absolute_boxes, fixed_boxes):

previous_in_flow = None
for index, child in reversed_enumerate(children):
if child.is_in_normal_flow():
if previous_in_flow is not None and (
block_level_page_break(child, previous_in_flow) not in
('avoid', 'avoid-page')):
index += 1 # break after child
new_children = children[:index]
# Get the index in the original parent
resume_at = (children[index].index, None)
break
previous_in_flow = child
if child.is_in_normal_flow() and (
child.style.break_inside not in ('avoid', 'avoid-page')):
if isinstance(child, boxes.BlockBox):
Expand All @@ -870,16 +880,6 @@ def find_earlier_page_break(children, absolute_boxes, fixed_boxes):
break
elif isinstance(child, boxes.TableBox):
pass # TODO: find an earlier break between table rows.
if child.is_in_normal_flow():
if previous_in_flow is not None and (
block_level_page_break(child, previous_in_flow) not in
('avoid', 'avoid-page')):
index += 1 # break after child
new_children = children[:index]
# Get the index in the original parent
resume_at = (children[index].index, None)
break
previous_in_flow = child
else:
return None

Expand Down

0 comments on commit bb3a4db

Please sign in to comment.