diff --git a/src/Markdig.Tests/Specs/Specs.cs b/src/Markdig.Tests/Specs/Specs.cs index 46ae247a..45bd5979 100644 --- a/src/Markdig.Tests/Specs/Specs.cs +++ b/src/Markdig.Tests/Specs/Specs.cs @@ -20492,6 +20492,124 @@ namespace Markdig.Tests Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 3, "Extensions YAML frontmatter discard"); TestParser.TestSpec("----\nthis: is a frontmatter\n----\nThis is a text", "
This is a text
", "yaml"); } + } + // It can end with three dots `...`: + [TestFixture] + public partial class TestExtensionsYAMLfrontmatterdiscard + { + [Test] + public void Example004() + { + // Example 4 + // Section: Extensions YAML frontmatter discard + // + // The following CommonMark: + // --- + // this: is a frontmatter + // ... + // This is a text + // + // Should be rendered as: + //This is a text
+ + Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 4, "Extensions YAML frontmatter discard"); + TestParser.TestSpec("---\nthis: is a frontmatter\n...\nThis is a text", "This is a text
", "yaml"); + } + } + // It expects exactly three dots `...`: + [TestFixture] + public partial class TestExtensionsYAMLfrontmatterdiscard + { + [Test] + public void Example005() + { + // Example 5 + // Section: Extensions YAML frontmatter discard + // + // The following CommonMark: + // --- + // this: is a frontmatter + // .... + // This is a text + // + // Should be rendered as: + // + + Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 5, "Extensions YAML frontmatter discard"); + TestParser.TestSpec("---\nthis: is a frontmatter\n....\nThis is a text", "", "yaml"); + } + } + // Front matter ends with the first line containing three dots `...` or three dashes `...`: + [TestFixture] + public partial class TestExtensionsYAMLfrontmatterdiscard + { + [Test] + public void Example006() + { + // Example 6 + // Section: Extensions YAML frontmatter discard + // + // The following CommonMark: + // --- + // this: is a frontmatter + // .... + // + // Hello + // --- + // This is a text + // + // Should be rendered as: + //This is a text
+ + Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 6, "Extensions YAML frontmatter discard"); + TestParser.TestSpec("---\nthis: is a frontmatter\n....\n\nHello\n---\nThis is a text", "This is a text
", "yaml"); + } + } + // It expects whitespace can exist after the leading characters + [TestFixture] + public partial class TestExtensionsYAMLfrontmatterdiscard + { + [Test] + public void Example007() + { + // Example 7 + // Section: Extensions YAML frontmatter discard + // + // The following CommonMark: + // --- + // this: is a frontmatter + // ... + // This is a text + // + // Should be rendered as: + //This is a text
+ + Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 7, "Extensions YAML frontmatter discard"); + TestParser.TestSpec("--- \nthis: is a frontmatter\n...\nThis is a text", "This is a text
", "yaml"); + } + } + // It expects whitespace can exist after the trailing characters + [TestFixture] + public partial class TestExtensionsYAMLfrontmatterdiscard + { + [Test] + public void Example008() + { + // Example 8 + // Section: Extensions YAML frontmatter discard + // + // The following CommonMark: + // --- + // this: is a frontmatter + // ... + // This is a text + // + // Should be rendered as: + //This is a text
+ + Console.WriteLine("Example {0}" + Environment.NewLine + "Section: {0}" + Environment.NewLine, 8, "Extensions YAML frontmatter discard"); + TestParser.TestSpec("---\nthis: is a frontmatter\n... \nThis is a text", "This is a text
", "yaml"); + } } // # Extensions // diff --git a/src/Markdig.Tests/Specs/YamlSpecs.md b/src/Markdig.Tests/Specs/YamlSpecs.md index 10bb678f..b6ff478b 100644 --- a/src/Markdig.Tests/Specs/YamlSpecs.md +++ b/src/Markdig.Tests/Specs/YamlSpecs.md @@ -42,3 +42,62 @@ This is a textThis is a text
```````````````````````````````` +It can end with three dots `...`: + +```````````````````````````````` example +--- +this: is a frontmatter +... +This is a text +. +This is a text
+```````````````````````````````` + +It expects exactly three dots `...`: + +```````````````````````````````` example +--- +this: is a frontmatter +.... +This is a text +. +```````````````````````````````` + +Front matter ends with the first line containing three dots `...` or three dashes `...`: + +```````````````````````````````` example +--- +this: is a frontmatter +.... + +Hello +--- +This is a text +. +This is a text
+```````````````````````````````` + +It expects whitespace can exist after the leading characters + +```````````````````````````````` example +--- +this: is a frontmatter +... +This is a text +. +This is a text
+```````````````````````````````` + +It expects whitespace can exist after the trailing characters + +```````````````````````````````` example +--- +this: is a frontmatter +... +This is a text +. +This is a text
+```````````````````````````````` + + + diff --git a/src/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs b/src/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs index 45a37fd5..e6018740 100644 --- a/src/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs +++ b/src/Markdig/Extensions/Yaml/YamlFrontMatterBlock.cs @@ -10,7 +10,7 @@ namespace Markdig.Extensions.Yaml /// A YAML frontmatter block. /// ///