2015-01-16 05:21:33 +08:00
|
|
|
showdown.subParser('autoLinks', function (text) {
|
2015-01-19 19:37:21 +08:00
|
|
|
'use strict';
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 20:04:22 +08:00
|
|
|
text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi, '<a href=\"$1\">$1</a>');
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
// Email addresses: <address@domain.foo>
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
/*
|
|
|
|
text = text.replace(/
|
|
|
|
<
|
|
|
|
(?:mailto:)?
|
|
|
|
(
|
|
|
|
[-.\w]+
|
|
|
|
\@
|
|
|
|
[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
|
|
|
|
)
|
|
|
|
>
|
2015-01-19 20:04:22 +08:00
|
|
|
/gi);
|
2015-01-19 19:37:21 +08:00
|
|
|
*/
|
2015-01-19 20:04:22 +08:00
|
|
|
var pattern = /<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
|
|
|
|
text = text.replace(pattern, function (wholeMatch, m1) {
|
2015-01-19 19:37:21 +08:00
|
|
|
var unescapedStr = showdown.subParser('unescapeSpecialChars')(m1);
|
|
|
|
return showdown.subParser('encodeEmailAddress')(unescapedStr);
|
|
|
|
});
|
2015-01-16 05:21:33 +08:00
|
|
|
|
2015-01-19 19:37:21 +08:00
|
|
|
return text;
|
2015-01-16 05:21:33 +08:00
|
|
|
|
|
|
|
});
|