Skip to content

Commit

Permalink
Fix extra line feeds in link title (#826)
Browse files Browse the repository at this point in the history
* Fix extra line feeds in link title

* Test added.
  • Loading branch information
snnz authored Nov 24, 2024
1 parent 310a55c commit 49cf59b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Markdig.Tests/TestLinkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ public void TestTitleSimpleAlternate()
Assert.AreEqual(' ', text.CurrentChar);
}

[Test]
public void TestTitleMultiline()
{
var text = new StringSlice("'this\ris\r\na\ntitle'");
Assert.True(LinkHelper.TryParseTitle(ref text, out string title, out _));
Assert.AreEqual("this\ris\r\na\ntitle", title);
}

[Test]
public void TestUrlAndTitle()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Markdig/Helpers/LinkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ public static bool TryParseTitle<T>(ref T text, out string? title, out char encl
if (c == '\r' && text.PeekChar() == '\n')
{
buffer.Append('\n');
text.SkipChar();
}
continue;
}
Expand Down Expand Up @@ -663,6 +664,7 @@ public static bool TryParseTitleTrivia<T>(ref T text, out string? title, out cha
if (c == '\r' && text.PeekChar() == '\n')
{
buffer.Append('\n');
text.SkipChar();
}
continue;
}
Expand Down

0 comments on commit 49cf59b

Please sign in to comment.