Skip to content

Commit

Permalink
chore: add test that inline rule correctly displays anchor links
Browse files Browse the repository at this point in the history
  • Loading branch information
carbontwelve committed May 1, 2024
1 parent 7d541b5 commit 716b5f5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/markdown-wikilink-renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,32 @@ test('inline rule correctly displays unable to load embed content', t => {
md.render('Hello world this is a ![[wiki-embed]]'),
"<p>Hello world this is a [TESTING]</p>\n"
);
});

test('inline rule correctly displays anchor links', t => {
const wikilinkParser = new WikilinkParser(opts, new Set);
const compiledEmbeds = new Map;

wikilinkParser.linkCache.set('[[wiki link#heading-id]]', {
title: 'Wiki Link',
href: '/wiki-link/',
anchor: 'heading-id',
isEmbed: false,
});

const md = require('markdown-it')({html: true});
md.inline.ruler.push('inline_wikilink', wikilinkInlineRule(
wikilinkParser
));

md.renderer.rules.inline_wikilink = wikilinkRenderRule(
wikilinkParser,
compiledEmbeds,
opts
);

t.is(
"<p>Hello world, this is some text with a <a href=\"/wiki-link/#heading-id\">Wiki Link</a> inside!</p>\n",
md.render('Hello world, this is some text with a [[wiki link#heading-id]] inside!', {})
);
})

0 comments on commit 716b5f5

Please sign in to comment.