Browse Source

Preserve initial position in links

fix #55
pull/14/head
Alex Kocharin 10 years ago
parent
commit
c9adb050e0
  1. 5
      lib/rules_inline/links.js
  2. 10
      test/fixtures/remarkable/commonmark_extras.txt

5
lib/rules_inline/links.js

@ -18,6 +18,7 @@ module.exports = function links(state, silent) {
ref, ref,
code, code,
isImage = false, isImage = false,
oldPos = state.pos,
max = state.posMax, max = state.posMax,
start = state.pos, start = state.pos,
marker = state.src.charCodeAt(start); marker = state.src.charCodeAt(start);
@ -86,7 +87,7 @@ module.exports = function links(state, silent) {
} }
if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) { if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
state.pos = labelStart - 1; state.pos = oldPos;
return false; return false;
} }
pos++; pos++;
@ -121,7 +122,7 @@ module.exports = function links(state, silent) {
ref = state.env.references[normalizeReference(label)]; ref = state.env.references[normalizeReference(label)];
if (!ref) { if (!ref) {
state.pos = labelStart - 1; state.pos = oldPos;
return false; return false;
} }
href = ref.href; href = ref.href;

10
test/fixtures/remarkable/commonmark_extras.txt

@ -77,3 +77,13 @@ Link label has priority over emphasis (not covered by stmd tests):
<p>**<a href="">link**</a></p> <p>**<a href="">link**</a></p>
. .
Issue #55:
.
![test]
![test](foo bar)
.
<p>![test]</p>
<p>![test](foo bar)</p>
.

Loading…
Cancel
Save