Keep ancestors in second tree when splitting

EPUB/AZW3 Output: When splitting HTML on page breaks, preserve tag
structure in the split files. This fixes splitting losing some styling
information for HTML files that define page breaks on deeply nested
tags. Fixes #1188768 [fonts change midfile without being ordered to](https://bugs.launchpad.net/calibre/+bug/1188768)
This commit is contained in:
Kovid Goyal 2013-06-08 09:08:11 +05:30
parent 0339c6396e
commit d9635111d2

View File

@ -353,12 +353,19 @@ class FlowSplitter(object):
nix_element(elem) nix_element(elem)
# Tree 2 # Tree 2
ancestors = frozenset(XPath('ancestor::*')(split_point2))
for elem in tuple(body2.iterdescendants()): for elem in tuple(body2.iterdescendants()):
if elem is split_point2: if elem is split_point2:
if not before: if not before:
nix_element(elem) nix_element(elem)
break break
nix_element(elem, top=False) if elem in ancestors:
# We have to preserve the ancestors as they could have CSS
# styles that are inherited/applicable, like font or
# width. So we only remove the text, if any.
elem.text = '\n'
else:
nix_element(elem, top=False)
body2.text = '\n' body2.text = '\n'