diff --git a/src/Markdig.Tests/MiscTests.cs b/src/Markdig.Tests/MiscTests.cs index 05f65fd2..c68a8ec5 100644 --- a/src/Markdig.Tests/MiscTests.cs +++ b/src/Markdig.Tests/MiscTests.cs @@ -129,6 +129,15 @@ public class MiscTests TestParser.TestSpec(input, expected); } + [Test] + public void ThematicBreakIndentedToListItemContentStaysInTheItem() + { + TestParser.TestSpec("- item one\n\n ---\n\n- item two", "
item one
\nitem two
\no
\n\n"); + } + [Test] public void TestAltTextIsCorrectlyEscaped() { diff --git a/src/Markdig/Parsers/ListBlockParser.cs b/src/Markdig/Parsers/ListBlockParser.cs index 008a135c..83fa8d22 100644 --- a/src/Markdig/Parsers/ListBlockParser.cs +++ b/src/Markdig/Parsers/ListBlockParser.cs @@ -91,10 +91,12 @@ public class ListBlockParser : BlockParser } // When both a thematic break and a list item are possible - // interpretations of a line, the thematic break takes precedence + // interpretations of a line, the thematic break takes precedence. + // A thematic break indented to the content of the current list item belongs to that item. BlockState result; var thematicParser = ThematicBreakParser.Default; - if (processor.LastBlock is not FencedCodeBlock && thematicParser.HasOpeningCharacter(processor.CurrentChar)) + if (processor.LastBlock is not FencedCodeBlock && thematicParser.HasOpeningCharacter(processor.CurrentChar) + && !(block is ListItemBlock currentItem && processor.Indent >= Math.Abs(currentItem.ColumnWidth))) { result = thematicParser.TryOpen(processor); if (result.IsBreak())\n
\n- \n
\no
\n
\n