Skip to content

Commit 3ef341b

Browse files
notriddlejgm
authored andcommitted
Fix title-related backtracking with empty string
Fixes #281
1 parent ba128a8 commit 3ef341b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/inlines.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,21 +884,20 @@ var parseReference = function(s, refmap) {
884884
title = this.parseLinkTitle();
885885
}
886886
if (title === null) {
887-
title = "";
888887
// rewind before spaces
889888
this.pos = beforetitle;
890889
}
891890

892891
// make sure we're at line end:
893892
var atLineEnd = true;
894893
if (this.match(reSpaceAtEndOfLine) === null) {
895-
if (title === "") {
894+
if (title === null) {
896895
atLineEnd = false;
897896
} else {
898897
// the potential title we found is not at the line end,
899898
// but it could still be a legal link reference if we
900899
// discard the title
901-
title = "";
900+
title = null;
902901
// rewind before spaces
903902
this.pos = beforetitle;
904903
// and instead check if the link URL is at the line end
@@ -919,7 +918,7 @@ var parseReference = function(s, refmap) {
919918
}
920919

921920
if (!refmap[normlabel]) {
922-
refmap[normlabel] = { destination: dest, title: title };
921+
refmap[normlabel] = { destination: dest, title: title === null ? "" : title };
923922
}
924923
return this.pos - startpos;
925924
};

test/regression.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,11 @@ x <- 1
484484
<p>&amp;para</p>
485485
<p>¶</p>
486486
````````````````````````````````
487+
488+
#281
489+
```````````````````````````````` example
490+
[test]:example
491+
""third [test]
492+
.
493+
<p>&quot;&quot;third <a href="example">test</a></p>
494+
````````````````````````````````

0 commit comments

Comments
 (0)