diff --git a/djot_parser/djot_ast.go b/djot_parser/djot_ast.go index 5eba8e4..329109b 100644 --- a/djot_parser/djot_ast.go +++ b/djot_parser/djot_ast.go @@ -444,11 +444,12 @@ func buildDjotAst( footnotes := make([]TreeNode[DjotNode], 0) groupElementsPop := make(map[int]int) + groupElementsInsert := make(map[int]*TreeNode[DjotNode]) assignedTableProps := make(map[int]TableProps) { groupElements := make([]*TreeNode[DjotNode], 0) - activeList, activeListNode, activeListLastItemSparse := ListProps{}, &TreeNode[DjotNode]{}, false + activeList, activeListNode, activeListLastItemSparse := ListProps{}, (*TreeNode[DjotNode])(nil), false activeTableProps := TableProps{} i, previous := 0, -1 for i < len(list) { @@ -523,7 +524,8 @@ func buildDjotAst( groupElements = append(groupElements, §ionNode) case djot_tokenizer.ListItemBlock: currentList, currentStart := detectListProps(document, openToken) - if len(groupElements) > 0 && (groupElements[len(groupElements)-1].Type != currentList.Type || activeList != currentList) { + // reset group only if last active group is the List of another type (markers, style, etc.) + if len(groupElements) > 0 && activeListNode != nil && activeList != currentList { groupElementsPop[i] = 1 groupElements = groupElements[:len(groupElements)-1] } @@ -553,7 +555,7 @@ func buildDjotAst( } } if openToken.Type != djot_tokenizer.ListItemBlock { - activeList, activeListNode, activeListLastItemSparse = ListProps{}, &TreeNode[DjotNode]{}, false + activeList, activeListNode, activeListLastItemSparse = ListProps{}, (*TreeNode[DjotNode])(nil), false } if openToken.Type != djot_tokenizer.PipeTableBlock { activeTableProps = TableProps{} diff --git a/djot_parser/examples/issue_9.djot b/djot_parser/examples/issue_9.djot new file mode 100644 index 0000000..247b696 --- /dev/null +++ b/djot_parser/examples/issue_9.djot @@ -0,0 +1,3 @@ +# Test + +- List item \ No newline at end of file diff --git a/djot_parser/examples/issue_9.html b/djot_parser/examples/issue_9.html new file mode 100644 index 0000000..53ecde0 --- /dev/null +++ b/djot_parser/examples/issue_9.html @@ -0,0 +1,8 @@ +
+

Test

+ +
diff --git a/djot_parser/examples/issue_9_1.djot b/djot_parser/examples/issue_9_1.djot new file mode 100644 index 0000000..3f174ae --- /dev/null +++ b/djot_parser/examples/issue_9_1.djot @@ -0,0 +1,8 @@ +# Test + +- 1 item +* 2 item +1) 3 item +2) 4 item +A) 5 item +B) 6 item \ No newline at end of file diff --git a/djot_parser/examples/issue_9_1.html b/djot_parser/examples/issue_9_1.html new file mode 100644 index 0000000..4ede45a --- /dev/null +++ b/djot_parser/examples/issue_9_1.html @@ -0,0 +1,29 @@ +
+

Test

+ + +
    +
  1. +3 item +
  2. +
  3. +4 item +
  4. +
+
    +
  1. +5 item +
  2. +
  3. +6 item +
  4. +
+