Skip to content

Commit

Permalink
fix gfm extended autolinking requiring multiple backpedals
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Trott committed Jun 22, 2018
1 parent 666e455 commit 1e48dfa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ InlineLexer.prototype.output = function(src) {
text,
href,
title,
cap;
cap,
prevCapZero;

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

// url (gfm)
if (!this.inLink && (cap = this.rules.url.exec(src))) {
cap[0] = this.rules._backpedal.exec(cap[0])[0];
do {
prevCapZero = cap[0];
cap[0] = this.rules._backpedal.exec(cap[0])[0];
} while (prevCapZero !== cap[0]);
src = src.substring(cap[0].length);
if (cap[2] === '@') {
text = escape(cap[0]);
Expand Down
Loading

0 comments on commit 1e48dfa

Please sign in to comment.