From fb33d8a78f527febcfdf590485b56fe404f6d189 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 19 Dec 2024 20:19:30 +0100 Subject: [PATCH] Callouts should not be parsed from nested code blocks (#120) --- docs/source/markup/callout.md | 1 + docs/source/markup/substitutions.md | 4 ++-- .../Myst/CodeBlocks/EnhancedCodeBlockParser.cs | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/markup/callout.md b/docs/source/markup/callout.md index d310b3ae..32261e28 100644 --- a/docs/source/markup/callout.md +++ b/docs/source/markup/callout.md @@ -13,6 +13,7 @@ project: content: CC-BY-4.0 <1> subject: MyST Markdown ``` +1. The license ### C# diff --git a/docs/source/markup/substitutions.md b/docs/source/markup/substitutions.md index 23318c2d..a78fe82b 100644 --- a/docs/source/markup/substitutions.md +++ b/docs/source/markup/substitutions.md @@ -18,9 +18,9 @@ Substitutions should work in code blocks too. ```{code} sh wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512 -shasum -a 512 -c elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512 <1> +shasum -a 512 -c elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512 tar -xzf elasticsearch-{{version}}-linux-x86_64.tar.gz -cd elasticsearch-{{version}}/ <2> +cd elasticsearch-{{version}}/ ``` diff --git a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs index ae774735..592a5977 100644 --- a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs +++ b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs @@ -94,6 +94,9 @@ public override bool Close(BlockProcessor processor, Block block) span = lines.Lines[index].Slice.AsSpan(); } + if (codeBlock.OpeningFencedCharCount > 3) + continue; + var matchClassicCallout = CallOutParser.CallOutNumber().EnumerateMatches(span); var callOut = EnumerateAnnotations(matchClassicCallout, ref span, ref callOutIndex, originatingLine, false);