1.1 --- a/moinformat/parsers/moin.py Fri Jul 13 23:59:22 2018 +0200
1.2 +++ b/moinformat/parsers/moin.py Sat Jul 14 13:28:03 2018 +0200
1.3 @@ -216,10 +216,11 @@
1.4 last = region.node(-1)
1.5 new_list = not isinstance(last, (List, ListItem))
1.6
1.7 - # If the marker is different or the indent is smaller, queue the item
1.8 - # and end the list.
1.9 + # If the marker is different and not starting a new list, or the indent
1.10 + # is smaller, queue the item and end the list.
1.11
1.12 - if not new_list and (last.marker != marker or indent < last.indent):
1.13 + if not new_list and (last.marker != marker and indent == last.indent or
1.14 + indent < last.indent):
1.15 self.queue_match()
1.16 self.end_region(region)
1.17
1.18 @@ -228,18 +229,19 @@
1.19 item = ListItem([], indent, marker, space)
1.20 self.parse_region_details(item, self.listitem_pattern_names)
1.21
1.22 - # Start a new list if not preceded by a list item or if the indent is
1.23 - # greater.
1.24 -
1.25 - if new_list or indent > last.indent:
1.26 - item = self.parse_list(item)
1.27 + # Start a new list if not preceded by a list item, adding a trailing
1.28 + # block for new elements.
1.29
1.30 - # Add a new or completed nested list.
1.31 -
1.32 + if new_list:
1.33 + item = self.parse_list(item)
1.34 self.add_node(region, item)
1.35 + self.new_block(region)
1.36
1.37 - if new_list:
1.38 - self.new_block(region)
1.39 + # Add a nested list to the last item.
1.40 +
1.41 + elif indent > last.indent:
1.42 + item = self.parse_list(item)
1.43 + self.add_node(last, item)
1.44
1.45 # Add the item to the current list.
1.46