mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2781 (Failed to generate index)
This commit is contained in:
parent
01a3782676
commit
5c5d37ee1a
@ -1953,6 +1953,8 @@ class MobiWriter(object):
|
|||||||
first = False
|
first = False
|
||||||
else :
|
else :
|
||||||
self._oeb.logger.info('Generating flat CTOC ...')
|
self._oeb.logger.info('Generating flat CTOC ...')
|
||||||
|
previousOffset = -1
|
||||||
|
currentOffset = 0
|
||||||
for (i, child) in enumerate(toc.iter()):
|
for (i, child) in enumerate(toc.iter()):
|
||||||
# Only add chapters or articles at depth==1
|
# Only add chapters or articles at depth==1
|
||||||
# no class defaults to 'chapter'
|
# no class defaults to 'chapter'
|
||||||
@ -1961,8 +1963,20 @@ class MobiWriter(object):
|
|||||||
if self.opts.verbose > 2 :
|
if self.opts.verbose > 2 :
|
||||||
self._oeb.logger.info("adding (klass:%s depth:%d) %s to flat ctoc" % \
|
self._oeb.logger.info("adding (klass:%s depth:%d) %s to flat ctoc" % \
|
||||||
(child.klass, child.depth(), child) )
|
(child.klass, child.depth(), child) )
|
||||||
self._add_flat_ctoc_node(child, ctoc)
|
|
||||||
reduced_toc.append(child)
|
# Test to see if this child's offset is the same as the previous child's
|
||||||
|
# offset, skip it
|
||||||
|
h = child.href
|
||||||
|
currentOffset = self._id_offsets[h]
|
||||||
|
# print "_generate_ctoc: child offset: 0x%X" % currentOffset
|
||||||
|
|
||||||
|
if currentOffset != previousOffset :
|
||||||
|
self._add_flat_ctoc_node(child, ctoc)
|
||||||
|
reduced_toc.append(child)
|
||||||
|
previousOffset = currentOffset
|
||||||
|
else :
|
||||||
|
self._oeb.logger.warn("ignoring redundant href: %s in '%s'" % (h, child.title))
|
||||||
|
|
||||||
first = False
|
first = False
|
||||||
else :
|
else :
|
||||||
if self.opts.verbose > 2 :
|
if self.opts.verbose > 2 :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user