123456789101112131415161718192021222324252627 |
- showdown.subParser('autoLinks', function (text, options) {
- 'use strict';
- //simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[-.+~:?#@!$&'()*,;=[\]\w]+)\b/gi,
- var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,
- delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,
- simpleMailRegex = /\b(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)\b/gi,
- delimMailRegex = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
- text = text.replace(delimUrlRegex, '<a href=\"$1\">$1</a>');
- text = text.replace(delimMailRegex, replaceMail);
- //simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[-.+~:?#@!$&'()*,;=[\]\w]+)\b/gi,
- // Email addresses: <address@domain.foo>
- if (options.simplifiedAutoLink) {
- text = text.replace(simpleURLRegex, '<a href=\"$1\">$1</a>');
- text = text.replace(simpleMailRegex, '<a href=\"$1\">$1</a>');
- }
- function replaceMail(wholeMatch, m1) {
- var unescapedStr = showdown.subParser('unescapeSpecialChars')(m1);
- return showdown.subParser('encodeEmailAddress')(unescapedStr);
- }
- return text;
- });
|