Skip to content

Commit

Permalink
Fixes exception in DefinitionListParser.GetCurrentDefinitionList()
Browse files Browse the repository at this point in the history
  • Loading branch information
snnz committed Jan 3, 2025
1 parent d1233ff commit 3e0c72f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,20 @@ public override BlockState TryOpen(BlockProcessor processor)
{
var index = previousParent.IndexOf(paragraphBlock) - 1;
if (index < 0) return null;
var lastBlock = previousParent[index];
if (lastBlock is BlankLineBlock)
switch (previousParent[index])
{
lastBlock = previousParent[index - 1];
previousParent.RemoveAt(index);
case DefinitionList definitionList:
return definitionList;

case BlankLineBlock:
if (index > 0 && previousParent[index - 1] is DefinitionList definitionList2)
{
previousParent.RemoveAt(index);
return definitionList2;
}
break;
}
return lastBlock as DefinitionList;
return null;
}

public override BlockState TryContinue(BlockProcessor processor, Block block)
Expand Down

0 comments on commit 3e0c72f

Please sign in to comment.