File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,8 @@ func mergeListItemNodes(nodes []ast.Node) []ast.Node {
151
151
}
152
152
} else {
153
153
result = append (result , node )
154
+ // Reset the stack if the current node is not a list item node.
155
+ stack = nil
154
156
}
155
157
}
156
158
Original file line number Diff line number Diff line change @@ -16,6 +16,26 @@ func TestListParser(t *testing.T) {
16
16
text string
17
17
nodes []ast.Node
18
18
}{
19
+ {
20
+ text : "1. hello\n \n " ,
21
+ nodes : []ast.Node {
22
+ & ast.List {
23
+ Kind : ast .OrderedList ,
24
+ Children : []ast.Node {
25
+ & ast.OrderedListItem {
26
+ Number : "1" ,
27
+ Children : []ast.Node {
28
+ & ast.Text {
29
+ Content : "hello" ,
30
+ },
31
+ },
32
+ },
33
+ & ast.LineBreak {},
34
+ & ast.LineBreak {},
35
+ },
36
+ },
37
+ },
38
+ },
19
39
{
20
40
text : "1. hello\n 2. world" ,
21
41
nodes : []ast.Node {
@@ -164,6 +184,46 @@ func TestListParser(t *testing.T) {
164
184
},
165
185
},
166
186
},
187
+ {
188
+ text : "* hello\n paragraph\n * world" ,
189
+ nodes : []ast.Node {
190
+ & ast.List {
191
+ Kind : ast .UnorderedList ,
192
+ Children : []ast.Node {
193
+ & ast.UnorderedListItem {
194
+ Symbol : "*" ,
195
+ Children : []ast.Node {
196
+ & ast.Text {
197
+ Content : "hello" ,
198
+ },
199
+ },
200
+ },
201
+ & ast.LineBreak {},
202
+ },
203
+ },
204
+ & ast.Paragraph {
205
+ Children : []ast.Node {
206
+ & ast.Text {
207
+ Content : "paragraph" ,
208
+ },
209
+ },
210
+ },
211
+ & ast.LineBreak {},
212
+ & ast.List {
213
+ Kind : ast .UnorderedList ,
214
+ Children : []ast.Node {
215
+ & ast.UnorderedListItem {
216
+ Symbol : "*" ,
217
+ Children : []ast.Node {
218
+ & ast.Text {
219
+ Content : "world" ,
220
+ },
221
+ },
222
+ },
223
+ },
224
+ },
225
+ },
226
+ },
167
227
}
168
228
169
229
for _ , test := range tests {
You can’t perform that action at this time.
0 commit comments