Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to build-toc to address issue #628 #629

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions se/se_epub_generate_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,6 @@ def evaluate_descendants(node: EasyXmlElement, toc_item: TocItem, textf: str) ->
"""
children = node.xpath("./p | ./h1 | ./h2 | ./h3 | ./h4 | ./h5 | ./h6")
for child in children: # we expect these to be h1, h2, h3, h4 etc
if not toc_item.lang:
toc_item.lang = child.get_attr("xml:lang")
epub_type = child.get_attr("epub:type")

if child.get_attr("hidden"):
Expand Down Expand Up @@ -635,9 +633,14 @@ def evaluate_descendants(node: EasyXmlElement, toc_item: TocItem, textf: str) ->
if "title" in epub_type: # this allows for `fulltitle` to work here, too
if toc_item.title or toc_item.roman or toc_item.title_is_ordinal: # if title already filled, must be a subtitle
toc_item.subtitle = extract_strings(child)
if toc_item.roman or toc_item.title_is_ordinal: # in these cases, we want to check language on subtitle
toc_item.lang = child.get_attr("xml:lang")
else:
toc_item.title = extract_strings(child)
if toc_item.title and toc_item.subtitle: # then we're done
if not toc_item.lang:
toc_item.lang = child.get_attr("xml:lang")

if toc_item.title and toc_item.subtitle: # then we're done, get out of loop by returning
return toc_item
return toc_item

Expand Down