mirror of
https://github.com/xoofx/markdig.git
synced 2026-11-16 09:20:40 +00:00
Fix thematic break inside a list item closing the list (#970)
A thematic break indented to the content column of the current list item is parsed inside the item instead of closing the list, matching cmark and commonmark.js.
This commit is contained in:
@@ -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", "<ul>\n<li>\n<p>item one</p>\n<hr />\n</li>\n<li>\n<p>item two</p>\n</li>\n</ul>");
|
||||
TestParser.TestSpec("1. o\n\n ***", "<ol>\n<li>\n<p>o</p>\n<hr />\n</li>\n</ol>");
|
||||
TestParser.TestSpec("-\n ***", "<ul>\n<li>\n<hr />\n</li>\n</ul>");
|
||||
TestParser.TestSpec("> - o\n>\n> ---", "<blockquote>\n<ul>\n<li>\n<p>o</p>\n<hr />\n</li>\n</ul>\n</blockquote>");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAltTextIsCorrectlyEscaped()
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user