@@ -120,18 +120,19 @@ func mergeListItemNodes(nodes []ast.Node) []ast.Node {
120
120
case * ast.OrderedListItem , * ast.UnorderedListItem , * ast.TaskListItem :
121
121
var listKind ast.ListKind
122
122
var indent int
123
- switch nodes [i ].(type ) {
123
+ switch item := nodes [i ].(type ) {
124
124
case * ast.OrderedListItem :
125
125
listKind = ast .OrderedList
126
- indent = nodes [ i ].( * ast. OrderedListItem ) .Indent
126
+ indent = item .Indent
127
127
case * ast.UnorderedListItem :
128
128
listKind = ast .UnorderedList
129
- indent = nodes [ i ].( * ast. UnorderedListItem ) .Indent
129
+ indent = item .Indent
130
130
case * ast.TaskListItem :
131
131
listKind = ast .DescrpitionList
132
- indent = nodes [ i ].( * ast. TaskListItem ) .Indent
132
+ indent = item .Indent
133
133
}
134
- indent = indent / 2
134
+
135
+ indent /= 2
135
136
if prevResultNode == nil || prevResultNode .Type () != ast .ListNode || prevResultNode .(* ast.List ).Kind != listKind || prevResultNode .(* ast.List ).Indent > indent {
136
137
prevResultNode = & ast.List {
137
138
BaseBlock : ast.BaseBlock {},
@@ -143,9 +144,12 @@ func mergeListItemNodes(nodes []ast.Node) []ast.Node {
143
144
continue
144
145
}
145
146
146
- listNode := prevResultNode .(* ast.List )
147
+ listNode , ok := prevResultNode .(* ast.List )
148
+ if ! ok {
149
+ continue
150
+ }
147
151
if listNode .Indent != indent {
148
- parent := findPossibleParent (listNode , indent )
152
+ parent := findListPossibleParent (listNode , indent )
149
153
if parent == nil {
150
154
parent = & ast.List {
151
155
BaseBlock : ast.BaseBlock {},
@@ -190,7 +194,7 @@ func mergeTextNodes(nodes []ast.Node) []ast.Node {
190
194
return result
191
195
}
192
196
193
- func findPossibleParent (listNode * ast.List , indent int ) * ast.List {
197
+ func findListPossibleParent (listNode * ast.List , indent int ) * ast.List {
194
198
if listNode .Indent == indent {
195
199
return listNode
196
200
}
@@ -204,5 +208,5 @@ func findPossibleParent(listNode *ast.List, indent int) *ast.List {
204
208
if lastChild .Type () != ast .ListNode {
205
209
return nil
206
210
}
207
- return findPossibleParent (lastChild .(* ast.List ), indent )
211
+ return findListPossibleParent (lastChild .(* ast.List ), indent )
208
212
}
0 commit comments