@@ -331,7 +331,11 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
331331 raw = cap [ 0 ] ;
332332 src = src . substring ( raw . length ) ;
333333
334- let line = expandTabs ( cap [ 2 ] . split ( '\n' , 1 ) [ 0 ] , cap [ 1 ] . length ) ;
334+ const firstLine = cap [ 2 ] . split ( '\n' , 1 ) [ 0 ] ;
335+ const bulletIndent = cap [ 1 ] . length ;
336+ let line = this . options . pedantic
337+ ? expandTabs ( firstLine , bulletIndent )
338+ : firstLine . replace ( this . rules . other . leadingSpaceTab , whitespace => expandTabs ( whitespace , bulletIndent ) ) ;
335339 let nextLine = src . split ( '\n' , 1 ) [ 0 ] ;
336340 let blankLine = ! line . trim ( ) ;
337341
@@ -340,12 +344,12 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
340344 indent = 2 ;
341345 itemContents = line . trimStart ( ) ;
342346 } else if ( blankLine ) {
343- indent = cap [ 1 ] . length + 1 ;
347+ indent = bulletIndent + 1 ;
344348 } else {
345349 indent = line . search ( this . rules . other . nonSpaceChar ) ; // Find first non-space char
346350 indent = indent > 4 ? 1 : indent ; // Treat indented code blocks (> 4 spaces) as having only 1 indent
347351 itemContents = line . slice ( indent ) ;
348- indent += cap [ 1 ] . length ;
352+ indent += bulletIndent ;
349353 }
350354
351355 if ( blankLine && this . rules . other . blankLine . test ( nextLine ) ) { // Items begin with at most one blank line
@@ -373,7 +377,7 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
373377 nextLine = nextLine . replace ( this . rules . other . listReplaceNesting , ' ' ) ;
374378 nextLineWithoutTabs = nextLine ;
375379 } else {
376- nextLineWithoutTabs = nextLine . replace ( this . rules . other . tabCharGlobal , ' ' ) ;
380+ nextLineWithoutTabs = nextLine . replace ( this . rules . other . leadingSpaceTab , whitespace => whitespace . replace ( this . rules . other . tabCharGlobal , ' ' ) ) ;
377381 }
378382
379383 // End list item if found code fences
0 commit comments