mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Output: Fix splitting of large HTML files removing all child tags from inside <pre> tags. Fixes #1267327 [Private bug](https://bugs.launchpad.net/calibre/+bug/1267327)
This commit is contained in:
parent
de49923947
commit
901f54e124
@ -317,13 +317,11 @@ class FlowSplitter(object):
|
||||
def split_to_size(self, tree):
|
||||
self.log.debug('\t\tSplitting...')
|
||||
root = tree.getroot()
|
||||
# Split large <pre> tags
|
||||
for pre in list(XPath('//h:pre')(root)):
|
||||
text = u''.join(pre.xpath('descendant::text()'))
|
||||
pre.text = text
|
||||
for child in list(pre.iterchildren()):
|
||||
pre.remove(child)
|
||||
if len(pre.text) > self.max_flow_size*0.5:
|
||||
# Split large <pre> tags if they contain only text
|
||||
for pre in XPath('//h:pre')(root):
|
||||
if len(tuple(pre.iterchildren(etree.Element))) > 0:
|
||||
continue
|
||||
if pre.text and len(pre.text) > self.max_flow_size*0.5:
|
||||
self.log.debug('\t\tSplitting large <pre> tag')
|
||||
frags = self.split_text(pre.text, root, int(0.2*self.max_flow_size))
|
||||
new_pres = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user