@@ -169,7 +169,7 @@ export class Tokenizer {
169
169
let cap = this . rules . block . list . exec ( src ) ;
170
170
if ( cap ) {
171
171
let raw , istask , ischecked , indent , i , blankLine , endsWithBlankLine ,
172
- line , nextLine , rawLine , itemContents ;
172
+ line , nextLine , rawLine , itemContents , endEarly ;
173
173
174
174
let bull = cap [ 1 ] . trim ( ) ;
175
175
const isordered = bull . length > 1 ;
@@ -194,6 +194,7 @@ export class Tokenizer {
194
194
195
195
// Check if current bullet point can start a new List Item
196
196
while ( src ) {
197
+ endEarly = false ;
197
198
if ( ! ( cap = itemRegex . exec ( src ) ) ) {
198
199
break ;
199
200
}
@@ -223,40 +224,42 @@ export class Tokenizer {
223
224
if ( ! line && / ^ * $ / . test ( nextLine ) ) { // Items begin with at most one blank line
224
225
raw += nextLine + '\n' ;
225
226
src = src . substring ( nextLine . length + 1 ) ;
226
- list . loose = true ;
227
+ endEarly = true ;
227
228
}
228
229
229
- const nextBulletRegex = new RegExp ( `^ {0,${ Math . min ( 3 , indent - 1 ) } }(?:[*+-]|\\d{1,9}[.)])` ) ;
230
-
231
- // Check if following lines should be included in List Item
232
- while ( src && ! list . loose ) {
233
- rawLine = src . split ( '\n' , 1 ) [ 0 ] ;
234
- line = rawLine ;
235
-
236
- // Re-align to follow commonmark nesting rules
237
- if ( this . options . pedantic ) {
238
- line = line . replace ( / ^ { 1 , 4 } (? = ( { 4 } ) * [ ^ ] ) / g, ' ' ) ;
239
- }
240
-
241
- // End list item if found start of new bullet
242
- if ( nextBulletRegex . test ( line ) ) {
243
- break ;
230
+ if ( ! endEarly ) {
231
+ const nextBulletRegex = new RegExp ( `^ {0,${ Math . min ( 3 , indent - 1 ) } }(?:[*+-]|\\d{1,9}[.)])` ) ;
232
+
233
+ // Check if following lines should be included in List Item
234
+ while ( src ) {
235
+ rawLine = src . split ( '\n' , 1 ) [ 0 ] ;
236
+ line = rawLine ;
237
+
238
+ // Re-align to follow commonmark nesting rules
239
+ if ( this . options . pedantic ) {
240
+ line = line . replace ( / ^ { 1 , 4 } (? = ( { 4 } ) * [ ^ ] ) / g, ' ' ) ;
241
+ }
242
+
243
+ // End list item if found start of new bullet
244
+ if ( nextBulletRegex . test ( line ) ) {
245
+ break ;
246
+ }
247
+
248
+ if ( line . search ( / [ ^ ] / ) >= indent || ! line . trim ( ) ) { // Dedent if possible
249
+ itemContents += '\n' + line . slice ( indent ) ;
250
+ } else if ( ! blankLine ) { // Until blank line, item doesn't need indentation
251
+ itemContents += '\n' + line ;
252
+ } else { // Otherwise, improper indentation ends this item
253
+ break ;
254
+ }
255
+
256
+ if ( ! blankLine && ! line . trim ( ) ) { // Check if current line is blank
257
+ blankLine = true ;
258
+ }
259
+
260
+ raw += rawLine + '\n' ;
261
+ src = src . substring ( rawLine . length + 1 ) ;
244
262
}
245
-
246
- if ( line . search ( / [ ^ ] / ) >= indent || ! line . trim ( ) ) { // Dedent if possible
247
- itemContents += '\n' + line . slice ( indent ) ;
248
- } else if ( ! blankLine ) { // Until blank line, item doesn't need indentation
249
- itemContents += '\n' + line ;
250
- } else { // Otherwise, improper indentation ends this item
251
- break ;
252
- }
253
-
254
- if ( ! blankLine && ! line . trim ( ) ) { // Check if current line is blank
255
- blankLine = true ;
256
- }
257
-
258
- raw += rawLine + '\n' ;
259
- src = src . substring ( rawLine . length + 1 ) ;
260
263
}
261
264
262
265
if ( ! list . loose ) {
0 commit comments