Fix parsing of lists inside drawers.

This commit is contained in:
Sergio Martínez Portela 2022-10-31 21:50:18 +01:00
parent 2748f6400b
commit 5e4a9f8ff2

View File

@ -489,15 +489,26 @@ class Headline:
elif content.strip().upper() == ":END:": elif content.strip().upper() == ":END:":
if current_node is None: if current_node is None:
logging.warning('Finished node (:END:) with no known starter') logging.warning('Finished node (:END:) with no known starter')
elif not (isinstance( else:
current_node, dom.PropertyDrawerNode tree_up = list(tree)
) or isinstance( while len(tree_up) > 0:
current_node, dom.LogbookDrawerNode node = tree_up[-1]
) or isinstance( if (isinstance(
current_node, dom.ResultsDrawerNode node, dom.PropertyDrawerNode
)): ) or isinstance(
raise Exception('Unexpected node: {}'.format(current_node)) node, dom.LogbookDrawerNode
current_node = None ) or isinstance(
node, dom.ResultsDrawerNode
)):
tree = tree_up
current_node = node
break
else:
tree_up.pop(-1)
else:
raise Exception('Unexpected node ({}) on headline (id={}), line {}'.format(current_node, self.id, linenum))
current_node = None
tree.pop()
elif content.strip().upper() == ":RESULTS:": elif content.strip().upper() == ":RESULTS:":
assert current_node is None assert current_node is None
current_node = dom.ResultsDrawerNode() current_node = dom.ResultsDrawerNode()