diff --git a/dist/showdown.js b/dist/showdown.js index 8b7e44d..af4d5e3 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 31a0dc6..bbfc3eb 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index dde4210..0f229ce 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index 70c1a54..84fbe2a 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/subParsers/autoLinks.js b/src/subParsers/autoLinks.js index 4bf53e9..44ec9e4 100644 --- a/src/subParsers/autoLinks.js +++ b/src/subParsers/autoLinks.js @@ -6,8 +6,8 @@ showdown.subParser('autoLinks', function (text, options, globals) { var simpleURLRegex = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)()(?=\s|$)(?!["<>])/gi, simpleURLRegex2 = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?()]?)(?=\s|$)(?!["<>])/gi, delimUrlRegex = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi, - simpleMailRegex = /(?:^|\s)([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?:$|\s)/gi, - delimMailRegex = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi; + simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi, + delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi; text = text.replace(delimUrlRegex, replaceLink); text = text.replace(delimMailRegex, replaceMail); @@ -35,8 +35,9 @@ showdown.subParser('autoLinks', function (text, options, globals) { return '' + lnkTxt + '' + append; } - function replaceMail(wholeMatch, mail) { + function replaceMail(wholeMatch, b, mail) { var href = 'mailto:'; + b = b || ''; mail = showdown.subParser('unescapeSpecialChars')(mail); if (options.encodeEmails) { mail = showdown.helper.encodeEmailAddress(mail); @@ -44,7 +45,7 @@ showdown.subParser('autoLinks', function (text, options, globals) { } else { href = href + mail; } - return '' + mail + ''; + return b + '' + mail + ''; } text = globals.converter._dispatch('autoLinks.after', text, options, globals); diff --git a/test/features/#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail.html b/test/features/#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail.html new file mode 100644 index 0000000..e82b0ba --- /dev/null +++ b/test/features/#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail.html @@ -0,0 +1 @@ +
Just an example info@example.com ok?
diff --git a/test/features/#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail.md b/test/features/#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail.md new file mode 100644 index 0000000..ceb08b1 --- /dev/null +++ b/test/features/#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail.md @@ -0,0 +1 @@ +Just an example info@example.com ok? \ No newline at end of file diff --git a/test/node/testsuite.features.js b/test/node/testsuite.features.js index f2bccc0..505cafc 100644 --- a/test/node/testsuite.features.js +++ b/test/node/testsuite.features.js @@ -55,6 +55,8 @@ describe('makeHtml() features testsuite', function () { converter = new showdown.Converter({ghMentions: true}); } else if (testsuite[i].name === 'disable-email-encoding') { converter = new showdown.Converter({encodeEmails: false}); + } else if (testsuite[i].name === '#330.simplifiedAutoLink-drops-character-before-and-after-linked-mail') { + converter = new showdown.Converter({encodeEmails: false, simplifiedAutoLink: true}); } else { converter = new showdown.Converter(); }