diff --git a/editor/src/wikilinks2.js b/editor/src/wikilinks2.js index 34904de..5e455d1 100644 --- a/editor/src/wikilinks2.js +++ b/editor/src/wikilinks2.js @@ -21,7 +21,7 @@ Plugin.prototype.init = function (md) { md.renderer.rules[this.id] = this.render.bind(this) } -export function linkParser(id, state) { +export function linkParser(id, state, silent) { let input = state.src.slice(state.pos); const match = /^#?\[\[/.exec(input) if (!match) { @@ -44,9 +44,11 @@ export function linkParser(id, state) { } if (open === 0) { - let link = state.src.slice(state.pos + prefixLength, p - 2) - let token = state.push(id, '', 0) - token.meta = {match: link, tag: prefixLength === 3} + if (!silent) { + let link = state.src.slice(state.pos + prefixLength, p - 2) + let token = state.push(id, '', 0) + token.meta = {match: link, tag: prefixLength === 3} + } state.pos = p return true } @@ -55,7 +57,7 @@ export function linkParser(id, state) { } Plugin.prototype.parse = function (state, silent) { - return linkParser(this.id, state) + return linkParser(this.id, state, silent) } Plugin.prototype.render = function (tokens, id, options, env) { @@ -67,7 +69,7 @@ Plugin.prototype.render = function (tokens, id, options, env) { return ''; } } - return '' + (tag ? '#' : '') + link + ''; + return '' + (tag ? '#' : '') + link + ''; } export default (options) => { diff --git a/editor/test/markdown.test.js b/editor/test/markdown.test.js index 94e5138..3bce29a 100644 --- a/editor/test/markdown.test.js +++ b/editor/test/markdown.test.js @@ -63,4 +63,8 @@ describe('MD', function () { it('parseLinks tag', function () { assert.deepStrictEqual(MD.renderInline("test #[[test]]"), 'test #test') }) + + it('parseLinks double url', function () { + assert.deepStrictEqual(MD.renderInline("[[test [[link]] test2]]"), 'test [[link]] test2') + }) })