Nicer page break insertion

This commit is contained in:
Kovid Goyal 2019-07-08 17:33:06 +05:30
parent 87b86d86a8
commit 6c78ae2105
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -420,6 +420,9 @@ def merge_html(container, names, master, insert_page_breaks=False):
first_child.set('id', unique_anchor(seen_anchors, 'top')) first_child.set('id', unique_anchor(seen_anchors, 'top'))
seen_anchors.add(first_child.get('id')) 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') amap[''] = first_child.get('id')
# Fix links that point to local changed anchors # 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: if q in amap:
a.set('href', '#' + amap[q]) 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: for child in children:
if isinstance(child, string_or_bytes): if isinstance(child, string_or_bytes):
add_text(master_body, child) add_text(master_body, child)