Skip to content

Commit 1e48dfa

Browse files
committed
fix gfm extended autolinking requiring multiple backpedals
Add a test and fix that trailing punctuation is omitted in link URLs for markdown like this: (See https://www.example.com/fhqwhgads.) The trailing period and closing parenthesis should not be part of the link URL.
1 parent 666e455 commit 1e48dfa

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

lib/marked.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ InlineLexer.prototype.output = function(src) {
655655
text,
656656
href,
657657
title,
658-
cap;
658+
cap,
659+
prevCapZero;
659660

660661
while (src) {
661662
// escape
@@ -681,7 +682,10 @@ InlineLexer.prototype.output = function(src) {
681682

682683
// url (gfm)
683684
if (!this.inLink && (cap = this.rules.url.exec(src))) {
684-
cap[0] = this.rules._backpedal.exec(cap[0])[0];
685+
do {
686+
prevCapZero = cap[0];
687+
cap[0] = this.rules._backpedal.exec(cap[0])[0];
688+
} while (prevCapZero !== cap[0]);
685689
src = src.substring(cap[0].length);
686690
if (cap[2] === '@') {
687691
text = escape(cap[0]);

0 commit comments

Comments
 (0)