@@ -1157,29 +1157,7 @@ showdown.subParser('anchors', function (text, options, globals) {
11571157 } ;
11581158
11591159 // First, handle reference-style links: [link text] [id]
1160- /*
1161- text = text.replace(/
1162- ( // wrap whole match in $1
1163- \[
1164- (
1165- (?:
1166- \[[^\]]*\] // allow brackets nested one level
1167- |
1168- [^\[] // or anything else
1169- )*
1170- )
1171- \]
1172-
1173- [ ]? // one optional space
1174- (?:\n[ ]*)? // one optional newline followed by spaces
1175-
1176- \[
1177- (.*?) // id = $3
1178- \]
1179- )()()()() // pad remaining backreferences
1180- /g,_DoAnchors_callback);
1181- */
1182- text = text . replace ( / ( \[ ( (?: \[ [ ^ \] ] * ] | [ ^ \[ \] ] ) * ) ] [ ] ? (?: \n [ ] * ) ? \[ ( .* ?) ] ) ( ) ( ) ( ) ( ) / g, writeAnchorTag ) ;
1160+ text = text . replace ( / ( \[ [ ^ \] \n ] + \] \s * ) { 2 } / g, writeAnchorTag ) ;
11831161
11841162 //
11851163 // Next, inline-style links: [link text](url "optional title")
@@ -1241,10 +1219,10 @@ showdown.subParser('autoLinks', function (text, options, globals) {
12411219
12421220 text = globals . converter . _dispatch ( 'autoLinks.before' , text , options , globals ) ;
12431221
1244- var simpleURLRegex = / \b ( ( ( h t t p s ? | f t p | d i c t ) : \/ \/ | w w w \. ) [ ^ ' " > \s ] + \. [ ^ ' " > \s ] + ) (? = \s | $ ) (? ! [ " < > ] ) / gi,
1222+ var simpleURLRegex = / \b ( ( ( h t t p s ? | f t p | d i c t ) : \/ \/ | w w w \. ) [ ^ ' " > \s ] + \. [ ^ ' " > \s ] + ) (? = \b ) (? ! [ ^ < > ] * > ) / gi,
12451223 delimUrlRegex = / < ( ( ( h t t p s ? | f t p | d i c t ) : \/ \/ | w w w \. ) [ ^ ' " > \s ] + ) > / gi,
1246- simpleMailRegex = / (?: ^ | [ \n \t ] ) ( [ A - Z a - z 0 - 9 ! # $ % & ' * + - / = ? ^ _ ` \{ | } ~ \. ] + @ [ - a - z 0 - 9 ] + ( \. [ - a - z 0 - 9 ] + ) * \. [ a - z ] + ) (?: $ | [ \n \t ] ) / gi,
1247- delimMailRegex = / < (?: m a i l t o : ) ? ( [ - . \w ] + @ [ - a - z 0 - 9 ] + ( \. [ - a - z 0 - 9 ] + ) * \. [ a - z ] + ) > / gi;
1224+ simpleMailRegex = / (?: \b ) ( [ \w \d \. \- \+ ] { 1 , 256 } \@ [ \w \d \. \- \+ ] { 1 , 256 } \. \w { 1 , 24 } + ) (?: \b ) / gi,
1225+ delimMailRegex = / < (?: m a i l t o : ) ? ( [ \w \d \. \- \+ ] { 1 , 256 } \@ [ \w \d \. \- \+ ] { 1 , 256 } \. \w { 1 , 24 } ) > / gi;
12481226
12491227 text = text . replace ( delimUrlRegex , replaceLink ) ;
12501228 text = text . replace ( delimMailRegex , replaceMail ) ;
0 commit comments