Skip to content

Commit c488aca

Browse files
authored
Merge branch 'master' into fix-deflists
2 parents bc8ba4f + 9b3f442 commit c488aca

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/Markdig.Tests/MiscTests.cs

+27
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,31 @@ public void TestDefinitionListInListItemWithBlankLine()
339339
";
340340
TestParser.TestSpec(input, expected, new MarkdownPipelineBuilder().UseDefinitionLists().Build());
341341
}
342+
343+
[Test]
344+
public void TestAlertWithinAlertOrNestedBlock()
345+
{
346+
var input = @"
347+
>[!NOTE]
348+
[!NOTE]
349+
The second one is not a note.
350+
351+
>>[!NOTE]
352+
Also not a note.
353+
";
354+
355+
var expected = @"<div class=""markdown-alert markdown-alert-note"">
356+
<p class=""markdown-alert-title""><svg viewBox=""0 0 16 16"" version=""1.1"" width=""16"" height=""16"" aria-hidden=""true""><path d=""M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z""></path></svg>Note</p>
357+
<p>[!NOTE]
358+
The second one is not a note.</p>
359+
</div>
360+
<blockquote>
361+
<blockquote>
362+
<p>[!NOTE]
363+
Also not a note.</p>
364+
</blockquote>
365+
</blockquote>
366+
";
367+
TestParser.TestSpec(input, expected, new MarkdownPipelineBuilder().UseAlertBlocks().Build());
368+
}
342369
}

src/Markdig/Extensions/Alerts/AlertInlineParser.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
2929
// We expect the alert to be the first child of a quote block. Example:
3030
// > [!NOTE]
3131
// > This is a note
32-
if (processor.Block is not ParagraphBlock paragraphBlock || paragraphBlock.Parent is not QuoteBlock quoteBlock || paragraphBlock.Inline?.FirstChild != null)
32+
if (processor.Block is not ParagraphBlock paragraphBlock || paragraphBlock.Parent is not QuoteBlock quoteBlock || paragraphBlock.Inline?.FirstChild != null
33+
|| quoteBlock is AlertBlock || quoteBlock.Parent is not MarkdownDocument)
3334
{
3435
return false;
3536
}

0 commit comments

Comments
 (0)