diff --git a/tests/fixtures/within-code.html b/tests/fixtures/within-code.html
new file mode 100644
index 0000000..3c5e69b
--- /dev/null
+++ b/tests/fixtures/within-code.html
@@ -0,0 +1,3 @@
+
Test Markdown File
+[[wiki link]]
+This contains a wiki link [[wiki link]]
within an inline code element. This sentance does not: Wiki Link.
diff --git a/tests/fixtures/within-code.md b/tests/fixtures/within-code.md
new file mode 100644
index 0000000..1511178
--- /dev/null
+++ b/tests/fixtures/within-code.md
@@ -0,0 +1,7 @@
+# Test Markdown File
+
+```
+[[wiki link]]
+```
+
+This contains a wiki link `[[wiki link]]` within an inline code element. This sentance does not: [[wiki link]].
diff --git a/tests/markdown-wikilink-renderer.test.js b/tests/markdown-wikilink-renderer.test.js
index b514b78..0426c0a 100644
--- a/tests/markdown-wikilink-renderer.test.js
+++ b/tests/markdown-wikilink-renderer.test.js
@@ -91,6 +91,33 @@ test('inline rule correctly parses single embed', t => {
);
});
+test('inline rule ignores wikilink within code and pre tags', t => {
+ const wikilinkParser = new WikilinkParser(opts, new Set(), new Map());
+
+ wikilinkParser.linkCache.set('[[wiki link]]', {
+ title: 'Wiki Link',
+ link: '[[wiki link]]',
+ href: '/wiki-link/',
+ content: 'Wiki Link',
+ isEmbed: false,
+ });
+
+ const md = MarkdownIt({html: true});
+ md.inline.ruler.push('inline_wikilink', wikilinkInlineRule(
+ wikilinkParser
+ ));
+
+ md.renderer.rules.inline_wikilink = wikilinkRenderRule();
+
+ const markdown = fs.readFileSync(__dirname + '/fixtures/within-code.md', {encoding:'utf8', flag:'r'});
+ const html = fs.readFileSync(__dirname + '/fixtures/within-code.html', {encoding:'utf8', flag:'r'});
+
+ t.is(
+ normalize(md.render(markdown)),
+ normalize(html)
+ );
+});
+
test('inline rule correctly parses mixed wikilink and embed in multiline input', t => {
const wikilinkParser = new WikilinkParser(opts, new Set(), new Map());