From 92d595c00def2332be02a041462976dc1e4a6f50 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 4 Feb 2020 00:18:25 -0800 Subject: [PATCH] Clarify this comment why the two .parent climbs are separate. --- epubfile.py | 4 ++++ 1 file changed, 4 insertions(+) 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