Skip to content

Commit

Permalink
Merge pull request markedjs#1293 from Trott/trailing-period
Browse files Browse the repository at this point in the history
fix gfm extended autolinking requiring multiple backpedals
  • Loading branch information
styfle authored Jul 5, 2018
2 parents ab5dfd2 + 83a8835 commit a562ab3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 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
16 changes: 14 additions & 2 deletions test/specs/marked/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,23 @@ Messenger.prototype.test = function(spec, section, ignore) {

var messenger = new Messenger();

describe('Marked Autolinks', function() {
var section = 'Autolinks';

var shouldPassButFails = [];

var willNotBeAttemptedByCoreTeam = [];

var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);

markedSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});

describe('Marked Code spans', function() {
var section = 'Code spans';

// var shouldPassButFails = [];
var shouldPassButFails = [1];

var willNotBeAttemptedByCoreTeam = [];
Expand Down Expand Up @@ -64,7 +77,6 @@ describe('Marked Links', function() {
describe('Marked Table cells', function() {
var section = 'Table cells';

// var shouldPassButFails = [];
var shouldPassButFails = [];

var willNotBeAttemptedByCoreTeam = [];
Expand Down
18 changes: 18 additions & 0 deletions test/specs/marked/marked.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"section": "Autolinks",
"markdown": "(See https://www.example.com/fhqwhgads.)",
"html": "<p>(See <a href=\"https://www.example.com/fhqwhgads\">https://www.example.com/fhqwhgads</a>.)</p>",
"example": 10
},
{
"section": "Autolinks",
"markdown": "((http://foo.com))",
"html": "<p>((<a href=\"http://foo.com\">http://foo.com</a>))</p>",
"example": 11
},
{
"section": "Autolinks",
"markdown": "((http://foo.com.))",
"html": "<p>((<a href=\"http://foo.com\">http://foo.com</a>.))</p>",
"example": 12
},
{
"section": "Code spans",
"markdown": "`someone@example.com`",
Expand Down

0 comments on commit a562ab3

Please sign in to comment.