PDF Input: Fix conversion of multi-level PDF Outline causing duplicate entries in the Table of Contents. Fixes #1738385 [Duplicated ToC entries in PDF to any format conversion](https://bugs.launchpad.net/calibre/+bug/1738385)

This commit is contained in:
Kovid Goyal 2018-01-04 20:02:29 +05:30
parent 49ad73ae40
commit 848b3d166e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -140,13 +140,13 @@ def parse_outline(raw, output_dir):
count = [0]
def process_node(node, toc):
for child in node.iterdescendants('*'):
for child in node.iterchildren('*'):
if child.tag == 'outline':
parent = toc.children[-1] if toc.children else toc
process_node(child, parent)
else:
page = child.get('page', '1')
toc.add(child.text, 'index.html', 'p' + page)
toc.add(child.text or '', 'index.html', 'p' + page)
count[0] += 1
process_node(outline, toc)
if count[0] > 2: