mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #3375 (--max-toc-links option does not seem to work)
This commit is contained in:
parent
707f0ffa0c
commit
3d4e766051
@ -106,6 +106,7 @@ class DetectStructure(object):
|
||||
counter += 1
|
||||
|
||||
def create_toc_from_links(self):
|
||||
num = 0
|
||||
for item in self.oeb.spine:
|
||||
for a in XPath('//h:a[@href]')(item.data):
|
||||
href = a.get('href')
|
||||
@ -120,8 +121,13 @@ class DetectStructure(object):
|
||||
a.xpath('descendant::text()')])
|
||||
text = text[:100].strip()
|
||||
if not self.oeb.toc.has_text(text):
|
||||
num += 1
|
||||
self.oeb.toc.add(text, href,
|
||||
play_order=self.oeb.toc.next_play_order())
|
||||
if self.opts.max_toc_links > 0 and \
|
||||
num >= self.opts.max_toc_links:
|
||||
self.log('Maximum TOC links reached, stopping.')
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user