diff --git a/src/Markdig.Tests/TestNormalize.cs b/src/Markdig.Tests/TestNormalize.cs
index fae3f763..2008ab7a 100644
--- a/src/Markdig.Tests/TestNormalize.cs
+++ b/src/Markdig.Tests/TestNormalize.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Alexandre Mutel. All rights reserved.
+// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
@@ -11,6 +11,36 @@ namespace Markdig.Tests
public class TestNormalize
{
+ [Test]
+ public void TestCodeBlock()
+ {
+ AssertNormalizeNoTrim(" public void HelloWorld();\n {\n }\n\n");
+ AssertNormalizeNoTrim("```` \npublic void HelloWorld();\n{\n}\n````\n"); //TODO: Bug? Space after the fence
+ AssertNormalizeNoTrim("````csharp \npublic void HelloWorld();\n{\n}\n````\n"); //TODO: Bug? two spaces after the language
+ AssertNormalizeNoTrim("````csharp hideNewKeyword=true \npublic void HelloWorld();\n{\n}\n````\n"); //TODO: Bug? space after the attributes
+ }
+
+ [Test]
+ public void TestHeading()
+ {
+ AssertNormalizeNoTrim("# Heading\n\n");
+ AssertNormalizeNoTrim("## Heading\n\n");
+ AssertNormalizeNoTrim("### Heading\n\n");
+ AssertNormalizeNoTrim("#### Heading\n\n");
+ AssertNormalizeNoTrim("##### Heading\n\n");
+ AssertNormalizeNoTrim("###### Heading\n\n");
+
+ AssertNormalizeNoTrim("Heading\n=======\n\n", "# Heading\n\n");
+ }
+
+ [Test]
+ public void TestHtml()
+ {
+ /*AssertNormalizeNoTrim(@"
+ div >");*/ // TODO: Bug: Throws Exception during emit
+ }
+
[Test]
public void TestParagraph()
{
@@ -52,6 +82,25 @@ line3");
");
}
+
+ [Test]
+ public void TestListOrderedAndIntended()
+ {
+ AssertNormalize(@"
+1. a
+2. b
+ - foo
+ - bar
+3. c
+", @"
+1. a
+2. b
+ - foo
+ - bar
+3. c
+"); // TODO: Bug: intend is always stripped a space.
+ }
+
[Test]
public void TestHeaderAndParagraph()
{
@@ -73,6 +122,25 @@ paragraph
");
}
+ [Test]
+ public void TestThematicBreak()
+ {
+ AssertNormalizeNoTrim("***\n");
+
+ AssertNormalizeNoTrim("* * *\n", "***\n");
+ }
+
+ [Test]
+ public void TestAutolinkInline()
+ {
+ AssertNormalizeNoTrim("This has a
");
+ }
+
+ [Test]
+ public void TestCodeInline()
+ {
+ AssertNormalizeNoTrim("This has a `HelloWorld()` in it");
+ }
[Test]
public void TestEmphasis()
@@ -91,15 +159,29 @@ paragraph
AssertNormalize("This is an ");
}
+ [Test]
+ public void TestHtmlEntity()
+ {
+ AssertNormalizeNoTrim("This is a ä blank", "This is a ä blank"); //TODO: bug?
+ }
- public void AssertNormalize(string input, string expected = null)
+ [Test]
+ public void TestHtmlInline()
+ {
+ AssertNormalizeNoTrim("foo
bar");
+ }
+
+ public void AssertNormalizeNoTrim(string input, string expected = null)
+ => AssertNormalize(input, expected, false);
+
+ public void AssertNormalize(string input, string expected = null, bool trim = true)
{
expected = expected ?? input;
- input = NormText(input);
- expected = NormText(expected);
+ input = NormText(input, trim);
+ expected = NormText(expected, trim);
var result = Markdown.Normalize(input);
- result = NormText(result);
+ result = NormText(result, trim);
Console.WriteLine("```````````````````Source");
Console.WriteLine(TestParser.DisplaySpaceAndTabs(input));
@@ -113,9 +195,13 @@ paragraph
TextAssert.AreEqual(expected, result);
}
- private static string NormText(string text)
+ private static string NormText(string text, bool trim)
{
- return text.Trim().Replace("\r\n", "\n").Replace('\r', '\n');
+ if (trim)
+ {
+ text = text.Trim();
+ }
+ return text.Replace("\r\n", "\n").Replace('\r', '\n');
}
}
}
\ No newline at end of file