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,
code,
isImage = false,
oldPos = state.pos,
max = state.posMax,
start = state.pos,
marker = state.src.charCodeAt(start);
@ -86,7 +87,7 @@ module.exports = function links(state, silent) {
}
if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
state.pos = labelStart - 1;
state.pos = oldPos;
return false;
}
pos++;
@ -121,7 +122,7 @@ module.exports = function links(state, silent) {
ref = state.env.references[normalizeReference(label)];
if (!ref) {
state.pos = labelStart - 1;
state.pos = oldPos;
return false;
}
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>
.
Issue #55:
.
![test]
![test](foo bar)
.
<p>![test]</p>
<p>![test](foo bar)</p>
.

Loading…
Cancel
Save