Skip to content

Commit

Permalink
Control on the spine should now be more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
pauliyobo committed Jan 29, 2024
1 parent 1e7c655 commit 6314cad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bookworm/document/formats/epub.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ def epub_html_items(self) -> tuple[str]:
# However this poses a problem when the chapters do not follow a conventional numeric scheme but rather use something like roman numbers
# As reported in issue 243
# We will now sort the items obtained earlier based on the position that the chapter itself occupies in the TOC
spine = [x[0] for x in self.epub.spine]
spine = [x[0].split('/')[-1] for x in self.epub.spine]
log.info(spine)
try:
items = sorted(items, key=lambda x: spine.index(x.file_name.split('/')[-1]))
items = sorted(items, key=lambda x: spine.index(x.id))
except ValueError:
log.warn(
'Failed to order chapters based on the table of content. Order may be inconsistent'
Expand Down

0 comments on commit 6314cad

Please sign in to comment.