Skip to content

Commit

Permalink
Merge pull request #837 from snnz/fix-links
Browse files Browse the repository at this point in the history
Fix errors in LinkHelper and LinkInlineParser.
  • Loading branch information
xoofx authored Dec 27, 2024
2 parents fdaef77 + ab8e85b commit d1233ff
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 130 deletions.
15 changes: 15 additions & 0 deletions src/Markdig.Tests/TestLinkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ public void TestTitleMultiline()
Assert.AreEqual("this\ris\r\na\ntitle", title);
}

[Test]
public void TestTitleMultilineWithSpaceAndBackslash()
{
var text = new StringSlice("'a\n\\ \\\ntitle'");
Assert.True(LinkHelper.TryParseTitle(ref text, out string title, out _));
Assert.AreEqual("a\n\\ \\\ntitle", title);
}

[Test]
public void TestUrlAndTitle()
{
Expand Down Expand Up @@ -238,6 +246,13 @@ public void TestlLinkReferenceDefinitionSimple()

}

[Test]
public void TestlLinkReferenceDefinitionInvalid()
{
var text = new StringSlice("[foo]: /url (title) x\n");
Assert.False(LinkHelper.TryParseLinkReferenceDefinition(ref text, out _, out _, out _, out _, out _, out _));
}

[Test]
public void TestAutoLinkUrlSimple()
{
Expand Down
8 changes: 8 additions & 0 deletions src/Markdig.Tests/TestPlayParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public void TestLink()
Assert.AreEqual("/yoyo", link?.Url);
}

[Test]
public void TestLinkWithMultipleBackslashesInTitle()
{
var doc = Markdown.Parse(@"[link](/uri '\\\\127.0.0.1')");
var link = doc.Descendants<LinkInline>().FirstOrDefault();
Assert.AreEqual(@"\\127.0.0.1", link?.Title);
}

[Test]
public void TestListBug2()
{
Expand Down
Loading

0 comments on commit d1233ff

Please sign in to comment.