diff --git a/src/Markdig.Tests/MiscTests.cs b/src/Markdig.Tests/MiscTests.cs index 85847988..0d3d14dd 100644 --- a/src/Markdig.Tests/MiscTests.cs +++ b/src/Markdig.Tests/MiscTests.cs @@ -317,4 +317,31 @@ public void RootInlineInTableCellHasCorrectSourceSpan() Assert.That(paragraph.Inline.Span.Start == paragraph.Inline.FirstChild.Span.Start); Assert.That(paragraph.Inline.Span.End == paragraph.Inline.LastChild.Span.End); } + + [Test] + public void TestAlertWithinAlertOrNestedBlock() + { + var input = @" +>[!NOTE] +[!NOTE] +The second one is not a note. + +>>[!NOTE] +Also not a note. +"; + + var expected = @"
+

Note

+

[!NOTE] +The second one is not a note.

+
+
+
+

[!NOTE] +Also not a note.

+
+
+"; + TestParser.TestSpec(input, expected, new MarkdownPipelineBuilder().UseAlertBlocks().Build()); + } } diff --git a/src/Markdig/Extensions/Alerts/AlertInlineParser.cs b/src/Markdig/Extensions/Alerts/AlertInlineParser.cs index 6f95c5b6..faf56859 100644 --- a/src/Markdig/Extensions/Alerts/AlertInlineParser.cs +++ b/src/Markdig/Extensions/Alerts/AlertInlineParser.cs @@ -29,7 +29,8 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice) // We expect the alert to be the first child of a quote block. Example: // > [!NOTE] // > This is a note - if (processor.Block is not ParagraphBlock paragraphBlock || paragraphBlock.Parent is not QuoteBlock quoteBlock || paragraphBlock.Inline?.FirstChild != null) + if (processor.Block is not ParagraphBlock paragraphBlock || paragraphBlock.Parent is not QuoteBlock quoteBlock || paragraphBlock.Inline?.FirstChild != null + || quoteBlock is AlertBlock || quoteBlock.Parent is not MarkdownDocument) { return false; }