add failing test, partial fix for setext headings in blockquotes

attempts to fix #465
This commit is contained in:
Ham Vocke
2020-08-28 13:18:08 +02:00
committed by Alexandre Mutel
parent db25c1db43
commit ccb7e8edfa
4 changed files with 40 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
// Generated: 2019-04-12 15:26:42
// Generated: 2020-08-28 11:05:04
// --------------------------------
// CommonMark v. 0.29
@@ -14925,6 +14925,29 @@ namespace Markdig.Tests.Specs.CommonMarkV_0_29
Console.WriteLine("Example 649\nSection Inlines / Textual content\n");
TestParser.TestSpec("Multiple spaces", "<p>Multiple spaces</p>", "");
}
// Within a blockquote a setext heading takes precedence
// over a thematic break:
[Test]
public void InlinesTextualContent_Example650()
{
// Example 650
// Section: Inlines / Textual content
//
// The following Markdown:
// > Foo
// > ---
// > bar
//
// Should be rendered as:
// <blockquote>
// <h2>Foo</h2>
// <p>bar</p>
// </blockquote>
Console.WriteLine("Example 650\nSection Inlines / Textual content\n");
TestParser.TestSpec("> Foo\n> ---\n> bar", "<blockquote>\n<h2>Foo</h2>\n<p>bar</p>\n</blockquote>", "");
}
// <!-- END TESTS -->
//
// # Appendix: A parsing strategy

View File

@@ -9368,6 +9368,20 @@ Multiple spaces
<p>Multiple spaces</p>
````````````````````````````````
Within a blockquote a setext heading takes precedence
over a thematic break:
```````````````````````````````` example
> Foo
> ---
> bar
.
<blockquote>
<h2>Foo</h2>
<p>bar</p>
</blockquote>
````````````````````````````````
<!-- END TESTS -->

View File

@@ -38,7 +38,7 @@ namespace Markdig.Parsers
return BlockState.BreakDiscard;
}
if (ParseSetexHeadings && !processor.IsCodeIndent && !(block.Parent is QuoteBlock))
if (ParseSetexHeadings && !processor.IsCodeIndent)
{
return TryParseSetexHeading(processor, block);
}

View File

@@ -74,7 +74,7 @@ namespace Markdig.Parsers
if (isSetexHeading)
{
var parent = previousParagraph.Parent;
if (parent is QuoteBlock || (parent is ListItemBlock && previousParagraph.Column != processor.Column))
if ((parent is QuoteBlock && processor.CurrentLineStartPosition > parent.Span.End) || (parent is ListItemBlock && previousParagraph.Column != processor.Column))
{
isSetexHeading = false;
}