mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
FB2 Output: Fix error when using the sectionize with toc option and the input documents Table of Contents contains multiple items pointing to the same HTML file. Fixes #1471125 [FB2 conversion failure](https://bugs.launchpad.net/calibre/+bug/1471125)
This commit is contained in:
parent
1ccd546c29
commit
99a26d34c7
@ -264,7 +264,7 @@ class FB2MLizer(object):
|
|||||||
|
|
||||||
# Start a <section> if we must sectionize each file or if the TOC references this page
|
# Start a <section> if we must sectionize each file or if the TOC references this page
|
||||||
page_section_open = False
|
page_section_open = False
|
||||||
if self.opts.sectionize == 'files' or self.toc.get(item.href) == 'page':
|
if self.opts.sectionize == 'files' or None in self.toc.get(item.href, ()):
|
||||||
text.append('<section>')
|
text.append('<section>')
|
||||||
page_section_open = True
|
page_section_open = True
|
||||||
self.section_level += 1
|
self.section_level += 1
|
||||||
@ -322,7 +322,7 @@ class FB2MLizer(object):
|
|||||||
for item in nodes:
|
for item in nodes:
|
||||||
href, mid, id = item.href.partition('#')
|
href, mid, id = item.href.partition('#')
|
||||||
if not id:
|
if not id:
|
||||||
self.toc[href] = 'page'
|
self.toc[href] = {None: 'page'}
|
||||||
else:
|
else:
|
||||||
if not self.toc.get(href, None):
|
if not self.toc.get(href, None):
|
||||||
self.toc[href] = {}
|
self.toc[href] = {}
|
||||||
@ -426,12 +426,13 @@ class FB2MLizer(object):
|
|||||||
# the TOC pointed to a specific element
|
# the TOC pointed to a specific element
|
||||||
newlevel = 0
|
newlevel = 0
|
||||||
toc_entry = self.toc.get(page.href, None)
|
toc_entry = self.toc.get(page.href, None)
|
||||||
if toc_entry == 'page':
|
if toc_entry is not None:
|
||||||
if tag != 'body' and hasattr(elem_tree, 'text') and elem_tree.text:
|
if None in toc_entry:
|
||||||
newlevel = 1
|
if tag != 'body' and hasattr(elem_tree, 'text') and elem_tree.text:
|
||||||
self.toc[page.href] = None
|
newlevel = 1
|
||||||
elif toc_entry and elem_tree.attrib.get('id', None):
|
self.toc[page.href] = None
|
||||||
newlevel = toc_entry.get(elem_tree.attrib.get('id', None), None)
|
if not newlevel and elem_tree.attrib.get('id', None) is not None:
|
||||||
|
newlevel = toc_entry.get(elem_tree.attrib.get('id', None), None)
|
||||||
|
|
||||||
# Start a new section if necessary
|
# Start a new section if necessary
|
||||||
if newlevel:
|
if newlevel:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user