Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix title-related backtracking with empty string #282

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,21 +884,20 @@ var parseReference = function(s, refmap) {
title = this.parseLinkTitle();
}
if (title === null) {
title = "";
// rewind before spaces
this.pos = beforetitle;
}

// make sure we're at line end:
var atLineEnd = true;
if (this.match(reSpaceAtEndOfLine) === null) {
if (title === "") {
if (title === null) {
atLineEnd = false;
} else {
// the potential title we found is not at the line end,
// but it could still be a legal link reference if we
// discard the title
title = "";
title = null;
// rewind before spaces
this.pos = beforetitle;
// and instead check if the link URL is at the line end
Expand All @@ -919,7 +918,7 @@ var parseReference = function(s, refmap) {
}

if (!refmap[normlabel]) {
refmap[normlabel] = { destination: dest, title: title };
refmap[normlabel] = { destination: dest, title: title === null ? "" : title };
}
return this.pos - startpos;
};
Expand Down
8 changes: 8 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,11 @@ x <- 1
<p>&amp;para</p>
<p>¶</p>
````````````````````````````````

#281
```````````````````````````````` example
[test]:example
""third [test]
.
<p>&quot;&quot;third <a href="example">test</a></p>
````````````````````````````````
Loading