MOBI Output: Have the href of the periodical class TOC node point to the top of the first spine element

This commit is contained in:
Kovid Goyal 2009-07-06 19:39:00 -06:00
parent 4158655b62
commit 01a3782676

View File

@ -76,6 +76,7 @@ class MOBIOutput(OutputFormatPlugin):
from calibre.ebooks.oeb.base import TOC from calibre.ebooks.oeb.base import TOC
toc = self.oeb.toc toc = self.oeb.toc
if toc and toc[0].klass != 'periodical': if toc and toc[0].klass != 'periodical':
start_href = self.oeb.spine[0].href
self.log('Converting TOC for MOBI periodical indexing...') self.log('Converting TOC for MOBI periodical indexing...')
articles = {} articles = {}
if toc.depth < 3: if toc.depth < 3:
@ -92,7 +93,7 @@ class MOBIOutput(OutputFormatPlugin):
a.klass = 'article' a.klass = 'article'
articles[id(sec)].append(a) articles[id(sec)].append(a)
sec.nodes.remove(a) sec.nodes.remove(a)
root = TOC(klass='periodical', root = TOC(klass='periodical', href=start_href,
title=unicode(self.oeb.metadata.title[0])) title=unicode(self.oeb.metadata.title[0]))
for s in sections: for s in sections:
if articles[id(s)]: if articles[id(s)]: