From 8ac28531279be319dee702536331bcd495d7cd90 Mon Sep 17 00:00:00 2001 From: Dmitry Sharabin Date: Thu, 29 May 2025 12:49:08 +0200 Subject: [PATCH 1/2] Fix the Markdown language - Add the missing inside token and fix the existing one - Fix the regexp that is too greedy now: if we have more than one code block next to each other, all of them starting from the second one will be interpreted as a code block of the first one --- src/languages/markdown.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/languages/markdown.ts b/src/languages/markdown.ts index a6af63c4f4..6a559fb0cb 100644 --- a/src/languages/markdown.ts +++ b/src/languages/markdown.ts @@ -95,9 +95,10 @@ export default { // code block // ``` pattern: - /^```(?[a-z-]+)(?:.+)?(?:\n|\r\n?)(?[\s\S]*)?(?:\n|\r\n?)```$/i, + /^```(?[a-z-]+)(?:.+)?(?:\n|\r\n?)(?[\s\S]*?)(?:\n|\r\n?)```$/im, inside: { - 'code-block': groups => groups.codeLanguage, + 'code-language': groups => groups.codeLanguage, + 'code-block': groups => groups.codeBlock, 'punctuation': /```/, }, }, From aae926dc8b39cedcbabb4eff197b8c094e65dc77 Mon Sep 17 00:00:00 2001 From: Dmitry Sharabin Date: Thu, 29 May 2025 16:12:33 +0200 Subject: [PATCH 2/2] Ignore spaces before the language code --- src/languages/markdown.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/markdown.ts b/src/languages/markdown.ts index 6a559fb0cb..1aa9954386 100644 --- a/src/languages/markdown.ts +++ b/src/languages/markdown.ts @@ -95,7 +95,7 @@ export default { // code block // ``` pattern: - /^```(?[a-z-]+)(?:.+)?(?:\n|\r\n?)(?[\s\S]*?)(?:\n|\r\n?)```$/im, + /^```(?:\s*)(?[a-z-]+)(?:.+)?(?:\n|\r\n?)(?[\s\S]*?)(?:\n|\r\n?)```$/im, inside: { 'code-language': groups => groups.codeLanguage, 'code-block': groups => groups.codeBlock,