mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-10 05:49:27 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
682c727288 | ||
|
|
ec2eef25b2 | ||
|
|
6261660d37 | ||
|
|
6d1fa96389 | ||
|
|
47c4e9b1e2 | ||
|
|
3535701d70 | ||
|
|
c41b389053 |
@@ -112,26 +112,26 @@ public class TestLinkHelper
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUrlAndTitleEmpty()
|
||||
public void TestUrlEmptyAndTitleNull()
|
||||
{
|
||||
// 01234
|
||||
var text = new StringSlice(@"(<>)A");
|
||||
Assert.True(LinkHelper.TryParseInlineLink(ref text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan));
|
||||
Assert.AreEqual(string.Empty, link);
|
||||
Assert.AreEqual(string.Empty, title);
|
||||
Assert.AreEqual(null, title);
|
||||
Assert.AreEqual(new SourceSpan(1, 2), linkSpan);
|
||||
Assert.AreEqual(SourceSpan.Empty, titleSpan);
|
||||
Assert.AreEqual('A', text.CurrentChar);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUrlAndTitleEmpty2()
|
||||
public void TestUrlEmptyAndTitleNull2()
|
||||
{
|
||||
// 012345
|
||||
var text = new StringSlice(@"( <> )A");
|
||||
Assert.True(LinkHelper.TryParseInlineLink(ref text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan));
|
||||
Assert.AreEqual(string.Empty, link);
|
||||
Assert.AreEqual(string.Empty, title);
|
||||
Assert.AreEqual(null, title);
|
||||
Assert.AreEqual(new SourceSpan(2, 3), linkSpan);
|
||||
Assert.AreEqual(SourceSpan.Empty, titleSpan);
|
||||
Assert.AreEqual('A', text.CurrentChar);
|
||||
@@ -158,7 +158,7 @@ public class TestLinkHelper
|
||||
var text = new StringSlice(@"()A");
|
||||
Assert.True(LinkHelper.TryParseInlineLink(ref text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan));
|
||||
Assert.AreEqual(string.Empty, link);
|
||||
Assert.AreEqual(string.Empty, title);
|
||||
Assert.AreEqual(null, title);
|
||||
Assert.AreEqual(SourceSpan.Empty, linkSpan);
|
||||
Assert.AreEqual(SourceSpan.Empty, titleSpan);
|
||||
Assert.AreEqual('A', text.CurrentChar);
|
||||
|
||||
@@ -26,6 +26,14 @@ public class TestPlainText
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(/* markdownText: */ "```\nConsole.WriteLine(\"Hello, World!\");\n```", /* expected: */ "Console.WriteLine(\"Hello, World!\");\n")]
|
||||
public void TestPlainCodeBlock(string markdownText, string expected)
|
||||
{
|
||||
var actual = Markdown.ToPlainText(markdownText);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(/* markdownText: */ ":::\nfoo\n:::", /* expected: */ "foo\n", /*extensions*/ "customcontainers|advanced")]
|
||||
[TestCase(/* markdownText: */ ":::bar\nfoo\n:::", /* expected: */ "foo\n", /*extensions*/ "customcontainers+attributes|advanced")]
|
||||
|
||||
@@ -411,7 +411,7 @@ public static class LinkHelper
|
||||
{
|
||||
// Skip ')'
|
||||
text.SkipChar();
|
||||
title ??= string.Empty;
|
||||
// not to normalize nulls into empty strings, since LinkInline.Title property is nullable.
|
||||
}
|
||||
|
||||
return isValid;
|
||||
@@ -1565,4 +1565,4 @@ public static class LinkHelper
|
||||
label = buffer.ToString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public class LinkInlineParser : InlineParser
|
||||
link = new LinkInline()
|
||||
{
|
||||
Url = HtmlHelper.Unescape(url, removeBackSlash: false),
|
||||
Title = HtmlHelper.Unescape(title, removeBackSlash: false),
|
||||
Title = title is null ? null : HtmlHelper.Unescape(title, removeBackSlash: false),
|
||||
IsImage = openParent.IsImage,
|
||||
LabelSpan = openParent.LabelSpan,
|
||||
UrlSpan = inlineState.GetSourcePositionFromLocalSpan(linkSpan),
|
||||
|
||||
@@ -100,7 +100,7 @@ public class CodeBlockRenderer : HtmlObjectRenderer<CodeBlock>
|
||||
renderer.WriteRaw('>');
|
||||
}
|
||||
|
||||
renderer.WriteLeafRawLines(obj, true, true);
|
||||
renderer.WriteLeafRawLines(obj, true, renderer.EnableHtmlEscape);
|
||||
|
||||
if (renderer.EnableHtmlForBlock)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user