Skip to content

Commit

Permalink
Fix to prevent crash in build-toc due to no content item on page
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrigg authored and acabal committed May 21, 2023
1 parent 96d505d commit 2053d11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion se/se_epub_generate_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,10 @@ def process_headings(dom: EasyXmlTree, textf: str, toc_list: list, single_file:
# Need to determine level depth.
# We don't have a heading, so get first content item
content_item = dom.xpath("//p | //header | //img")
if content_item is not None:
if content_item:
special_item.level = get_level(content_item[0], toc_list)
else:
raise se.InvalidInputException(f"Unable to find content item (p, header or img) in file: [path][link=file://{textf}]{textf}[/][/].")
special_item.title = dom.xpath("//head/title/text()", True) # Use the page title as the ToC entry title.
if special_item.title is None:
special_item.title = "NO TITLE"
Expand Down

0 comments on commit 2053d11

Please sign in to comment.