From 8470c1cae8341f37af0804e8de46b1525aecf2d0 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Sat, 27 Dec 2014 09:22:54 +0300 Subject: [PATCH] Fix an issue with links skipping space after them --- lib/rules_inline/links.js | 4 +++- test/fixtures/commonmark/bad.txt | 16 ---------------- test/fixtures/commonmark/good.txt | 11 +++++++++++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/rules_inline/links.js b/lib/rules_inline/links.js index 8823139..004fcad 100644 --- a/lib/rules_inline/links.js +++ b/lib/rules_inline/links.js @@ -114,8 +114,10 @@ module.exports = function links(state, silent) { if (pos >= 0) { label = state.src.slice(start, pos++); } else { - pos = start - 1; + pos = labelEnd + 1; } + } else { + pos = labelEnd + 1; } // covers label === '' and label === undefined diff --git a/test/fixtures/commonmark/bad.txt b/test/fixtures/commonmark/bad.txt index 99fae07..82fcb0a 100644 --- a/test/fixtures/commonmark/bad.txt +++ b/test/fixtures/commonmark/bad.txt @@ -58,19 +58,3 @@ error:

foo bar [baz][ref]

-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -src line: 5915 - -. -[foo] bar - -[foo]: /url -. -

foo bar

-. - -error: - -

foobar

- - diff --git a/test/fixtures/commonmark/good.txt b/test/fixtures/commonmark/good.txt index cff2f5c..4a0e233 100644 --- a/test/fixtures/commonmark/good.txt +++ b/test/fixtures/commonmark/good.txt @@ -5204,6 +5204,17 @@ src line: 5905

Foo

. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +src line: 5915 + +. +[foo] bar + +[foo]: /url +. +

foo bar

+. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src line: 5926