@@ -208,13 +208,13 @@ function parseImage(
208208 //  or 
209209 const altStart = start + 2 ; // after ![
210210 const altEnd = text . indexOf ( "]" , altStart ) ;
211- if ( altEnd === - 1 ) return null ;
211+ if ( altEnd === - 1 ) { return null ; }
212212
213- if ( text [ altEnd + 1 ] !== "(" ) return null ;
213+ if ( text [ altEnd + 1 ] !== "(" ) { return null ; }
214214
215215 const urlStart = altEnd + 2 ;
216216 const parenEnd = findClosingParen ( text , urlStart - 1 ) ;
217- if ( parenEnd === - 1 ) return null ;
217+ if ( parenEnd === - 1 ) { return null ; }
218218
219219 const alt = text . substring ( altStart , altEnd ) ;
220220 let urlContent = text . substring ( urlStart , parenEnd ) . trim ( ) ;
@@ -250,13 +250,13 @@ function parseLink(
250250 // [text](url)
251251 const textStart = start + 1 ;
252252 const textEnd = findClosingBracket ( text , start ) ;
253- if ( textEnd === - 1 ) return null ;
253+ if ( textEnd === - 1 ) { return null ; }
254254
255- if ( text [ textEnd + 1 ] !== "(" ) return null ;
255+ if ( text [ textEnd + 1 ] !== "(" ) { return null ; }
256256
257257 const urlStart = textEnd + 2 ;
258258 const parenEnd = findClosingParen ( text , textEnd + 1 ) ;
259- if ( parenEnd === - 1 ) return null ;
259+ if ( parenEnd === - 1 ) { return null ; }
260260
261261 const linkText = text . substring ( textStart , textEnd ) ;
262262 const url = text . substring ( urlStart , parenEnd ) . trim ( ) ;
@@ -274,10 +274,10 @@ function findClosingBracket(text: string, openPos: number): number {
274274 i ++ ; // skip escaped
275275 continue ;
276276 }
277- if ( text [ i ] === "[" ) depth ++ ;
277+ if ( text [ i ] === "[" ) { depth ++ ; }
278278 if ( text [ i ] === "]" ) {
279279 depth -- ;
280- if ( depth === 0 ) return i ;
280+ if ( depth === 0 ) { return i ; }
281281 }
282282 }
283283 return - 1 ;
@@ -290,10 +290,10 @@ function findClosingParen(text: string, openPos: number): number {
290290 i ++ ;
291291 continue ;
292292 }
293- if ( text [ i ] === "(" ) depth ++ ;
293+ if ( text [ i ] === "(" ) { depth ++ ; }
294294 if ( text [ i ] === ")" ) {
295295 depth -- ;
296- if ( depth === 0 ) return i ;
296+ if ( depth === 0 ) { return i ; }
297297 }
298298 }
299299 return - 1 ;
@@ -309,10 +309,10 @@ function parseDelimited(
309309 const len = delimiter . length ;
310310 const afterOpen = start + len ;
311311
312- if ( afterOpen >= text . length ) return null ;
312+ if ( afterOpen >= text . length ) { return null ; }
313313
314314 // Opening delimiter must not be followed by whitespace
315- if ( text [ afterOpen ] === " " || text [ afterOpen ] === "\t" ) return null ;
315+ if ( text [ afterOpen ] === " " || text [ afterOpen ] === "\t" ) { return null ; }
316316
317317 // Find closing delimiter
318318 let j = afterOpen ;
@@ -580,11 +580,11 @@ function tokenize(markdown: string): Token[] {
580580 const minChildIndent = indent + 1 ;
581581
582582 // Helper to check if a line belongs to this list item
583- function belongsToItem ( lineStr : string ) : boolean {
584- if ( lineStr . trim ( ) === "" ) return true ; // blank lines checked separately
583+ const belongsToItem = ( lineStr : string ) : boolean => {
584+ if ( lineStr . trim ( ) === "" ) { return true ; } // blank lines checked separately
585585 const lineInd = lineStr . match ( / ^ \s * / ) ! [ 0 ] . length ;
586586 // Lines at contentIndent are continuation text
587- if ( lineInd >= contentIndent ) return true ;
587+ if ( lineInd >= contentIndent ) { return true ; }
588588 // Lines between marker and content column that start a sub-list
589589 if (
590590 lineInd >= minChildIndent &&
@@ -615,7 +615,7 @@ function tokenize(markdown: string): Token[] {
615615 break ;
616616 }
617617
618- if ( ! belongsToItem ( cur ) ) break ;
618+ if ( ! belongsToItem ( cur ) ) { break ; }
619619
620620 // Strip indent: for lines at contentIndent+, strip contentIndent chars;
621621 // for sub-list lines between minChildIndent and contentIndent, strip minChildIndent
@@ -652,14 +652,14 @@ function tokenize(markdown: string): Token[] {
652652 while ( i < lines . length ) {
653653 const nextLine = lines [ i ] ;
654654 // Stop paragraph on blank line
655- if ( nextLine . trim ( ) === "" ) break ;
655+ if ( nextLine . trim ( ) === "" ) { break ; }
656656 // Stop on block-level element
657- if ( / ^ ( # { 1 , 6 } ) \s / . test ( nextLine ) ) break ;
658- if ( / ^ ( ` { 3 , } | ~ { 3 , } ) / . test ( nextLine ) ) break ;
659- if ( / ^ \s { 0 , 3 } > / . test ( nextLine ) ) break ;
660- if ( / ^ ( \s { 0 , 3 } ) ( [ - * _ ] ) \s * ( \2\s * ) { 2 , } $ / . test ( nextLine ) ) break ;
661- if ( / ^ \s * ( [ - * + ] | \d + [ . ) ] ) \s + / . test ( nextLine ) ) break ;
662- if ( / ^ \s * \| ( .+ \| ) + \s * $ / . test ( nextLine ) ) break ;
657+ if ( / ^ ( # { 1 , 6 } ) \s / . test ( nextLine ) ) { break ; }
658+ if ( / ^ ( ` { 3 , } | ~ { 3 , } ) / . test ( nextLine ) ) { break ; }
659+ if ( / ^ \s { 0 , 3 } > / . test ( nextLine ) ) { break ; }
660+ if ( / ^ ( \s { 0 , 3 } ) ( [ - * _ ] ) \s * ( \2\s * ) { 2 , } $ / . test ( nextLine ) ) { break ; }
661+ if ( / ^ \s * ( [ - * + ] | \d + [ . ) ] ) \s + / . test ( nextLine ) ) { break ; }
662+ if ( / ^ \s * \| ( .+ \| ) + \s * $ / . test ( nextLine ) ) { break ; }
663663 // Check if next-next line is setext marker
664664 if (
665665 i + 1 < lines . length &&
@@ -686,16 +686,16 @@ function tryParseTable(
686686 start : number
687687) : { token : TableToken ; nextLine : number } | null {
688688 // A table needs at least a header row and a separator row
689- if ( start + 1 >= lines . length ) return null ;
689+ if ( start + 1 >= lines . length ) { return null ; }
690690
691691 const headerLine = lines [ start ] ;
692692 const separatorLine = lines [ start + 1 ] ;
693693
694694 // Check separator line format: | --- | --- | or | :--- | ---: |
695- if ( ! / ^ \s * \| ( \s * : ? - + : ? \s * \| ) + \s * $ / . test ( separatorLine ) ) return null ;
695+ if ( ! / ^ \s * \| ( \s * : ? - + : ? \s * \| ) + \s * $ / . test ( separatorLine ) ) { return null ; }
696696
697697 // Check header line format: | ... | ... |
698- if ( ! / ^ \s * \| ( .+ \| ) + \s * $ / . test ( headerLine ) ) return null ;
698+ if ( ! / ^ \s * \| ( .+ \| ) + \s * $ / . test ( headerLine ) ) { return null ; }
699699
700700 const headers = parsePipeCells ( headerLine ) ;
701701 const alignments = parseAlignments ( separatorLine ) ;
@@ -704,7 +704,7 @@ function tryParseTable(
704704 let i = start + 2 ;
705705 while ( i < lines . length ) {
706706 const line = lines [ i ] ;
707- if ( ! / ^ \s * \| ( .+ \| ) + \s * $ / . test ( line ) ) break ;
707+ if ( ! / ^ \s * \| ( .+ \| ) + \s * $ / . test ( line ) ) { break ; }
708708 rows . push ( parsePipeCells ( line ) ) ;
709709 i ++ ;
710710 }
@@ -757,9 +757,9 @@ function parseAlignments(
757757 const trimmed = cell . trim ( ) ;
758758 const left = trimmed . startsWith ( ":" ) ;
759759 const right = trimmed . endsWith ( ":" ) ;
760- if ( left && right ) return "center" ;
761- if ( right ) return "right" ;
762- if ( left ) return "left" ;
760+ if ( left && right ) { return "center" ; }
761+ if ( right ) { return "right" ; }
762+ if ( left ) { return "left" ; }
763763 return null ;
764764 } ) ;
765765}
0 commit comments