mirror of
https://github.com/markedjs/marked
synced 2024-11-23 01:38:57 +00:00
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.
This commit is contained in:
parent
666e4558b0
commit
a3cddeeae6
@ -655,7 +655,8 @@ InlineLexer.prototype.output = function(src) {
|
||||
text,
|
||||
href,
|
||||
title,
|
||||
cap;
|
||||
cap,
|
||||
prevCapZero;
|
||||
|
||||
while (src) {
|
||||
// escape
|
||||
@ -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]);
|
||||
|
@ -32,6 +32,21 @@ Messenger.prototype.test = function(spec, section, ignore) {
|
||||
|
||||
var messenger = new Messenger();
|
||||
|
||||
describe('Marked Autolinks', function() {
|
||||
var section = 'Autolinks';
|
||||
|
||||
// var shouldPassButFails = [];
|
||||
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';
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
[
|
||||
{
|
||||
"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": "Code spans",
|
||||
"markdown": "`someone@example.com`",
|
||||
|
Loading…
Reference in New Issue
Block a user