Fix #2098 (PRS-505 stating "Page Error!" when trying to open an ePub file)

This commit is contained in:
Kovid Goyal 2009-03-18 10:13:53 -07:00
parent 135381e3a0
commit e685f4f79d

View File

@ -139,7 +139,9 @@ class Splitter(LoggingInterface):
split_point, before = self.find_split_point(root)
if split_point is None or self.split_size > 6*self.orig_size:
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)
for t in self.do_split(tree, split_point, before):
@ -150,7 +152,8 @@ class Splitter(LoggingInterface):
if size <= self.opts.profile.flow_size:
self.trees.append(t)
#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
else:
self.split_to_size(t)
@ -332,8 +335,10 @@ class Splitter(LoggingInterface):
'//p',
'//br',
'//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)
if elem is not None:
try: