Skip to content

Commit

Permalink
Merge pull request #836 from snnz/fix-abbreviation
Browse files Browse the repository at this point in the history
Fix an error in the AbbreviationParser.
  • Loading branch information
xoofx authored Dec 19, 2024
2 parents a8de208 + bc41b0c commit 733c028
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Markdig.Tests/TestSourcePosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,17 @@ public void TestHtmlEntityInline()
[Test]
public void TestAbbreviations()
{
Check("*[HTML]: Hypertext Markup Language\r\n\r\nLater in a text we are using HTML and it becomes an abbr tag HTML", @"
Check("*[HTML]: Hypertext Markup Language\r\n\r\nLater in a text we are using HTML and it becomes an abbr tag HTML\r\n\r\nHTML abbreviation at the beginning of a line", @"
paragraph ( 2, 0) 38-102
container ( 2, 0) 38-102
literal ( 2, 0) 38-66
abbreviation ( 2,29) 67-70
literal ( 2,33) 71-98
abbreviation ( 2,61) 99-102
paragraph ( 4, 0) 107-150
container ( 4, 0) 107-150
abbreviation ( 4, 0) 107-110
literal ( 4, 4) 111-150
", "abbreviations");
}

Expand Down
3 changes: 2 additions & 1 deletion src/Markdig/Extensions/Abbreviations/AbbreviationParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private void DocumentOnProcessInlinesBegin(InlineProcessor inlineProcessor, Inli
{
var literal = (LiteralInline)processor.Inline!;
var originalLiteral = literal;
var originalSpanEnd = literal.Span.End;

ContainerInline? container = null;

Expand Down Expand Up @@ -171,7 +172,7 @@ private void DocumentOnProcessInlinesBegin(InlineProcessor inlineProcessor, Inli
// Process the remaining literal
literal = new LiteralInline()
{
Span = new SourceSpan(abbrInline.Span.End + 1, literal.Span.End),
Span = new SourceSpan(abbrInline.Span.End + 1, originalSpanEnd),
Line = line,
Column = column + match.Length,
};
Expand Down

0 comments on commit 733c028

Please sign in to comment.