Use multiple underscore when there are multiple spaces

This commit is contained in:
Peter Stuifzand 2021-11-06 14:37:03 +01:00
parent 760eb11694
commit 001e4748dd
2 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ Plugin.prototype.render = function (tokens, id, options, env) {
return '<input type="checkbox" class="checkbox" checked>'; return '<input type="checkbox" class="checkbox" checked>';
} }
} }
return '<a href="'+this.options.relativeBaseURL+encodeURIComponent(link.replace(' ', '_')) + '" class="wiki-link">' + (tag ? '#' : '') + link + '</a>'; return '<a href="'+this.options.relativeBaseURL+encodeURIComponent(link.replace(/ +/g, '_')) + '" class="wiki-link">' + (tag ? '#' : '') + link + '</a>';
} }
export default (options) => { export default (options) => {

View File

@ -65,6 +65,6 @@ describe('MD', function () {
}) })
it('parseLinks double url', function () { it('parseLinks double url', function () {
assert.deepStrictEqual(MD.renderInline("[[test [[link]] test2]]"), '<a href="/edit/test_%5B%5Blink%5D%5D%20test2" class="wiki-link">test [[link]] test2</a>') assert.deepStrictEqual(MD.renderInline("[[test [[link]] test2]]"), '<a href="/edit/test_%5B%5Blink%5D%5D_test2" class="wiki-link">test [[link]] test2</a>')
}) })
}) })