diff --git a/docs/install.rst b/docs/install.rst index 62d4e8886..e52b8710c 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -488,3 +488,10 @@ to open a `new issue `_. You can also find extra help in this `bug report `_. If you cheated, then, you know: Kittens already died. + + +Other Options for Installation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There is a .NET wrapper for WeasyPrint available `here +`_. diff --git a/weasyprint/document.py b/weasyprint/document.py index f95311b8a..69bbc77c2 100644 --- a/weasyprint/document.py +++ b/weasyprint/document.py @@ -423,7 +423,7 @@ def copy(self, pages='all'): Combine multiple documents into one PDF file, using metadata from the first:: - all_pages = [p for p in doc.pages for doc in documents] + all_pages = [p for doc in documents for p in doc.pages] documents[0].copy(all_pages).write_pdf('combined.pdf') """ @@ -481,7 +481,7 @@ def make_bookmark_tree(self): .. versionadded:: 0.15 :return: A list of bookmark subtrees. - A subtree is ``(label, target, children)``. ``label`` is + A subtree is ``(label, target, children, state)``. ``label`` is a string, ``target`` is ``(page_number, x, y)`` like in :meth:`resolve_links`, and ``children`` is a list of child subtrees. diff --git a/weasyprint/layout/pages.py b/weasyprint/layout/pages.py index 9558858d6..0fdf939fe 100644 --- a/weasyprint/layout/pages.py +++ b/weasyprint/layout/pages.py @@ -715,9 +715,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' diff --git a/weasyprint/tests/test_layout/test_page.py b/weasyprint/tests/test_layout/test_page.py index 5203b8186..e2c2e74b8 100644 --- a/weasyprint/tests/test_layout/test_page.py +++ b/weasyprint/tests/test_layout/test_page.py @@ -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(''' + + abc +

def

+ ''' % (direction, page_break)) + assert len(pages) == pages_number + + @assert_no_logs def test_page_names_1(): pages = render_pages('''