mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2098 (PRS-505 stating "Page Error!" when trying to open an ePub file)
This commit is contained in:
parent
135381e3a0
commit
e685f4f79d
@ -139,7 +139,9 @@ class Splitter(LoggingInterface):
|
|||||||
split_point, before = self.find_split_point(root)
|
split_point, before = self.find_split_point(root)
|
||||||
if split_point is None or self.split_size > 6*self.orig_size:
|
if split_point is None or self.split_size > 6*self.orig_size:
|
||||||
if not self.always_remove:
|
if not self.always_remove:
|
||||||
self.log_warn(_('\t\tToo much markup. Re-splitting without structure preservation. This may cause incorrect rendering.'))
|
self.log_warn(_('\t\tToo much markup. Re-splitting without '
|
||||||
|
'structure preservation. This may cause '
|
||||||
|
'incorrect rendering.'))
|
||||||
raise SplitError(self.path, root)
|
raise SplitError(self.path, root)
|
||||||
|
|
||||||
for t in self.do_split(tree, split_point, before):
|
for t in self.do_split(tree, split_point, before):
|
||||||
@ -150,7 +152,8 @@ class Splitter(LoggingInterface):
|
|||||||
if size <= self.opts.profile.flow_size:
|
if size <= self.opts.profile.flow_size:
|
||||||
self.trees.append(t)
|
self.trees.append(t)
|
||||||
#print tostring(t.getroot(), pretty_print=True)
|
#print tostring(t.getroot(), pretty_print=True)
|
||||||
self.log_debug('\t\t\tCommitted sub-tree #%d (%d KB)', len(self.trees), size/1024.)
|
self.log_debug('\t\t\tCommitted sub-tree #%d (%d KB)',
|
||||||
|
len(self.trees), size/1024.)
|
||||||
self.split_size += size
|
self.split_size += size
|
||||||
else:
|
else:
|
||||||
self.split_to_size(t)
|
self.split_to_size(t)
|
||||||
@ -332,8 +335,10 @@ class Splitter(LoggingInterface):
|
|||||||
'//p',
|
'//p',
|
||||||
'//br',
|
'//br',
|
||||||
'//li',
|
'//li',
|
||||||
|
'//div',
|
||||||
):
|
):
|
||||||
elems = root.xpath(path, namespaces={'re':'http://exslt.org/regular-expressions'})
|
elems = root.xpath(path,
|
||||||
|
namespaces={'re':'http://exslt.org/regular-expressions'})
|
||||||
elem = pick_elem(elems)
|
elem = pick_elem(elems)
|
||||||
if elem is not None:
|
if elem is not None:
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user