From 984c365aebec20b87f76791c7d511e32bf3a31f6 Mon Sep 17 00:00:00 2001 From: Federico Soave Date: Tue, 18 Sep 2018 21:26:09 +0200 Subject: [PATCH] [gfm] use new extended email autolink rule to avoid autolinking email addresses in code spans (fixes #1218) --- lib/marked.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index 79478498c9..85e2ebabe3 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -605,9 +605,8 @@ inline.pedantic = merge({}, inline.normal, { inline.gfm = merge({}, inline.normal, { escape: edit(inline.escape).replace('])', '~|])').getRegex(), - url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/) - .replace('email', inline._email) - .getRegex(), + _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, + url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, del: /^~+(?=\S)([\s\S]*?\S)~+/, text: edit(inline.text) @@ -616,6 +615,9 @@ inline.gfm = merge({}, inline.normal, { .getRegex() }); +inline.gfm.url = edit(inline.gfm.url) + .replace('email', inline.gfm._extended_email) + .getRegex(); /** * GFM + Line Breaks Inline Grammar */