Rudimentary support for page-break-after: avoid. May have broken other things.

This commit is contained in:
Kovid Goyal 2008-03-12 20:26:14 +00:00
parent 1bbab6f266
commit 756de168fe

View File

@ -500,6 +500,24 @@ class HTMLConverter(object):
self.book.append(self.current_page) self.book.append(self.current_page)
self.current_page = None self.current_page = None
if not top.has_text() and top.parent.contents.index(top) == len(top.parent.contents)-1:
top.parent.contents.remove(top)
opage = top.parent
if self.book.last_page() is opage:
if self.current_page and self.current_page.has_text():
for c in self.current_page.contents:
if isinstance(c, (TextBlock, ImageBlock)):
return c
raise ConversionError(_('Could not parse file: %s')%self.file_name)
else:
index = self.book.pages().index(opage)
for page in list(self.book.pages()[index+1:]):
for c in page.contents:
if isinstance(c, (TextBlock, ImageBlock)):
return c
raise ConversionError(_('Could not parse file: %s')%self.file_name)
return top return top
def create_link(self, children, tag): def create_link(self, children, tag):
@ -1381,7 +1399,7 @@ class HTMLConverter(object):
self.targets[self.target_prefix+tag[key]] = self.current_block self.targets[self.target_prefix+tag[key]] = self.current_block
self.current_block.must_append = True self.current_block.must_append = True
else: else:
self.logger.warn('Could not follow link to '+tag['href']) self.logger.debug('Could not follow link to '+tag['href'])
self.process_children(tag, tag_css, tag_pseudo_css) self.process_children(tag, tag_css, tag_pseudo_css)
elif tag.has_key('name') or tag.has_key('id'): elif tag.has_key('name') or tag.has_key('id'):
self.process_anchor(tag, tag_css, tag_pseudo_css) self.process_anchor(tag, tag_css, tag_pseudo_css)