From ccc3ac7c661295375d245574ec1125c6c00fe119 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Fri, 29 Oct 2021 22:43:34 +0200 Subject: [PATCH] Apply relativeBaseURL to parse urls --- editor/src/wikilinks2.js | 2 +- editor/test/markdown.test.js | 8 ++++---- editor/test/wikilinks2.test.js | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/editor/src/wikilinks2.js b/editor/src/wikilinks2.js index a58d83d..34904de 100644 --- a/editor/src/wikilinks2.js +++ b/editor/src/wikilinks2.js @@ -67,7 +67,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 87c77f9..94e5138 100644 --- a/editor/test/markdown.test.js +++ b/editor/test/markdown.test.js @@ -51,16 +51,16 @@ describe('MD', function () { assert.deepStrictEqual(MD.renderInline("test #[[TODO]] test2"), 'test test2') }) it('parseLinks 4', function () { - assert.deepStrictEqual(MD.renderInline("test [[test]] [[test2]] [[test3]]"), 'test test test2 test3') + assert.deepStrictEqual(MD.renderInline("test [[test]] [[test2]] [[test3]]"), 'test test test2 test3') }) it('parseLinks 5', function () { - assert.deepStrictEqual(MD.renderInline("test [[test]]"), 'test test') + assert.deepStrictEqual(MD.renderInline("test [[test]]"), 'test test') }) it('parseLinks 6', function () { - assert.deepStrictEqual(MD.renderInline("test [[test]] [[test2]]"), 'test test test2') + assert.deepStrictEqual(MD.renderInline("test [[test]] [[test2]]"), 'test test test2') }) it('parseLinks tag', function () { - assert.deepStrictEqual(MD.renderInline("test #[[test]]"), 'test #test') + assert.deepStrictEqual(MD.renderInline("test #[[test]]"), 'test #test') }) }) diff --git a/editor/test/wikilinks2.test.js b/editor/test/wikilinks2.test.js index b1e43c9..02ee2cf 100644 --- a/editor/test/wikilinks2.test.js +++ b/editor/test/wikilinks2.test.js @@ -114,4 +114,24 @@ describe('linkParser', function () { }] }) }) + + it('parse text and two links', function () { + let state = {src: '1234 [[hello [[world]] Link2]]', pos: 5, tokens: []}; + state.__proto__.push = function (id, s, x) { + let token = {id, s, x}; + this.tokens.push(token) + return token + } + assert.deepStrictEqual(linkParser('test', state), true); + assert.deepStrictEqual(state, { + src: '1234 [[hello [[world]] Link2]]', + pos: 30, + tokens: [{ + id: 'test', + s: '', + x: 0, + meta: {match:'hello [[world]] Link2', tag: false} + }] + }) + }) })