forked from LiveCarta/BookConverter
fix error on book without right TOC
This commit is contained in:
@@ -594,7 +594,6 @@ class Book:
|
||||
|
||||
footnotes.append(content)
|
||||
|
||||
|
||||
self.footnotes = footnotes
|
||||
|
||||
def _process_images(self):
|
||||
@@ -705,6 +704,7 @@ class Book:
|
||||
headers_info = []
|
||||
header_tags = self.body_tag.find_all(re.compile("^h[1-9]$"))
|
||||
headers_outline = [int(re.sub(r"^h", "", tag.name)) for tag in header_tags]
|
||||
if headers_outline:
|
||||
top_level_outline = min(headers_outline)
|
||||
top_level_headers = [tag for tag in header_tags
|
||||
if int(re.sub(r"^h", "", tag.name)) == top_level_outline]
|
||||
@@ -973,6 +973,7 @@ class Book:
|
||||
|
||||
# Add is_introduction field to json structure
|
||||
# after deleting content before toc, some chapters can be deleted
|
||||
if self.top_level_headers:
|
||||
same_first_titles = self.top_level_headers[0]['title'] == json_strc[0]['title']
|
||||
is_first_header_introduction = not self.top_level_headers[0]['should_be_numbered']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user