/* * Wiki - A wiki with editor * Copyright (c) 2021 Peter Stuifzand * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import assert from 'assert' import MarkdownIt from "markdown-it"; import MarkdownItWikilinks2 from "../src/wikilinks2"; const MD = new MarkdownIt({ linkify: false, highlight: function (str, lang) { if (lang === 'mermaid') { return '
' + str + '
'; } return ''; } }) MD.use(MarkdownItWikilinks2({ baseURL: 'http://localhost/', uriSuffix: '', relativeBaseURL: '/edit/', htmlAttributes: { class: 'wiki-link' }, })) describe('MD', function () { it('parseLinks', function () { assert.deepStrictEqual(MD.renderInline("#[[TODO]]"), '') assert.deepStrictEqual(MD.renderInline("#[[TODO]] #[[DONE]]"), ' ') }) it('parseLinks 2', function () { assert.deepStrictEqual(MD.renderInline("#[[TODO]] #[[DONE]]"), ' ') }) it('parseLinks 3', 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') }) it('parseLinks 5', function () { assert.deepStrictEqual(MD.renderInline("test [[test]]"), 'test test') }) it('parseLinks 6', function () { assert.deepStrictEqual(MD.renderInline("test [[test]] [[test2]]"), 'test test test2') }) 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') }) })