diff --git a/epubfile.py b/epubfile.py index ba11b2e..37908f0 100644 --- a/epubfile.py +++ b/epubfile.py @@ -1062,6 +1062,10 @@ class Epub: current_level -= 1 # Because the sub-
    are actually a child of the last #
  1. of the previous
      , we must .parent twice. + # The second .parent is conditional because if the current + # list is toc.ol, then parent is a Soup document object, and + # parenting again would be a mistake. We'll recover from + # this in just a moment. current_list = current_list.parent if current_list.name == 'li': current_list = current_list.parent