@@ -25,7 +25,7 @@ export const block = {
25
25
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
26
26
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
27
27
+ ')' ,
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 + | $ ) / ,
29
29
table : noopTest ,
30
30
lheading : / ^ ( [ ^ \n ] + ) \n { 0 , 3 } ( = + | - + ) * (?: \n + | $ ) / ,
31
31
// regex template, placeholders will be replaced according to different paragraph
@@ -34,7 +34,7 @@ export const block = {
34
34
text : / ^ [ ^ \n ] + /
35
35
} ;
36
36
37
- block . _label = / (? ! \s * \] ) (?: \\ [ \[ \] ] | [ ^ \[ \] ] ) + / ;
37
+ block . _label = / (? ! \s * \] ) (?: \\ . | [ ^ \[ \] \\ ] ) + / ;
38
38
block . _title = / (?: " (?: \\ " ? | [ ^ " \\ ] ) * " | ' [ ^ ' \n ] * (?: \n [ ^ ' \n ] + ) * \n ? ' | \( [ ^ ( ) ] * \) ) / ;
39
39
block . def = edit ( block . def )
40
40
. replace ( 'label' , block . _label )
@@ -162,8 +162,8 @@ export const inline = {
162
162
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
163
163
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>' , // CDATA section
164
164
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 ) \] (?: \[ \] ) ? / ,
167
167
reflinkSearch : 'reflink|nolink(?!\\()' ,
168
168
emStrong : {
169
169
lDelim : / ^ (?: \* + (?: ( [ p u n c t _ ] ) | [ ^ \s * ] ) ) | ^ _ + (?: ( [ p u n c t * ] ) | ( [ ^ \s _ ] ) ) / ,
@@ -230,6 +230,11 @@ inline.link = edit(inline.link)
230
230
231
231
inline . reflink = edit ( inline . reflink )
232
232
. replace ( 'label' , inline . _label )
233
+ . replace ( 'ref' , block . _label )
234
+ . getRegex ( ) ;
235
+
236
+ inline . nolink = edit ( inline . nolink )
237
+ . replace ( 'ref' , block . _label )
233
238
. getRegex ( ) ;
234
239
235
240
inline . reflinkSearch = edit ( inline . reflinkSearch , 'g' )
0 commit comments