Skip to content

Commit 20d3b8c

Browse files
authored
Merge pull request #1385 from anis-ladram/master
Fix bold around autolink email address
2 parents ed64407 + 485248e commit 20d3b8c

File tree

2 files changed

+43
-37
lines changed

2 files changed

+43
-37
lines changed

lib/marked.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -694,43 +694,6 @@ InlineLexer.prototype.output = function(src) {
694694
continue;
695695
}
696696

697-
// autolink
698-
if (cap = this.rules.autolink.exec(src)) {
699-
src = src.substring(cap[0].length);
700-
if (cap[2] === '@') {
701-
text = escape(this.mangle(cap[1]));
702-
href = 'mailto:' + text;
703-
} else {
704-
text = escape(cap[1]);
705-
href = text;
706-
}
707-
out += this.renderer.link(href, null, text);
708-
continue;
709-
}
710-
711-
// url (gfm)
712-
if (!this.inLink && (cap = this.rules.url.exec(src))) {
713-
if (cap[2] === '@') {
714-
text = escape(cap[0]);
715-
href = 'mailto:' + text;
716-
} else {
717-
// do extended autolink path validation
718-
do {
719-
prevCapZero = cap[0];
720-
cap[0] = this.rules._backpedal.exec(cap[0])[0];
721-
} while (prevCapZero !== cap[0]);
722-
text = escape(cap[0]);
723-
if (cap[1] === 'www.') {
724-
href = 'http://' + text;
725-
} else {
726-
href = text;
727-
}
728-
}
729-
src = src.substring(cap[0].length);
730-
out += this.renderer.link(href, null, text);
731-
continue;
732-
}
733-
734697
// tag
735698
if (cap = this.rules.tag.exec(src)) {
736699
if (!this.inLink && /^<a /i.test(cap[0])) {
@@ -831,6 +794,43 @@ InlineLexer.prototype.output = function(src) {
831794
continue;
832795
}
833796

797+
// autolink
798+
if (cap = this.rules.autolink.exec(src)) {
799+
src = src.substring(cap[0].length);
800+
if (cap[2] === '@') {
801+
text = escape(this.mangle(cap[1]));
802+
href = 'mailto:' + text;
803+
} else {
804+
text = escape(cap[1]);
805+
href = text;
806+
}
807+
out += this.renderer.link(href, null, text);
808+
continue;
809+
}
810+
811+
// url (gfm)
812+
if (!this.inLink && (cap = this.rules.url.exec(src))) {
813+
if (cap[2] === '@') {
814+
text = escape(cap[0]);
815+
href = 'mailto:' + text;
816+
} else {
817+
// do extended autolink path validation
818+
do {
819+
prevCapZero = cap[0];
820+
cap[0] = this.rules._backpedal.exec(cap[0])[0];
821+
} while (prevCapZero !== cap[0]);
822+
text = escape(cap[0]);
823+
if (cap[1] === 'www.') {
824+
href = 'http://' + text;
825+
} else {
826+
href = text;
827+
}
828+
}
829+
src = src.substring(cap[0].length);
830+
out += this.renderer.link(href, null, text);
831+
continue;
832+
}
833+
834834
// text
835835
if (cap = this.rules.text.exec(src)) {
836836
src = src.substring(cap[0].length);

test/specs/marked/marked.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@
9595
"html": "<p><strong><a href=\"mailto:[email protected]\">[email protected]</a></strong></p>",
9696
"example": 1327
9797
},
98+
{
99+
"section": "Autolinks",
100+
"markdown": "[email protected]__",
101+
"html": "<p><strong><a href=\"mailto:[email protected]\">[email protected]</a></strong></p>",
102+
"example": 1347
103+
},
98104
{
99105
"section": "Emphasis extra tests",
100106
"markdown": "_test_. _test_: _test_! _test_? _test_-",

0 commit comments

Comments
 (0)