MOBI Output: When converting an input document that specifies an inline TOC in the <guide> but not in the <spine> add it correctly. Fixes #6661 (Conversion to MOBI fails to create TOC)

This commit is contained in:
Kovid Goyal 2010-09-02 07:48:45 -06:00
parent a2f46d86af
commit 3a4ac4663b

View File

@ -62,7 +62,16 @@ class HTMLTOCAdder(object):
def __call__(self, oeb, context): def __call__(self, oeb, context):
if 'toc' in oeb.guide: if 'toc' in oeb.guide:
return # Ensure toc pointed to in <guide> is in spine
from calibre.ebooks.oeb.base import urlnormalize
href = urlnormalize(oeb.guide['toc'].href)
if href in oeb.manifest.hrefs:
item = oeb.manifest.hrefs[href]
if oeb.spine.index(item) < 0:
oeb.spine.add(item, linear=False)
return
else:
oeb.guide.remove('toc')
if not getattr(getattr(oeb, 'toc', False), 'nodes', False): if not getattr(getattr(oeb, 'toc', False), 'nodes', False):
return return
oeb.logger.info('Generating in-line TOC...') oeb.logger.info('Generating in-line TOC...')