@@ -25,7 +25,7 @@ export const block = {
2525 + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
2626 + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
2727 + ')' ,
28- def : / ^ { 0 , 3 } \[ ( l a b e l ) \] : * \n ? * < ? ( [ ^ \s > ] + ) > ? (?: (?: + \n ? * | * \n * ) ( t i t l e ) ) ? * (?: \n + | $ ) / ,
28+ def : / ^ { 0 , 3 } \[ ( l a b e l ) \] : * (?: \n * ) ? < ? ( [ ^ \s > ] + ) > ? (?: (?: + (?: \n * ) ? | * \n * ) ( t i t l e ) ) ? * (?: \n + | $ ) / ,
2929 table : noopTest ,
3030 lheading : / ^ ( [ ^ \n ] + ) \n { 0 , 3 } ( = + | - + ) * (?: \n + | $ ) / ,
3131 // regex template, placeholders will be replaced according to different paragraph
@@ -34,7 +34,7 @@ export const block = {
3434 text : / ^ [ ^ \n ] + /
3535} ;
3636
37- block . _label = / (? ! \s * \] ) (?: \\ [ \[ \] ] | [ ^ \[ \] ] ) + / ;
37+ block . _label = / (? ! \s * \] ) (?: \\ . | [ ^ \[ \] \\ ] ) + / ;
3838block . _title = / (?: " (?: \\ " ? | [ ^ " \\ ] ) * " | ' [ ^ ' \n ] * (?: \n [ ^ ' \n ] + ) * \n ? ' | \( [ ^ ( ) ] * \) ) / ;
3939block . def = edit ( block . def )
4040 . replace ( 'label' , block . _label )
@@ -162,8 +162,8 @@ export const inline = {
162162 + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
163163 + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>' , // CDATA section
164164 link : / ^ ! ? \[ ( l a b e l ) \] \( \s * ( h r e f ) (?: \s + ( t i t l e ) ) ? \s * \) / ,
165- reflink : / ^ ! ? \[ ( l a b e l ) \] \[ (? ! \s * \] ) ( (?: \\ [ \[ \] ] ? | [ ^ \[ \] \\ ] ) + ) \] / ,
166- nolink : / ^ ! ? \[ (? ! \s * \] ) ( (?: \[ [ ^ \[ \] ] * \] | \\ [ \[ \] ] | [ ^ \[ \] ] ) * ) \] (?: \[ \] ) ? / ,
165+ reflink : / ^ ! ? \[ ( l a b e l ) \] \[ ( r e f ) \] / ,
166+ nolink : / ^ ! ? \[ ( r e f ) \] (?: \[ \] ) ? / ,
167167 reflinkSearch : 'reflink|nolink(?!\\()' ,
168168 emStrong : {
169169 lDelim : / ^ (?: \* + (?: ( [ p u n c t _ ] ) | [ ^ \s * ] ) ) | ^ _ + (?: ( [ p u n c t * ] ) | ( [ ^ \s _ ] ) ) / ,
@@ -230,6 +230,11 @@ inline.link = edit(inline.link)
230230
231231inline . reflink = edit ( inline . reflink )
232232 . replace ( 'label' , inline . _label )
233+ . replace ( 'ref' , block . _label )
234+ . getRegex ( ) ;
235+
236+ inline . nolink = edit ( inline . nolink )
237+ . replace ( 'ref' , block . _label )
233238 . getRegex ( ) ;
234239
235240inline . reflinkSearch = edit ( inline . reflinkSearch , 'g' )
0 commit comments