From 6c78ae210595f6d60ff4a85310301a0ceacf2131 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 8 Jul 2019 17:33:06 +0530 Subject: [PATCH] Nicer page break insertion --- src/calibre/ebooks/oeb/polish/split.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/split.py b/src/calibre/ebooks/oeb/polish/split.py index 1ccf5d288b..0102e774ca 100644 --- a/src/calibre/ebooks/oeb/polish/split.py +++ b/src/calibre/ebooks/oeb/polish/split.py @@ -420,6 +420,9 @@ def merge_html(container, names, master, insert_page_breaks=False): first_child.set('id', unique_anchor(seen_anchors, 'top')) seen_anchors.add(first_child.get('id')) + if insert_page_breaks: + first_child.set('style', first_child.get('style', '') + '; page-break-before: always') + amap[''] = first_child.get('id') # Fix links that point to local changed anchors @@ -428,9 +431,6 @@ def merge_html(container, names, master, insert_page_breaks=False): if q in amap: a.set('href', '#' + amap[q]) - if insert_page_breaks: - master_body.append(master_body.makeelement(XHTML('div'), style='page-break-after:always')) - for child in children: if isinstance(child, string_or_bytes): add_text(master_body, child)