@@ -11,24 +11,38 @@ function exitCheck(token) {
11
11
}
12
12
13
13
function exitParagraphWithTaskListItem ( token ) {
14
- var node = this . stack [ this . stack . length - 1 ]
15
14
var parent = this . stack [ this . stack . length - 2 ]
15
+ var node = this . stack [ this . stack . length - 1 ]
16
+ var siblings = parent . children
16
17
var head = node . children [ 0 ]
18
+ var index = - 1
19
+ var firstParaghraph
17
20
18
21
if (
22
+ parent &&
19
23
parent . type === 'listItem' &&
20
24
typeof parent . checked === 'boolean' &&
21
25
head &&
22
26
head . type === 'text'
23
27
) {
24
- // Must start with a space or a tab.
25
- head . value = head . value . slice ( 1 )
26
- if ( head . value . length === 0 ) {
27
- node . children . shift ( )
28
- } else {
29
- head . position . start . column ++
30
- head . position . start . offset ++
31
- node . position . start = Object . assign ( { } , head . position . start )
28
+ while ( ++ index < siblings . length ) {
29
+ if ( siblings [ index ] . type === 'paragraph' ) {
30
+ firstParaghraph = siblings [ index ]
31
+ break
32
+ }
33
+ }
34
+
35
+ if ( firstParaghraph === node ) {
36
+ // Must start with a space or a tab.
37
+ head . value = head . value . slice ( 1 )
38
+
39
+ if ( head . value . length === 0 ) {
40
+ node . children . shift ( )
41
+ } else {
42
+ head . position . start . column ++
43
+ head . position . start . offset ++
44
+ node . position . start = Object . assign ( { } , head . position . start )
45
+ }
32
46
}
33
47
}
34
48
0 commit comments