From dbaac498786f21f342d881cb67e55fb7ee59b0ac Mon Sep 17 00:00:00 2001 From: Anis Ladram Date: Wed, 5 Dec 2018 18:03:12 -0500 Subject: [PATCH 1/2] Changed order of autolink processing --- lib/marked.js | 74 +++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index c25fa07c39..09aa559a9a 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -694,43 +694,6 @@ InlineLexer.prototype.output = function(src) { continue; } - // autolink - if (cap = this.rules.autolink.exec(src)) { - src = src.substring(cap[0].length); - if (cap[2] === '@') { - text = escape(this.mangle(cap[1])); - href = 'mailto:' + text; - } else { - text = escape(cap[1]); - href = text; - } - out += this.renderer.link(href, null, text); - continue; - } - - // url (gfm) - if (!this.inLink && (cap = this.rules.url.exec(src))) { - if (cap[2] === '@') { - text = escape(cap[0]); - href = 'mailto:' + text; - } else { - // do extended autolink path validation - do { - prevCapZero = cap[0]; - cap[0] = this.rules._backpedal.exec(cap[0])[0]; - } while (prevCapZero !== cap[0]); - text = escape(cap[0]); - if (cap[1] === 'www.') { - href = 'http://' + text; - } else { - href = text; - } - } - src = src.substring(cap[0].length); - out += this.renderer.link(href, null, text); - continue; - } - // tag if (cap = this.rules.tag.exec(src)) { if (!this.inLink && /^ Date: Wed, 5 Dec 2018 19:37:18 -0500 Subject: [PATCH 2/2] Added a test for the case: __test@test.com__ --- test/specs/marked/marked.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/specs/marked/marked.json b/test/specs/marked/marked.json index a42f6dc981..b64eda14cf 100644 --- a/test/specs/marked/marked.json +++ b/test/specs/marked/marked.json @@ -95,6 +95,12 @@ "html": "

me@example.com

", "example": 1327 }, + { + "section": "Autolinks", + "markdown": "__test@test.com__", + "html": "

test@test.com

", + "example": 1347 + }, { "section": "Emphasis extra tests", "markdown": "_test_. _test_: _test_! _test_? _test_-",