From 3a4ac4663befd39598385c771d25e14e6ba648b5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Sep 2010 07:48:45 -0600 Subject: [PATCH] MOBI Output: When converting an input document that specifies an inline TOC in the but not in the add it correctly. Fixes #6661 (Conversion to MOBI fails to create TOC) --- src/calibre/ebooks/oeb/transforms/htmltoc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/transforms/htmltoc.py b/src/calibre/ebooks/oeb/transforms/htmltoc.py index 1aef7e56cc..b570420756 100644 --- a/src/calibre/ebooks/oeb/transforms/htmltoc.py +++ b/src/calibre/ebooks/oeb/transforms/htmltoc.py @@ -62,7 +62,16 @@ class HTMLTOCAdder(object): def __call__(self, oeb, context): if 'toc' in oeb.guide: - return + # Ensure toc pointed to in 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): return oeb.logger.info('Generating in-line TOC...')