Skip to content

Commit 52a3178

Browse files
Update showdown.js (#518)
1 parent a633d9a commit 52a3178

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

renard-wx/lib/wxParse/showdown.js

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,
1222+
var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\b)(?![^<>]*>)/gi,
12451223
delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,
1246-
simpleMailRegex = /(?:^|[ \n\t])([A-Za-z0-9!#$%&'*+-/=?^_`\{|}~\.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?:$|[ \n\t])/gi,
1247-
delimMailRegex = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
1224+
simpleMailRegex = /(?:\b)([\w\d\.\-\+]{1,256}\@[\w\d\.\-\+]{1,256}\.\w{1,24}+)(?:\b)/gi,
1225+
delimMailRegex = /<(?:mailto:)?([\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

Comments
 (0)