Use more robust list de-indentation handler.

This commit is contained in:
Sergio Martínez Portela 2023-04-13 23:56:58 +02:00
parent d67bae645b
commit 7008124509
1 changed files with 14 additions and 11 deletions

View File

@ -457,17 +457,20 @@ class Headline:
current_node = sublist
indentation_tree.append(current_node)
while len(indentation_tree) > 0 and (
(len(indentation_tree[-1].children) > 0)
and len(
[
c
for c in indentation_tree[-1].children
if isinstance(c, dom.ListItem)
][-1].orig.indentation
)
> len(line.indentation)
):
while len(indentation_tree) > 0:
list_children = [
c
for c in indentation_tree[-1].children
if isinstance(c, dom.ListItem)
]
if ((len(list_children) > 0)
and (len(list_children[-1].orig.indentation)
<= len(line.indentation))):
# No more breaking out of lists, it's indentation
# is less than ours
break
rem = indentation_tree.pop(-1)
if len(indentation_tree) == 0:
indentation_tree.append(rem)