diff --git a/lib/rules_inline/link.js b/lib/rules_inline/link.js index 4b9056f..7c9834c 100644 --- a/lib/rules_inline/link.js +++ b/lib/rules_inline/link.js @@ -20,7 +20,8 @@ module.exports = function link(state, silent) { href = '', oldPos = state.pos, max = state.posMax, - start = state.pos; + start = state.pos, + parseReference = true; if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; } @@ -36,6 +37,9 @@ module.exports = function link(state, silent) { // Inline link // + // might have found a valid shortcut link, disable reference parsing + parseReference = false; + // [link]( "title" ) // ^^ skipping these spaces pos++; @@ -84,11 +88,13 @@ module.exports = function link(state, silent) { } if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) { - state.pos = oldPos; - return false; + // parsing a valid shortcut link failed, fallback to reference + parseReference = true; } pos++; - } else { + } + + if (parseReference) { // // Link reference //