Skip to content

Commit

Permalink
Merge pull request #785 from toothache/fix_issues
Browse files Browse the repository at this point in the history
Fix issues for math span calculation
  • Loading branch information
xoofx committed Mar 29, 2024
2 parents 000393f + 93d88ab commit 8e22754
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/Markdig.Tests/TestSourcePosition.cs
Expand Up @@ -698,7 +698,7 @@ public void TestAttributesForHeading()
[Test]
public void TestMathematicsInline()
{
// 01 23456789AB
// 01 23456789ABCDEF
Check("0\n012 $abcd$ 321", @"
paragraph ( 0, 0) 0-15
literal ( 0, 0) 0-0
Expand All @@ -707,6 +707,13 @@ public void TestMathematicsInline()
math ( 1, 4) 6-11
attributes ( 0, 0) 0--1
literal ( 1,10) 12-15
", "mathematics");

// 012345678
Check("$ abcd $", @"
paragraph ( 0, 0) 0-7
math ( 0, 0) 0-7
attributes ( 0, 0) 0--1
", "mathematics");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Markdig/Extensions/Mathematics/MathInlineParser.cs
Expand Up @@ -152,7 +152,7 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
// Create a new MathInline
var inline = new MathInline()
{
Span = new SourceSpan(processor.GetSourcePosition(startPosition, out int line, out int column), processor.GetSourcePosition(end)),
Span = new SourceSpan(processor.GetSourcePosition(startPosition, out int line, out int column), processor.GetSourcePosition(slice.Start - 1)),
Line = line,
Column = column,
Delimiter = match,
Expand Down

0 comments on commit 8e22754

Please sign in to comment.