Skip to content

Commit

Permalink
Merge pull request xoofx#696 from artempyanykh/fix-setext-span
Browse files Browse the repository at this point in the history
Fix incorrect setext heading source span
  • Loading branch information
xoofx authored Feb 16, 2023
2 parents 851713f + a6cd283 commit 8f8a145
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/Markdig.Tests/TestSourcePosition.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.

using System.Text;
Expand Down Expand Up @@ -127,6 +127,17 @@ public void TestHeading()
");
}

[Test]
public void TestSetextHeading()
{
// 01 2 34 5
Check("A\n\n-\n-", @"
paragraph ( 0, 0) 0-0
literal ( 0, 0) 0-0
heading ( 3, 0) 3-5
literal ( 3, 0) 3-3");
}

[Test]
public void TestHeadingWithEmphasis()
{
Expand Down Expand Up @@ -322,7 +333,7 @@ public void TestHtmlInline()
[Test]
public void TestHtmlInline1()
{
// 0
// 0
// 0123456789
Check("0<!--A-->1", @"
paragraph ( 0, 0) 0-9
Expand Down Expand Up @@ -788,7 +799,7 @@ public void TestTabsInList()
[Test]
public void TestDocument()
{
// L0 L0 L1L2 L3 L4 L5L6 L7L8
// L0 L0 L1L2 L3 L4 L5L6 L7L8
// 0 10 20 30 40 50 60 70 80 90
// 012345678901234567890 1 2345678901 2345678901 2345678901 2 345678901234567890123 4 5678901234567890123
Check("# This is a document\n\n1) item 1\n2) item 2\n3) item 4\n\nWith an **emphasis**\n\n> and a blockquote\n", @"
Expand Down
2 changes: 1 addition & 1 deletion src/Markdig/Parsers/ParagraphBlockParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private BlockState TryParseSetexHeading(BlockProcessor state, Block block)
var heading = new HeadingBlock(this)
{
Column = paragraph.Column,
Span = new SourceSpan(paragraph.Span.Start, line.Start),
Span = new SourceSpan(paragraph.Span.Start, line.End),
Level = level,
Lines = paragraph.Lines,
IsSetext = true,
Expand Down

0 comments on commit 8f8a145

Please sign in to comment.