TXT Output: Fix inline toc not showing all items.

This commit is contained in:
John Schember 2011-02-05 11:02:00 -05:00
parent ed2b94ac9d
commit deee20d8f8

View File

@ -55,6 +55,7 @@ class TXTMLizer(object):
self.log.info('Converting XHTML to TXT...') self.log.info('Converting XHTML to TXT...')
self.oeb_book = oeb_book self.oeb_book = oeb_book
self.opts = opts self.opts = opts
self.toc_titles = []
self.toc_ids = [] self.toc_ids = []
self.last_was_heading = False self.last_was_heading = False
@ -94,8 +95,8 @@ class TXTMLizer(object):
if getattr(self.opts, 'inline_toc', None): if getattr(self.opts, 'inline_toc', None):
self.log.debug('Generating table of contents...') self.log.debug('Generating table of contents...')
toc.append(u'%s\n\n' % _(u'Table of Contents:')) toc.append(u'%s\n\n' % _(u'Table of Contents:'))
for item in self.oeb_book.toc: for item in self.toc_titles:
toc.append(u'* %s\n\n' % item.title) toc.append(u'* %s\n\n' % item)
return ''.join(toc) return ''.join(toc)
def create_flat_toc(self, nodes): def create_flat_toc(self, nodes):
@ -103,6 +104,7 @@ class TXTMLizer(object):
Turns a hierarchical list of TOC href's into a flat list. Turns a hierarchical list of TOC href's into a flat list.
''' '''
for item in nodes: for item in nodes:
self.toc_titles.append(item.title)
self.toc_ids.append(item.href) self.toc_ids.append(item.href)
self.create_flat_toc(item.nodes) self.create_flat_toc(item.nodes)