Skip to content

Commit ebd893f

Browse files
committed
add unit test to demonstrate that we don't normally touch markdown links inside of code blocks
1 parent 361ec74 commit ebd893f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/plugins/internalLinks.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,50 @@ Callouts inline [great page](/hello-world).
458458
);
459459
});
460460

461+
test("internal link inside codeblock ignored", async () => {
462+
const targetPageId = "123";
463+
const targetPage: NotionPage = makeSamplePageObject({
464+
slug: "hello-world",
465+
name: "Hello World",
466+
id: targetPageId,
467+
});
468+
469+
const results = await getMarkdown(
470+
{
471+
type: "code",
472+
code: {
473+
caption: [],
474+
rich_text: [
475+
{
476+
type: "text",
477+
text: {
478+
content:
479+
"this should not change [link](https://www.notion.so/native/metapages/mypage)",
480+
link: null,
481+
},
482+
annotations: {
483+
bold: false,
484+
italic: false,
485+
strikethrough: false,
486+
underline: false,
487+
code: false,
488+
color: "default",
489+
},
490+
plain_text:
491+
"this should not change [link](https://www.notion.so/native/metapages/mypage)",
492+
href: null,
493+
},
494+
],
495+
language: "javascript", // notion assumed javascript in my test in which I didn't specify a language
496+
},
497+
},
498+
targetPage
499+
);
500+
expect(results.trim()).toContain(
501+
"this should not change [link](https://www.notion.so/native/metapages/mypage)"
502+
);
503+
});
504+
461505
async function getMarkdown(block: object, targetPage?: NotionPage) {
462506
const config = {
463507
plugins: [

0 commit comments

Comments
 (0)