File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -441,7 +441,14 @@ const tag = edit(
441441 . replace ( 'attribute' , / \s + [ a - z A - Z : _ ] [ \w . : - ] * (?: \s * = \s * " [ ^ " ] * " | \s * = \s * ' [ ^ ' ] * ' | \s * = \s * [ ^ \s " ' = < > ` ] + ) ? / )
442442 . getRegex ( ) ;
443443
444- const _inlineLabel = / (?: \[ (?: \\ [ \s \S ] | [ ^ \[ \] \\ ] ) * \] | \\ [ \s \S ] | ` + (? ! ` ) [ ^ ` ] * ?` + (? ! ` ) | ` ` + (? = \] ) | [ ^ \[ \] \\ ` ] ) * ?/ ;
444+ // One matched pair of brackets, holding no bracket of its own.
445+ const _inlineLabelBrackets = / \[ (?: \\ [ \s \S ] | [ ^ \[ \] \\ ] ) * \] / ;
446+ // CommonMark lets the brackets in a link label nest to any depth, which a regex
447+ // cannot follow, so it stops at a fixed one. Two levels is what the spec suite
448+ // asks for: a third and a fourth flip no further example.
449+ const _inlineLabel = edit ( / (?: \[ (?: b r a c k e t s | \\ [ \s \S ] | [ ^ \[ \] \\ ] ) * \] | \\ [ \s \S ] | ` + (? ! ` ) [ ^ ` ] * ?` + (? ! ` ) | ` ` + (? = \] ) | [ ^ \[ \] \\ ` ] ) * ?/ )
450+ . replace ( 'brackets' , _inlineLabelBrackets )
451+ . getRegex ( ) ;
445452
446453const link = edit ( / ^ ! ? \[ ( l a b e l ) \] \( \s * ( h r e f ) (?: (?: [ \t ] + (?: \n [ \t ] * ) ? | \n [ \t ] * ) ( t i t l e ) ) ? \s * \) / )
447454 . replace ( 'label' , _inlineLabel )
Original file line number Diff line number Diff line change 40964096 "example" : 512 ,
40974097 "start_line" : 7840 ,
40984098 "end_line" : 7844 ,
4099- "section" : " Links" ,
4100- "shouldFail" : true
4099+ "section" : " Links"
41014100 },
41024101 {
41034102 "markdown" : " [link] bar](/uri)\n " ,
41614160 "example" : 520 ,
41624161 "start_line" : 7900 ,
41634162 "end_line" : 7904 ,
4164- "section" : " Links" ,
4165- "shouldFail" : true
4163+ "section" : " Links"
41664164 },
41674165 {
41684166 "markdown" : " *[foo*](/uri)\n " ,
42284226 "example" : 528 ,
42294227 "start_line" : 8004 ,
42304228 "end_line" : 8010 ,
4231- "section" : " Links" ,
4232- "shouldFail" : true
4229+ "section" : " Links"
42334230 },
42344231 {
42354232 "markdown" : " [link \\ [bar][ref]\n\n [ref]: /uri\n " ,
Original file line number Diff line number Diff line change 40964096 "example" : 512 ,
40974097 "start_line" : 7840 ,
40984098 "end_line" : 7844 ,
4099- "section" : " Links" ,
4100- "shouldFail" : true
4099+ "section" : " Links"
41014100 },
41024101 {
41034102 "markdown" : " [link] bar](/uri)\n " ,
41614160 "example" : 520 ,
41624161 "start_line" : 7900 ,
41634162 "end_line" : 7904 ,
4164- "section" : " Links" ,
4165- "shouldFail" : true
4163+ "section" : " Links"
41664164 },
41674165 {
41684166 "markdown" : " *[foo*](/uri)\n " ,
42284226 "example" : 528 ,
42294227 "start_line" : 8004 ,
42304228 "end_line" : 8010 ,
4231- "section" : " Links" ,
4232- "shouldFail" : true
4229+ "section" : " Links"
42334230 },
42344231 {
42354232 "markdown" : " [link \\ [bar][ref]\n\n [ref]: /uri\n " ,
You can’t perform that action at this time.
0 commit comments