From 8bddf72400780ab9ac49d8b8adb882176c3e4c9f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 2 Nov 2010 11:00:18 -0600 Subject: [PATCH] MOBI Output: Don't ignore hidden anchors. Fixes #7384 (TOC generation in MOBI not working) --- src/calibre/ebooks/mobi/mobiml.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 0910d10cfb..56930ad2a9 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -275,7 +275,15 @@ class MobiMLizer(object): # does not exist lalalala if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \ or style['visibility'] == 'hidden': - return + id_ = elem.get('id', None) + if id_: + # Keep anchors so people can use display:none + # to generate hidden TOCs + elem.clear() + elem.text = None + elem.set('id', id_) + else: + return tag = barename(elem.tag) istate = copy.copy(istates[-1]) istate.rendered = False