mirror of
https://github.com/xoofx/markdig.git
synced 2026-11-16 09:20:40 +00:00
fix multiline quote blocks, split tests into file per node type
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs.Inlines
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestAutoLinkInline
|
||||
{
|
||||
[TestCase("<http://a>")]
|
||||
[TestCase(" <http://a>")]
|
||||
[TestCase("<http://a> ")]
|
||||
[TestCase(" <http://a> ")]
|
||||
|
||||
[TestCase("< http://a>")]
|
||||
[TestCase(" < http://a>")]
|
||||
[TestCase("< http://a> ")]
|
||||
[TestCase(" < http://a> ")]
|
||||
|
||||
[TestCase("<http://a >")]
|
||||
[TestCase(" <http://a >")]
|
||||
[TestCase("<http://a > ")]
|
||||
[TestCase(" <http://a > ")]
|
||||
|
||||
[TestCase("< http://a >")]
|
||||
[TestCase(" < http://a >")]
|
||||
[TestCase("< http://a > ")]
|
||||
[TestCase(" < http://a > ")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
52
src/Markdig.Tests/RoundtripSpecs/Inlines/TestCodeInline.cs
Normal file
52
src/Markdig.Tests/RoundtripSpecs/Inlines/TestCodeInline.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs.Inlines
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCodeInline
|
||||
{
|
||||
[TestCase("``")]
|
||||
[TestCase(" ``")]
|
||||
[TestCase("`` ")]
|
||||
[TestCase(" `` ")]
|
||||
|
||||
[TestCase("`a`")]
|
||||
[TestCase(" `a`")]
|
||||
[TestCase("`a` ")]
|
||||
[TestCase(" `a` ")]
|
||||
|
||||
[TestCase("` a`")]
|
||||
[TestCase(" ` a`")]
|
||||
[TestCase("` a` ")]
|
||||
[TestCase(" ` a` ")]
|
||||
|
||||
[TestCase("`a `")]
|
||||
[TestCase(" `a `")]
|
||||
[TestCase("`a ` ")]
|
||||
[TestCase(" `a ` ")]
|
||||
|
||||
[TestCase("``a``")]
|
||||
[TestCase("- ```a```")]
|
||||
[TestCase("p ```a``` p")]
|
||||
|
||||
[TestCase("```c```")]
|
||||
|
||||
// broken
|
||||
//[TestCase("```a```")]
|
||||
[TestCase("```a``` p")]
|
||||
[TestCase("```a`b`c```")]
|
||||
//[TestCase("p\n\n```a``` p")]
|
||||
//[TestCase("```a``` p\n```a``` p")]
|
||||
|
||||
/// <see cref="CodeInlineParser"/>: intentionally trimmed. TODO: decide on how to handle
|
||||
//[TestCase("` a `")]
|
||||
//[TestCase(" ` a `")]
|
||||
//[TestCase("` a ` ")]
|
||||
//[TestCase(" ` a ` ")]
|
||||
public void Test_CodeInline(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/Markdig.Tests/RoundtripSpecs/Inlines/TestImage.cs
Normal file
25
src/Markdig.Tests/RoundtripSpecs/Inlines/TestImage.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs.Inlines
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestImage
|
||||
{
|
||||
[TestCase("")]
|
||||
[TestCase(" ")]
|
||||
[TestCase(" ")]
|
||||
[TestCase("  ")]
|
||||
[TestCase(" ")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("paragraph ")]
|
||||
public void TestParagraph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
117
src/Markdig.Tests/RoundtripSpecs/Inlines/TestLinkInline.cs
Normal file
117
src/Markdig.Tests/RoundtripSpecs/Inlines/TestLinkInline.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs.Inlines
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestLinkInline
|
||||
{
|
||||
[TestCase("[a]")] // TODO: this is not a link but a paragraph
|
||||
[TestCase("[a]()")]
|
||||
|
||||
[TestCase("[](b)")]
|
||||
[TestCase(" [](b)")]
|
||||
[TestCase("[](b) ")]
|
||||
[TestCase(" [](b) ")]
|
||||
|
||||
[TestCase("[a](b)")]
|
||||
[TestCase(" [a](b)")]
|
||||
[TestCase("[a](b) ")]
|
||||
[TestCase(" [a](b) ")]
|
||||
|
||||
[TestCase("[ a](b)")]
|
||||
[TestCase(" [ a](b)")]
|
||||
[TestCase("[ a](b) ")]
|
||||
[TestCase(" [ a](b) ")]
|
||||
|
||||
[TestCase("[a ](b)")]
|
||||
[TestCase(" [a ](b)")]
|
||||
[TestCase("[a ](b) ")]
|
||||
[TestCase(" [a ](b) ")]
|
||||
|
||||
[TestCase("[ a ](b)")]
|
||||
[TestCase(" [ a ](b)")]
|
||||
[TestCase("[ a ](b) ")]
|
||||
[TestCase(" [ a ](b) ")]
|
||||
|
||||
// below cases are required for a full CST but not have low prio for impl
|
||||
//[TestCase("[]( b)")]
|
||||
//[TestCase(" []( b)")]
|
||||
//[TestCase("[]( b) ")]
|
||||
//[TestCase(" []( b) ")]
|
||||
|
||||
//[TestCase("[a]( b)")]
|
||||
//[TestCase(" [a]( b)")]
|
||||
//[TestCase("[a]( b) ")]
|
||||
//[TestCase(" [a]( b) ")]
|
||||
|
||||
//[TestCase("[ a]( b)")]
|
||||
//[TestCase(" [ a]( b)")]
|
||||
//[TestCase("[ a]( b) ")]
|
||||
//[TestCase(" [ a]( b) ")]
|
||||
|
||||
//[TestCase("[a ]( b)")]
|
||||
//[TestCase(" [a ]( b)")]
|
||||
//[TestCase("[a ]( b) ")]
|
||||
//[TestCase(" [a ]( b) ")]
|
||||
|
||||
//[TestCase("[ a ]( b)")]
|
||||
//[TestCase(" [ a ]( b)")]
|
||||
//[TestCase("[ a ]( b) ")]
|
||||
//[TestCase(" [ a ]( b) ")]
|
||||
|
||||
//[TestCase("[](b )")]
|
||||
//[TestCase(" [](b )")]
|
||||
//[TestCase("[](b ) ")]
|
||||
//[TestCase(" [](b ) ")]
|
||||
|
||||
//[TestCase("[a](b )")]
|
||||
//[TestCase(" [a](b )")]
|
||||
//[TestCase("[a](b ) ")]
|
||||
//[TestCase(" [a](b ) ")]
|
||||
|
||||
//[TestCase("[ a](b )")]
|
||||
//[TestCase(" [ a](b )")]
|
||||
//[TestCase("[ a](b ) ")]
|
||||
//[TestCase(" [ a](b ) ")]
|
||||
|
||||
//[TestCase("[a ](b )")]
|
||||
//[TestCase(" [a ](b )")]
|
||||
//[TestCase("[a ](b ) ")]
|
||||
//[TestCase(" [a ](b ) ")]
|
||||
|
||||
//[TestCase("[ a ](b )")]
|
||||
//[TestCase(" [ a ](b )")]
|
||||
//[TestCase("[ a ](b ) ")]
|
||||
//[TestCase(" [ a ](b ) ")]
|
||||
|
||||
//[TestCase("[]( b )")]
|
||||
//[TestCase(" []( b )")]
|
||||
//[TestCase("[]( b ) ")]
|
||||
//[TestCase(" []( b ) ")]
|
||||
|
||||
//[TestCase("[a]( b )")]
|
||||
//[TestCase(" [a]( b )")]
|
||||
//[TestCase("[a]( b ) ")]
|
||||
//[TestCase(" [a]( b ) ")]
|
||||
|
||||
//[TestCase("[ a]( b )")]
|
||||
//[TestCase(" [ a]( b )")]
|
||||
//[TestCase("[ a]( b ) ")]
|
||||
//[TestCase(" [ a]( b ) ")]
|
||||
|
||||
//[TestCase("[a ]( b )")]
|
||||
//[TestCase(" [a ]( b )")]
|
||||
//[TestCase("[a ]( b ) ")]
|
||||
//[TestCase(" [a ]( b ) ")]
|
||||
|
||||
//[TestCase("[ a ]( b )")]
|
||||
//[TestCase(" [ a ]( b )")]
|
||||
//[TestCase("[ a ]( b ) ")]
|
||||
//[TestCase(" [ a ]( b ) ")]
|
||||
public void Test_InlineLink(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/Markdig.Tests/RoundtripSpecs/TestAtxHeading.cs
Normal file
32
src/Markdig.Tests/RoundtripSpecs/TestAtxHeading.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestAtxHeading
|
||||
{
|
||||
[TestCase("# h")]
|
||||
[TestCase("# h ")]
|
||||
[TestCase("# h\n#h")]
|
||||
[TestCase("# h\n #h")]
|
||||
[TestCase("# h\n # h")]
|
||||
[TestCase("# h\n # h ")]
|
||||
[TestCase(" # h \n # h ")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("\n# h\n\np")]
|
||||
[TestCase("\n# h\n\np\n")]
|
||||
[TestCase("\n# h\n\np\n\n")]
|
||||
[TestCase("\n\n# h\n\np\n\n")]
|
||||
[TestCase("\n\n# h\np\n\n")]
|
||||
[TestCase("\n\n# h\np\n\n")]
|
||||
public void TestParagrph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/Markdig.Tests/RoundtripSpecs/TestCodeBlock.cs
Normal file
20
src/Markdig.Tests/RoundtripSpecs/TestCodeBlock.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCodeBlock
|
||||
{
|
||||
// A codeblock is indented with 4 spaces. After the 4th space, whitespace is interpreted as content.
|
||||
// l = line
|
||||
[TestCase(" l")]
|
||||
[TestCase(" l")]
|
||||
[TestCase("\tl")]
|
||||
[TestCase("\tl1\n l1")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/Markdig.Tests/RoundtripSpecs/TestFencedCodeBlock.cs
Normal file
27
src/Markdig.Tests/RoundtripSpecs/TestFencedCodeBlock.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestFencedCodeBlock
|
||||
{
|
||||
[TestCase("```\nc\n```")]
|
||||
[TestCase("```\nc\n```\n")]
|
||||
[TestCase("\n```\nc\n```")]
|
||||
[TestCase("\n\n```\nc\n```")]
|
||||
[TestCase("```\nc\n```\n")]
|
||||
[TestCase("```\nc\n```\n\n")]
|
||||
[TestCase("\n```\nc\n```\n")]
|
||||
[TestCase("\n```\nc\n```\n\n")]
|
||||
[TestCase("\n\n```\nc\n```\n")]
|
||||
[TestCase("\n\n```\nc\n```\n\n")]
|
||||
|
||||
[TestCase("```\nc\n````")]
|
||||
[TestCase("p\n\n```\nc\n```")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/Markdig.Tests/RoundtripSpecs/TestHelper.cs
Normal file
23
src/Markdig.Tests/RoundtripSpecs/TestHelper.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Markdig.Renderers.Normalize;
|
||||
using Markdig.Syntax;
|
||||
using NUnit.Framework;
|
||||
using System.IO;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
internal static class TestHelper
|
||||
{
|
||||
internal static void RoundTrip(string markdown)
|
||||
{
|
||||
var pipelineBuilder = new MarkdownPipelineBuilder();
|
||||
MarkdownPipeline pipeline = pipelineBuilder.Build();
|
||||
MarkdownDocument markdownDocument = Markdown.Parse(markdown, pipeline);
|
||||
var sw = new StringWriter();
|
||||
var nr = new NormalizeRenderer(sw);
|
||||
|
||||
nr.Write(markdownDocument);
|
||||
|
||||
Assert.AreEqual(markdown, sw.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/Markdig.Tests/RoundtripSpecs/TestHtmlBlock.cs
Normal file
20
src/Markdig.Tests/RoundtripSpecs/TestHtmlBlock.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestHtmlBlock
|
||||
{
|
||||
[TestCase("<br>")]
|
||||
[TestCase("<br>\n")]
|
||||
[TestCase("<br>\n\n")]
|
||||
[TestCase("<div></div>\n\n# h")]
|
||||
[TestCase("p\n\n<div></div>\n")]
|
||||
[TestCase("<div></div>\n\n# h")]
|
||||
public void TestHtml(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
src/Markdig.Tests/RoundtripSpecs/TestOrderedList.cs
Normal file
21
src/Markdig.Tests/RoundtripSpecs/TestOrderedList.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestOrderedList
|
||||
{
|
||||
[TestCase("1. i")]
|
||||
[TestCase("1. i")]
|
||||
[TestCase("1. i ")]
|
||||
[TestCase("1. i ")]
|
||||
|
||||
[TestCase("1. i1\n2. i2")]
|
||||
[TestCase("1. i1\n2. i2\n a. i2.1")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
65
src/Markdig.Tests/RoundtripSpecs/TestParagraph.cs
Normal file
65
src/Markdig.Tests/RoundtripSpecs/TestParagraph.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestParagraph
|
||||
{
|
||||
[TestCase("p")]
|
||||
[TestCase(" p")]
|
||||
[TestCase("p ")]
|
||||
[TestCase(" p ")]
|
||||
|
||||
[TestCase("p\np")]
|
||||
[TestCase(" p\np")]
|
||||
[TestCase("p \np")]
|
||||
[TestCase(" p \np")]
|
||||
|
||||
[TestCase("p\n p")]
|
||||
[TestCase(" p\n p")]
|
||||
[TestCase("p \n p")]
|
||||
[TestCase(" p \n p")]
|
||||
|
||||
[TestCase("p\np ")]
|
||||
[TestCase(" p\np ")]
|
||||
[TestCase("p \np ")]
|
||||
[TestCase(" p \np ")]
|
||||
|
||||
[TestCase("p\n\n p ")]
|
||||
[TestCase(" p\n\n p ")]
|
||||
[TestCase("p \n\n p ")]
|
||||
[TestCase(" p \n\n p ")]
|
||||
|
||||
[TestCase("p\n\np")]
|
||||
[TestCase(" p\n\np")]
|
||||
[TestCase("p \n\np")]
|
||||
[TestCase(" p \n\np")]
|
||||
|
||||
[TestCase("p\n\n p")]
|
||||
[TestCase(" p\n\n p")]
|
||||
[TestCase("p \n\n p")]
|
||||
[TestCase(" p \n\n p")]
|
||||
|
||||
[TestCase("p\n\np ")]
|
||||
[TestCase(" p\n\np ")]
|
||||
[TestCase("p \n\np ")]
|
||||
[TestCase(" p \n\np ")]
|
||||
|
||||
[TestCase("p\n\n p ")]
|
||||
[TestCase(" p\n\n p ")]
|
||||
[TestCase("p \n\n p ")]
|
||||
[TestCase(" p \n\n p ")]
|
||||
|
||||
// special cases
|
||||
[TestCase(" p \n\n\n\n p \n\n")]
|
||||
[TestCase("\np")]
|
||||
[TestCase("\n\np")]
|
||||
[TestCase("p\n")]
|
||||
[TestCase("p\n\n")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
218
src/Markdig.Tests/RoundtripSpecs/TestQuoteBlock.cs
Normal file
218
src/Markdig.Tests/RoundtripSpecs/TestQuoteBlock.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestQuoteBlock
|
||||
{
|
||||
[TestCase(">q")]
|
||||
[TestCase(" >q")]
|
||||
[TestCase(" >q")]
|
||||
[TestCase(" >q")]
|
||||
[TestCase("> q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase("> q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
|
||||
[TestCase(">q\n>q")]
|
||||
[TestCase(">q\n >q")]
|
||||
[TestCase(">q\n >q")]
|
||||
[TestCase(">q\n >q")]
|
||||
[TestCase(">q\n> q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n> q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
|
||||
[TestCase(" >q\n>q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
|
||||
[TestCase(" >q\n>q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
|
||||
[TestCase("> q\n>q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase("> q\n>q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(">q\n>q\n>q")]
|
||||
[TestCase(">q\n>\n>q")]
|
||||
[TestCase(">q\np\n>q")]
|
||||
[TestCase(">q\n>\n>\n>q")]
|
||||
[TestCase(">q\n>\n>\n>\n>q")]
|
||||
[TestCase(">q\n>\n>q\n>\n>q")]
|
||||
[TestCase("> **q**\n>p\n")]
|
||||
[TestCase("p\n\n> **q**\n>p\n")]
|
||||
|
||||
[TestCase("> q\np\n> q")] // lazy
|
||||
[TestCase("> q\n> q\np")] // lazy
|
||||
|
||||
[TestCase(">>q")]
|
||||
[TestCase(" > > q")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > \tq")]
|
||||
public void TestCodeBlock(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("\n> q")]
|
||||
[TestCase("\n> q\n")]
|
||||
[TestCase("\n> q\n\n")]
|
||||
[TestCase("> q\n\np")]
|
||||
[TestCase("p\n\n> q\n\n# h")]
|
||||
|
||||
//https://github.com/lunet-io/markdig/issues/480
|
||||
//[TestCase(">\np")]
|
||||
//[TestCase(">**b**\n>\n>p\n>\np\n")]
|
||||
public void TestParagraph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("> q\n\n# h\n")]
|
||||
public void TestAtxHeader(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase(">- i1\n>- i2\n")]
|
||||
[TestCase("> **p** p\n>- i1\n>- i2\n")]
|
||||
public void TestUnorderedList(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/Markdig.Tests/RoundtripSpecs/TestSetextHeading.cs
Normal file
16
src/Markdig.Tests/RoundtripSpecs/TestSetextHeading.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSetextHeading
|
||||
{
|
||||
[TestCase("h1===\n")]
|
||||
[TestCase("h2---\n")]
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/Markdig.Tests/RoundtripSpecs/TestThematicBreak.cs
Normal file
33
src/Markdig.Tests/RoundtripSpecs/TestThematicBreak.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestThematicBreak
|
||||
{
|
||||
[TestCase("---")]
|
||||
[TestCase(" ---")]
|
||||
[TestCase(" ---")]
|
||||
[TestCase(" ---")]
|
||||
[TestCase("--- ")]
|
||||
[TestCase(" --- ")]
|
||||
[TestCase(" --- ")]
|
||||
[TestCase(" --- ")]
|
||||
[TestCase("- - -")]
|
||||
[TestCase(" - - -")]
|
||||
[TestCase(" - - - ")]
|
||||
[TestCase("-- -")]
|
||||
[TestCase("---\n")]
|
||||
[TestCase("---\n\n")]
|
||||
[TestCase("---\np")]
|
||||
[TestCase("---\n\np")]
|
||||
[TestCase("---\n# h")]
|
||||
//[TestCase("p\n\n---")]
|
||||
/// Note: "p\n---" is parsed as setext heading
|
||||
public void Test(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
78
src/Markdig.Tests/RoundtripSpecs/TestUnorderedList.cs
Normal file
78
src/Markdig.Tests/RoundtripSpecs/TestUnorderedList.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using NUnit.Framework;
|
||||
using static Markdig.Tests.RoundtripSpecs.TestHelper;
|
||||
|
||||
namespace Markdig.Tests.RoundtripSpecs
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestUnorderedList
|
||||
{
|
||||
// i = item
|
||||
[TestCase("- i1")]
|
||||
[TestCase("- i1 ")]
|
||||
[TestCase("- i1\n")]
|
||||
[TestCase("- i1\n\n")]
|
||||
[TestCase("- i1\n- i2")]
|
||||
[TestCase("- i1\n - i2")]
|
||||
[TestCase("- i1\n - i1.1\n - i1.2")]
|
||||
[TestCase("- i1 \n- i2 \n")]
|
||||
[TestCase("- i1 \n- i2 \n")]
|
||||
[TestCase(" - i1")]
|
||||
[TestCase(" - i1")]
|
||||
[TestCase(" - i1")]
|
||||
[TestCase("- i1\n\n- i1")]
|
||||
[TestCase("- i1\n\n\n- i1")]
|
||||
[TestCase("- i1\n - i1.1\n - i1.1.1\n")]
|
||||
|
||||
[TestCase("-\ti1")]
|
||||
[TestCase("-\ti1\n-\ti2")]
|
||||
[TestCase("-\ti1\n- i2\n-\ti3")]
|
||||
public void Test_UnorderedList(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q1\n - > q2")]
|
||||
public void TestBlockQuote(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- i1\n\np\n")] // TODO: listblock should render newline, apparently last paragraph of last listitem dont have newline
|
||||
[TestCase("- i1\n\n\np\n")]
|
||||
[TestCase("- i1\n\np")]
|
||||
[TestCase("- i1\n\np\n")]
|
||||
public void TestParagraph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- i1\n\n---\n")]
|
||||
[TestCase("- i1\n\n\n---\n")]
|
||||
public void TestThematicBreak(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- i1\n - i1.1\n ```\n code\n ```")]
|
||||
public void TestCodeBlock(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,706 +0,0 @@
|
||||
using Markdig.Renderers;
|
||||
using Markdig.Renderers.Normalize;
|
||||
using Markdig.Syntax;
|
||||
using NUnit.Framework;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// General notes
|
||||
/// - whitespace can occur before, between and after symbols
|
||||
/// </summary>
|
||||
/// TODO:
|
||||
/// - \r\n, \r, \n
|
||||
/// - \t and spaces
|
||||
/// - html entities i.e. >
|
||||
///
|
||||
namespace Markdig.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCst
|
||||
{
|
||||
[Test]
|
||||
public void TestWhitespaceBefore()
|
||||
{
|
||||
var markdown = " This is a paragraph. ";
|
||||
|
||||
var pipelineBuilder = new MarkdownPipelineBuilder();
|
||||
MarkdownPipeline pipeline = pipelineBuilder.Build();
|
||||
|
||||
MarkdownDocument markdownDocument = Markdown.Parse(markdown, pipeline);
|
||||
var paragraphBlock = markdownDocument[0] as ParagraphBlock;
|
||||
|
||||
var sw = new StringWriter();
|
||||
var nr = new NormalizeRenderer(sw);
|
||||
nr.Write(markdownDocument);
|
||||
|
||||
Assert.AreEqual(markdown, sw.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNewLinesBeforeAndAfter()
|
||||
{
|
||||
var markdown = " \n \nLine2\n\nLine1\n\n";
|
||||
//var markdown = "\r\nLine2\r\n\r\nLine1\r\n\r\n";
|
||||
|
||||
var pipelineBuilder = new MarkdownPipelineBuilder();
|
||||
MarkdownPipeline pipeline = pipelineBuilder.Build();
|
||||
|
||||
MarkdownDocument markdownDocument = Markdown.Parse(markdown, pipeline);
|
||||
var paragraphBlock = markdownDocument[0] as ParagraphBlock;
|
||||
|
||||
var sw = new StringWriter();
|
||||
var nr = new NormalizeRenderer(sw);
|
||||
nr.Write(markdownDocument);
|
||||
|
||||
Assert.AreEqual(markdown, sw.ToString());
|
||||
}
|
||||
|
||||
private void RoundTrip(string markdown)
|
||||
{
|
||||
var pipelineBuilder = new MarkdownPipelineBuilder();
|
||||
MarkdownPipeline pipeline = pipelineBuilder.Build();
|
||||
MarkdownDocument markdownDocument = Markdown.Parse(markdown, pipeline);
|
||||
var sw = new StringWriter();
|
||||
var nr = new NormalizeRenderer(sw);
|
||||
|
||||
nr.Write(markdownDocument);
|
||||
|
||||
Assert.AreEqual(markdown, sw.ToString());
|
||||
}
|
||||
|
||||
[TestCase("p")]
|
||||
[TestCase(" p")]
|
||||
[TestCase("p ")]
|
||||
[TestCase(" p ")]
|
||||
|
||||
[TestCase("p\np")]
|
||||
[TestCase(" p\np")]
|
||||
[TestCase("p \np")]
|
||||
[TestCase(" p \np")]
|
||||
|
||||
[TestCase("p\n p")]
|
||||
[TestCase(" p\n p")]
|
||||
[TestCase("p \n p")]
|
||||
[TestCase(" p \n p")]
|
||||
|
||||
[TestCase("p\np ")]
|
||||
[TestCase(" p\np ")]
|
||||
[TestCase("p \np ")]
|
||||
[TestCase(" p \np ")]
|
||||
|
||||
[TestCase("p\n\n p ")]
|
||||
[TestCase(" p\n\n p ")]
|
||||
[TestCase("p \n\n p ")]
|
||||
[TestCase(" p \n\n p ")]
|
||||
|
||||
[TestCase("p\n\np")]
|
||||
[TestCase(" p\n\np")]
|
||||
[TestCase("p \n\np")]
|
||||
[TestCase(" p \n\np")]
|
||||
|
||||
[TestCase("p\n\n p")]
|
||||
[TestCase(" p\n\n p")]
|
||||
[TestCase("p \n\n p")]
|
||||
[TestCase(" p \n\n p")]
|
||||
|
||||
[TestCase("p\n\np ")]
|
||||
[TestCase(" p\n\np ")]
|
||||
[TestCase("p \n\np ")]
|
||||
[TestCase(" p \n\np ")]
|
||||
|
||||
[TestCase("p\n\n p ")]
|
||||
[TestCase(" p\n\n p ")]
|
||||
[TestCase("p \n\n p ")]
|
||||
[TestCase(" p \n\n p ")]
|
||||
|
||||
// special cases
|
||||
[TestCase(" p \n\n\n\n p \n\n")]
|
||||
[TestCase("\np")]
|
||||
[TestCase("\n\np")]
|
||||
[TestCase("p\n")]
|
||||
[TestCase("p\n\n")]
|
||||
public void TestParagraph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNewLinesBeforeAndAfter2()
|
||||
{
|
||||
RoundTrip("\n# H1\n\nLine1");
|
||||
RoundTrip("\n# H1\n\nLine1\n");
|
||||
RoundTrip("\n# H1\n\nLine1\n\n");
|
||||
RoundTrip("\n\n# H1\n\nLine1\n\n");
|
||||
RoundTrip("\n\n# H1\nLine1\n\n");
|
||||
RoundTrip("\n\n# H1\nLine1\n\n");
|
||||
}
|
||||
|
||||
// i = item
|
||||
[TestCase("- i1")]
|
||||
[TestCase("- i1 ")]
|
||||
[TestCase("- i1\n")]
|
||||
[TestCase("- i1\n\n")]
|
||||
[TestCase("- i1\n- i2")]
|
||||
[TestCase("- i1\n - i2")]
|
||||
[TestCase("- i1\n - i1.1\n - i1.2")]
|
||||
[TestCase("- i1 \n- i2 \n")]
|
||||
[TestCase("- i1 \n- i2 \n")]
|
||||
[TestCase(" - i1")]
|
||||
[TestCase(" - i1")]
|
||||
[TestCase(" - i1")]
|
||||
[TestCase("- i1\n\n- i1")]
|
||||
[TestCase("- i1\n\n\n- i1")]
|
||||
[TestCase("- i1\n - i1.1\n - i1.1.1\n")]
|
||||
|
||||
[TestCase("-\ti1")]
|
||||
[TestCase("-\ti1\n-\ti2")]
|
||||
[TestCase("-\ti1\n- i2\n-\ti3")]
|
||||
public void TestUnorderedList(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- i1\n\np\n")] // TODO: listblock should render newline, apparently last paragraph of last listitem dont have newline
|
||||
[TestCase("- i1\n\n\np\n")]
|
||||
[TestCase("- i1\n\np")]
|
||||
[TestCase("- i1\n\np\n")]
|
||||
public void TestUnorderedList_Paragraph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- i1\n\n---\n")]
|
||||
[TestCase("- i1\n\n\n---\n")]
|
||||
public void TestUnorderedList_ThematicBreak(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- i1\n - i1.1\n ```\n code\n ```")]
|
||||
public void TestUnorderedList_CodeBlock(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("1. i")]
|
||||
[TestCase("1. i")]
|
||||
[TestCase("1. i ")]
|
||||
[TestCase("1. i ")]
|
||||
|
||||
[TestCase("1. i1\n2. i2")]
|
||||
[TestCase("1. i1\n2. i2\n a. i2.1")]
|
||||
public void TestOrderedList(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase(" ")]
|
||||
[TestCase("paragraph ")]
|
||||
public void TestImage2(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("# h")]
|
||||
[TestCase("# h ")]
|
||||
public void TestHeading(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase("- > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q")]
|
||||
[TestCase(" - > q1\n - > q2")]
|
||||
public void TestUnorderedListItem_BlockQuote(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase(">q")]
|
||||
[TestCase(" >q")]
|
||||
[TestCase(" >q")]
|
||||
[TestCase(" >q")]
|
||||
[TestCase("> q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase("> q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
[TestCase(" > q")]
|
||||
|
||||
[TestCase(">q\n>q")]
|
||||
[TestCase(">q\n >q")]
|
||||
[TestCase(">q\n >q")]
|
||||
[TestCase(">q\n >q")]
|
||||
[TestCase(">q\n> q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n> q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
[TestCase(">q\n > q")]
|
||||
|
||||
[TestCase(" >q\n>q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
|
||||
[TestCase(" >q\n>q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n >q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n> q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
[TestCase(" >q\n > q")]
|
||||
|
||||
[TestCase("> q\n>q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase("> q\n>q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n >q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n> q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
[TestCase("> q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(" > q\n>q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n >q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n> q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
[TestCase(" > q\n > q")]
|
||||
|
||||
[TestCase(">q\n>q\n>q")]
|
||||
[TestCase(">q\n>\n>q")]
|
||||
[TestCase(">q\np\n>q")]
|
||||
[TestCase(">q\n>\n>\n>q")]
|
||||
[TestCase(">q\n>\n>\n>\n>q")]
|
||||
[TestCase(">q\n>\n>q\n>\n>q")]
|
||||
[TestCase("> **q**\n>p\n")]
|
||||
[TestCase("p\n\n> **q**\n>p\n")]
|
||||
|
||||
[TestCase("> q\np\n> q")] // lazy
|
||||
[TestCase("> q\n> q\np")] // lazy
|
||||
|
||||
[TestCase(">>q")]
|
||||
[TestCase(" > > q")]
|
||||
public void TestBlockQuote(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("---")]
|
||||
[TestCase(" ---")]
|
||||
[TestCase(" ---")]
|
||||
[TestCase(" ---")]
|
||||
[TestCase("--- ")]
|
||||
[TestCase(" --- ")]
|
||||
[TestCase(" --- ")]
|
||||
[TestCase(" --- ")]
|
||||
[TestCase("- - -")]
|
||||
[TestCase(" - - -")]
|
||||
[TestCase(" - - - ")]
|
||||
[TestCase("-- -")]
|
||||
[TestCase("---\n")]
|
||||
[TestCase("---\n\n")]
|
||||
[TestCase("---\np")]
|
||||
[TestCase("---\n\np")]
|
||||
[TestCase("---\n# h")]
|
||||
//[TestCase("p\n\n---")]
|
||||
/// Note: "p\n---" is parsed as setext heading
|
||||
public void TestThematicBreak(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("\n> q")]
|
||||
[TestCase("\n> q\n")]
|
||||
[TestCase("\n> q\n\n")]
|
||||
[TestCase("> q\n\np")]
|
||||
[TestCase("p\n\n> q\n\n# h")]
|
||||
|
||||
//https://github.com/lunet-io/markdig/issues/480
|
||||
//[TestCase(">\np")]
|
||||
//[TestCase(">**b**\n>\n>p\n>\np\n")]
|
||||
public void TestBlockQuote_Paragraph(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("> q\n\n# h\n")]
|
||||
public void TestBlockQuote_Header(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase(">- i1\n>- i2\n")]
|
||||
[TestCase("> **p** p\n>- i1\n>- i2\n")]
|
||||
public void TestBlockQuote_ListBlock(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBlockQuote()
|
||||
{
|
||||
//RoundTrip("- >quote"); // par in qb in l in li
|
||||
// 3ws? - ws 3ws? q ws? p
|
||||
// 3ws? lb
|
||||
// - li
|
||||
// ws li
|
||||
// 3ws? qb
|
||||
// q qb
|
||||
// ws? qb
|
||||
// p p
|
||||
//RoundTrip(" - > quote"); // par in qb in l in li
|
||||
}
|
||||
|
||||
/// A codeblock is indented with 4 spaces. After the 4th space, whitespace is interpreted as content.
|
||||
[TestCase(" code")]
|
||||
[TestCase(" code")]
|
||||
public void TestImplicitCodeBlock(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("[a]")] // TODO: this is not a link but a paragraph
|
||||
[TestCase("[a]()")]
|
||||
|
||||
[TestCase("[](b)")]
|
||||
[TestCase(" [](b)")]
|
||||
[TestCase("[](b) ")]
|
||||
[TestCase(" [](b) ")]
|
||||
|
||||
[TestCase("[a](b)")]
|
||||
[TestCase(" [a](b)")]
|
||||
[TestCase("[a](b) ")]
|
||||
[TestCase(" [a](b) ")]
|
||||
|
||||
[TestCase("[ a](b)")]
|
||||
[TestCase(" [ a](b)")]
|
||||
[TestCase("[ a](b) ")]
|
||||
[TestCase(" [ a](b) ")]
|
||||
|
||||
[TestCase("[a ](b)")]
|
||||
[TestCase(" [a ](b)")]
|
||||
[TestCase("[a ](b) ")]
|
||||
[TestCase(" [a ](b) ")]
|
||||
|
||||
[TestCase("[ a ](b)")]
|
||||
[TestCase(" [ a ](b)")]
|
||||
[TestCase("[ a ](b) ")]
|
||||
[TestCase(" [ a ](b) ")]
|
||||
|
||||
// below cases are required for a full CST but not have low prio for impl
|
||||
//[TestCase("[]( b)")]
|
||||
//[TestCase(" []( b)")]
|
||||
//[TestCase("[]( b) ")]
|
||||
//[TestCase(" []( b) ")]
|
||||
|
||||
//[TestCase("[a]( b)")]
|
||||
//[TestCase(" [a]( b)")]
|
||||
//[TestCase("[a]( b) ")]
|
||||
//[TestCase(" [a]( b) ")]
|
||||
|
||||
//[TestCase("[ a]( b)")]
|
||||
//[TestCase(" [ a]( b)")]
|
||||
//[TestCase("[ a]( b) ")]
|
||||
//[TestCase(" [ a]( b) ")]
|
||||
|
||||
//[TestCase("[a ]( b)")]
|
||||
//[TestCase(" [a ]( b)")]
|
||||
//[TestCase("[a ]( b) ")]
|
||||
//[TestCase(" [a ]( b) ")]
|
||||
|
||||
//[TestCase("[ a ]( b)")]
|
||||
//[TestCase(" [ a ]( b)")]
|
||||
//[TestCase("[ a ]( b) ")]
|
||||
//[TestCase(" [ a ]( b) ")]
|
||||
|
||||
//[TestCase("[](b )")]
|
||||
//[TestCase(" [](b )")]
|
||||
//[TestCase("[](b ) ")]
|
||||
//[TestCase(" [](b ) ")]
|
||||
|
||||
//[TestCase("[a](b )")]
|
||||
//[TestCase(" [a](b )")]
|
||||
//[TestCase("[a](b ) ")]
|
||||
//[TestCase(" [a](b ) ")]
|
||||
|
||||
//[TestCase("[ a](b )")]
|
||||
//[TestCase(" [ a](b )")]
|
||||
//[TestCase("[ a](b ) ")]
|
||||
//[TestCase(" [ a](b ) ")]
|
||||
|
||||
//[TestCase("[a ](b )")]
|
||||
//[TestCase(" [a ](b )")]
|
||||
//[TestCase("[a ](b ) ")]
|
||||
//[TestCase(" [a ](b ) ")]
|
||||
|
||||
//[TestCase("[ a ](b )")]
|
||||
//[TestCase(" [ a ](b )")]
|
||||
//[TestCase("[ a ](b ) ")]
|
||||
//[TestCase(" [ a ](b ) ")]
|
||||
|
||||
//[TestCase("[]( b )")]
|
||||
//[TestCase(" []( b )")]
|
||||
//[TestCase("[]( b ) ")]
|
||||
//[TestCase(" []( b ) ")]
|
||||
|
||||
//[TestCase("[a]( b )")]
|
||||
//[TestCase(" [a]( b )")]
|
||||
//[TestCase("[a]( b ) ")]
|
||||
//[TestCase(" [a]( b ) ")]
|
||||
|
||||
//[TestCase("[ a]( b )")]
|
||||
//[TestCase(" [ a]( b )")]
|
||||
//[TestCase("[ a]( b ) ")]
|
||||
//[TestCase(" [ a]( b ) ")]
|
||||
|
||||
//[TestCase("[a ]( b )")]
|
||||
//[TestCase(" [a ]( b )")]
|
||||
//[TestCase("[a ]( b ) ")]
|
||||
//[TestCase(" [a ]( b ) ")]
|
||||
|
||||
//[TestCase("[ a ]( b )")]
|
||||
//[TestCase(" [ a ]( b )")]
|
||||
//[TestCase("[ a ]( b ) ")]
|
||||
//[TestCase(" [ a ]( b ) ")]
|
||||
public void TestInlineLink(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase(" ")]
|
||||
[TestCase(" ")]
|
||||
[TestCase("  ")]
|
||||
public void TestImage(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("``")]
|
||||
[TestCase(" ``")]
|
||||
[TestCase("`` ")]
|
||||
[TestCase(" `` ")]
|
||||
|
||||
[TestCase("`a`")]
|
||||
[TestCase(" `a`")]
|
||||
[TestCase("`a` ")]
|
||||
[TestCase(" `a` ")]
|
||||
|
||||
[TestCase("` a`")]
|
||||
[TestCase(" ` a`")]
|
||||
[TestCase("` a` ")]
|
||||
[TestCase(" ` a` ")]
|
||||
|
||||
[TestCase("`a `")]
|
||||
[TestCase(" `a `")]
|
||||
[TestCase("`a ` ")]
|
||||
[TestCase(" `a ` ")]
|
||||
|
||||
[TestCase("``a``")]
|
||||
[TestCase("- ```a```")]
|
||||
[TestCase("p ```a``` p")]
|
||||
|
||||
// broken
|
||||
//[TestCase("```a```")]
|
||||
[TestCase("```a``` p")]
|
||||
[TestCase("```a`b`c```")]
|
||||
//[TestCase("p\n\n```a``` p")]
|
||||
//[TestCase("```a``` p\n```a``` p")]
|
||||
|
||||
/// <see cref="CodeInlineParser"/>: intentionally trimmed. TODO: decide on how to handle
|
||||
//[TestCase("` a `")]
|
||||
//[TestCase(" ` a `")]
|
||||
//[TestCase("` a ` ")]
|
||||
//[TestCase(" ` a ` ")]
|
||||
public void TestCodeInline(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("<http://a>")]
|
||||
[TestCase(" <http://a>")]
|
||||
[TestCase("<http://a> ")]
|
||||
[TestCase(" <http://a> ")]
|
||||
|
||||
[TestCase("< http://a>")]
|
||||
[TestCase(" < http://a>")]
|
||||
[TestCase("< http://a> ")]
|
||||
[TestCase(" < http://a> ")]
|
||||
|
||||
[TestCase("<http://a >")]
|
||||
[TestCase(" <http://a >")]
|
||||
[TestCase("<http://a > ")]
|
||||
[TestCase(" <http://a > ")]
|
||||
|
||||
[TestCase("< http://a >")]
|
||||
[TestCase(" < http://a >")]
|
||||
[TestCase("< http://a > ")]
|
||||
[TestCase(" < http://a > ")]
|
||||
public void TestAutolinkInline(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("```c```")]
|
||||
|
||||
[TestCase(" l")]
|
||||
[TestCase("\tl")]
|
||||
[TestCase("\tl1\n l1")]
|
||||
|
||||
[TestCase("```\nc\n```")]
|
||||
[TestCase("```\nc\n```\n")]
|
||||
[TestCase("\n```\nc\n```")]
|
||||
[TestCase("\n\n```\nc\n```")]
|
||||
[TestCase("```\nc\n```\n")]
|
||||
[TestCase("```\nc\n```\n\n")]
|
||||
[TestCase("\n```\nc\n```\n")]
|
||||
[TestCase("\n```\nc\n```\n\n")]
|
||||
[TestCase("\n\n```\nc\n```\n")]
|
||||
[TestCase("\n\n```\nc\n```\n\n")]
|
||||
|
||||
[TestCase("```\nc\n````")]
|
||||
[TestCase("p\n\n```\nc\n```")]
|
||||
public void TestCodeBlock(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("<br>")]
|
||||
[TestCase("<br>\n")]
|
||||
[TestCase("<br>\n\n")]
|
||||
[TestCase("<div></div>\n\n# h")]
|
||||
[TestCase("p\n\n<div></div>\n")]
|
||||
[TestCase("<div></div>\n\n# h")]
|
||||
public void TestHtml(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
|
||||
[TestCase("h1===\n")]
|
||||
[TestCase("h2---\n")]
|
||||
public void TestSetextHeading(string value)
|
||||
{
|
||||
RoundTrip(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Markdig.Helpers;
|
||||
using Markdig.Syntax;
|
||||
|
||||
@@ -735,7 +736,6 @@ namespace Markdig.Parsers
|
||||
if (TryOpenBlocks(globalParsers))
|
||||
{
|
||||
RestartIndent();
|
||||
//RestartBeforeLines();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -807,9 +807,16 @@ namespace Markdig.Parsers
|
||||
|
||||
if (!result.IsDiscard())
|
||||
{
|
||||
// TODO: RTP: pass line with whitespace
|
||||
paragraph.AppendLine(ref Line, Column, LineIndex, CurrentLineStartPosition);
|
||||
}
|
||||
|
||||
// TODO: RTP: delegate this to container parser classes
|
||||
var qb = paragraph.Parent as QuoteBlock;
|
||||
if (qb != null)
|
||||
{
|
||||
var afterWhitespace = PopBeforeWhitespace(Start - 1);
|
||||
qb.QuoteLines.Last().AfterWhitespace = afterWhitespace;
|
||||
}
|
||||
// We have just found a lazy continuation for a paragraph, early exit
|
||||
// Mark all block opened after a lazy continuation
|
||||
OpenAll();
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Markdig.Parsers
|
||||
Level = leadingCount,
|
||||
Column = column,
|
||||
Span = { Start = sourcePosition },
|
||||
BeforeWhitespace = processor.PopBeforeWhitespace(column),
|
||||
BeforeWhitespace = processor.PopBeforeWhitespace(sourcePosition - 1),
|
||||
LinesBefore = processor.UseLinesBefore()
|
||||
};
|
||||
processor.NewBlocks.Push(headingBlock);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Markdig.Parsers
|
||||
};
|
||||
quoteBlock.QuoteLines.Add(new QuoteBlock.QuoteLine
|
||||
{
|
||||
BeforeWhitespace = processor.PopBeforeWhitespace(processor.ColumnBeforeIndent, sourcePosition - 1),
|
||||
BeforeWhitespace = processor.PopBeforeWhitespace(sourcePosition - 1),
|
||||
QuoteChar = true
|
||||
});
|
||||
processor.NewBlocks.Push(quoteBlock);
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace Markdig.Renderers.Normalize
|
||||
renderer.RenderLinesBefore(paragraph);
|
||||
renderer.Write(paragraph.BeforeWhitespace);
|
||||
renderer.WriteLeafInline(paragraph);
|
||||
renderer.FinishBlock();
|
||||
//renderer.FinishBlock();
|
||||
renderer.RenderLineAfterIfNeeded(paragraph);
|
||||
renderer.RenderLinesAfter(paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Markdig.Renderers.Normalize
|
||||
var indents = new List<string>();
|
||||
foreach (var quoteLine in quoteBlock.QuoteLines)
|
||||
{
|
||||
indents.Add(quoteLine.BeforeWhitespace.ToString() + (quoteLine.QuoteChar ? ">" : ""));
|
||||
indents.Add(quoteLine.BeforeWhitespace.ToString() + (quoteLine.QuoteChar ? ">" : "") + quoteLine.AfterWhitespace.ToString());
|
||||
}
|
||||
|
||||
renderer.PushIndent(indents);
|
||||
|
||||
@@ -75,16 +75,16 @@ namespace Markdig.Renderers
|
||||
private readonly string _constant;
|
||||
private readonly Queue<string> _lineSpecific;
|
||||
|
||||
public Indent(string constant)
|
||||
internal Indent(string constant)
|
||||
{
|
||||
_constant = constant;
|
||||
}
|
||||
public Indent(IEnumerable<string> lineSpecific)
|
||||
internal Indent(IEnumerable<string> lineSpecific)
|
||||
{
|
||||
_lineSpecific = new Queue<string>(lineSpecific);
|
||||
}
|
||||
|
||||
public string Next()
|
||||
internal string Next()
|
||||
{
|
||||
if (_constant != null)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace Markdig.Syntax
|
||||
else
|
||||
{
|
||||
// We need to expand tabs to spaces
|
||||
// TODO: RTP: also register tabs here
|
||||
var builder = StringBuilderCache.Local();
|
||||
builder.Append(' ', CharHelper.AddTab(column) - column);
|
||||
builder.Append(slice.Text, slice.Start + 1, slice.Length - 1);
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Markdig.Syntax
|
||||
{
|
||||
public StringSlice BeforeWhitespace { get; set; }
|
||||
|
||||
public StringSlice AfterWhitespace { get; set; }
|
||||
|
||||
// support lazy lines
|
||||
public bool QuoteChar { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user