From 08f38df9b9b3f63ba6c652ce09fb184154210e8f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Aug 2012 10:41:48 +0530 Subject: [PATCH] MOBI Output: Fix ToC at start option having no effect when converting some input documents that have an out-of-spine ToC. Fixes #1033656 (Table of Contents not in Front after converting) --- src/calibre/ebooks/oeb/transforms/htmltoc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/transforms/htmltoc.py b/src/calibre/ebooks/oeb/transforms/htmltoc.py index 26b2ccf41c..0e1b2b5f10 100644 --- a/src/calibre/ebooks/oeb/transforms/htmltoc.py +++ b/src/calibre/ebooks/oeb/transforms/htmltoc.py @@ -73,7 +73,10 @@ class HTMLTOCAdder(object): if (hasattr(item.data, 'xpath') and XPath('//h:a[@href]')(item.data)): if oeb.spine.index(item) < 0: - oeb.spine.add(item, linear=False) + if self.position == 'end': + oeb.spine.add(item, linear=False) + else: + oeb.spine.insert(0, item, linear=True) return elif has_toc: oeb.guide.remove('toc')