From c248b82fdb3bb110b45427d3a59c8ba0be7a64f7 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Tue, 28 Dec 2021 10:42:55 +0800 Subject: [PATCH] quick fix --- packages/docusaurus-utils/src/markdownLinks.ts | 9 ++++++++- .../markdown-features/markdown-features-code-blocks.mdx | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-utils/src/markdownLinks.ts b/packages/docusaurus-utils/src/markdownLinks.ts index 6379d7cd3849..2938eef4e13b 100644 --- a/packages/docusaurus-utils/src/markdownLinks.ts +++ b/packages/docusaurus-utils/src/markdownLinks.ts @@ -45,9 +45,16 @@ export function replaceMarkdownLinks({ // Replace internal markdown linking (except in fenced blocks). let fencedBlock = false; + let lastCodeFence = ''; const lines = fileString.split('\n').map((line) => { if (line.trim().startsWith('```')) { - fencedBlock = !fencedBlock; + if (!fencedBlock) { + fencedBlock = true; + [lastCodeFence] = line.trim().match(/^`+/)!; + // If we are in a ````-fenced block, all ``` would be plain text instead of fences + } else if (line.trim().match(/^`+/)![0].length >= lastCodeFence.length) { + fencedBlock = false; + } } if (fencedBlock) { return line; diff --git a/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx b/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx index da94b58e8054..3361ba7b2b0a 100644 --- a/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx +++ b/website/docs/guides/markdown-features/markdown-features-code-blocks.mdx @@ -217,7 +217,7 @@ export default MyComponent; :::tip prefer comments -Prefer highlighting with comments where you can. This way, highlight is inlined in the code, and if you add/remove lines, you don't have to offset your line ranges. You also don't have to manually count the lines if your code block becomes long. +Prefer highlighting with comments where you can. By inlining highlight in the code, you don't have to manually count the lines if your code block becomes long. If you add/remove lines, you also don't have to offset your line ranges. ````diff - ```jsx {3} @@ -233,6 +233,8 @@ Prefer highlighting with comments where you can. This way, highlight is inlined ``` ```` +In the future, we may extend the magic comment system and let you define custom directives and their functionalities. The magic comments would only be parsed if a highlight metastring is not present. + ::: ## Interactive code editor {#interactive-code-editor}