Skip to content
Permalink
Browse files

Handle recto/verso on page break.

  • Loading branch information...
grewn0uille committed Jul 18, 2019
1 parent 204e719 commit 135dc06c9a75ce2d74ce533391ec89d314932d75
Showing with 33 additions and 3 deletions.
  1. +10 −3 weasyprint/layout/pages.py
  2. +23 −0 weasyprint/tests/test_layout/test_page.py
@@ -716,9 +716,16 @@ def remake_page(index, context, root_box, html, style_for):
page_state = copy.deepcopy(initial_page_state)
next_page_name = initial_next_page['page']
first = index == 0
# TODO: handle recto/verso and add test
blank = ((initial_next_page['break'] == 'left' and right_page) or
(initial_next_page['break'] == 'right' and not right_page))
if initial_next_page['break'] in ('left', 'right'):
next_page_side = initial_next_page['break']
elif initial_next_page['break'] in ('recto', 'verso'):
direction_ltr = root_box.style['direction'] == 'ltr'
break_verso = initial_next_page['break'] == 'verso'
next_page_side = 'right' if direction_ltr ^ break_verso else 'left'
else:
next_page_side = None
blank = ((next_page_side == 'left' and right_page) or
(next_page_side == 'right' and not right_page))
if blank:
next_page_name = ''
side = 'right' if right_page else 'left'
@@ -497,6 +497,29 @@ def test_margin_break_clearance():
assert div_2.content_box_y() == 5


@assert_no_logs
@pytest.mark.parametrize('direction, page_break, pages_number', (
('ltr', 'recto', 3),
('ltr', 'verso', 2),
('rtl', 'recto', 3),
('rtl', 'verso', 2),
('ltr', 'right', 3),
('ltr', 'left', 2),
('rtl', 'right', 2),
('rtl', 'left', 3),
))
def test_recto_verso_break(direction, page_break, pages_number):
pages = render_pages('''
<style>
html { direction: %s }
p { break-before: %s }
</style>
abc
<p>def</p>
''' % (direction, page_break))
assert len(pages) == pages_number


@assert_no_logs
def test_page_names_1():
pages = render_pages('''

0 comments on commit 135dc06

Please sign in to comment.
You can’t perform that action at this time.