Fix blockquote ordered list parsing (#887)

This commit is contained in:
Alexandre Mutel
2026-06-13 14:38:30 +02:00
parent 9dffce52b6
commit bc4e399087
3 changed files with 69 additions and 1 deletions

View File

@@ -481,6 +481,61 @@ A tip inside a note</p>
TestParser.TestSpec(input, expected, new MarkdownPipelineBuilder().UseAlertBlocks(allowNestedAlerts: true).Build());
}
[Test]
public void TestIssue887ListAfterNestedBlockQuote()
{
var input = @"> >* _Unordered 1_ QL2 level 1 no space sep
> > Continued 1
> > * Unordered 2 level 1
> > 1. **Ordered 1** QL2 level 1
> > Continued 1
> > > Not continued QL3
> > 2. Ordered 2 QL2 level 1
> > Continued 2a
> >
> > Continued 2b
> >
> > Continued 2c
> >
> > 3. Ordered 3 QL2 level 2
> > Continued 3a
> >
> > Continued 3b
";
var expected = @"<blockquote>
<blockquote>
<ul>
<li><em>Unordered 1</em> QL2 level 1 no space sep
Continued 1</li>
<li>Unordered 2 level 1</li>
</ul>
<ol>
<li><strong>Ordered 1</strong> QL2 level 1
Continued 1</li>
</ol>
<blockquote>
<p>Not continued QL3</p>
</blockquote>
<ol start=""2"">
<li><p>Ordered 2 QL2 level 1
Continued 2a</p>
<p>Continued 2b</p>
<p>Continued 2c</p>
<ol start=""3"">
<li><p>Ordered 3 QL2 level 2
Continued 3a</p>
<p>Continued 3b</p>
</li>
</ol>
</li>
</ol>
</blockquote>
</blockquote>";
TestParser.TestSpec(input, expected);
}
[Test]
public void TestIssue845ListItemBlankLine()
{

View File

@@ -152,6 +152,11 @@ public class BlockProcessor
/// </summary>
public bool IsLazy { get; private set; }
/// <summary>
/// Gets a value indicating whether the current line failed to continue one of the open containers.
/// </summary>
internal bool HasUnmatchedBlocks { get; private set; }
/// <summary>
/// Gets the current stack of <see cref="Block"/> being processed.
/// </summary>
@@ -689,6 +694,7 @@ public class BlockProcessor
private void TryContinueBlocks()
{
IsLazy = false;
HasUnmatchedBlocks = false;
// Set all blocks non opened.
// They will be marked as open in the following loop
@@ -723,6 +729,7 @@ public class BlockProcessor
if (result == BlockState.None)
{
HasUnmatchedBlocks = true;
break;
}
@@ -1049,6 +1056,7 @@ public class BlockProcessor
SkipFirstUnwindSpace = false;
ContinueProcessingLine = false;
IsLazy = false;
HasUnmatchedBlocks = false;
currentStackIndex = 0;
originalLineStart = 0;

View File

@@ -275,8 +275,13 @@ public class ListBlockParser : BlockParser
block ??= state.LastBlock;
if (block is not null && block.IsParagraphBlock)
{
bool isOrderedListInterruptingParagraph = !state.HasUnmatchedBlocks &&
state.IsOpen(block) &&
listInfo.BulletType == '1' &&
listInfo.OrderedStart is not "1";
if (state.IsBlankLine ||
state.IsOpen(block) && listInfo.BulletType == '1' && listInfo.OrderedStart is not "1")
isOrderedListInterruptingParagraph)
{
state.GoToColumn(initColumn);
state.TriviaStart = savedTriviaStart; // restore changed TriviaStart state