mirror of
https://github.com/xoofx/markdig.git
synced 2026-11-16 17:30:52 +00:00
Merge pull request #170 from yishengjin1413/master
fix yaml frontmatter issue when ending with a empty line
This commit is contained in:
@@ -20630,6 +20630,7 @@ namespace Markdig.Tests
|
||||
// The following CommonMark:
|
||||
// ---
|
||||
// this: is a frontmatter
|
||||
//
|
||||
// ...
|
||||
// This is a text
|
||||
//
|
||||
@@ -20637,7 +20638,7 @@ namespace Markdig.Tests
|
||||
// <p>This is a text</p>
|
||||
|
||||
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", "<p>This is a text</p>", "yaml");
|
||||
TestParser.TestSpec("---\nthis: is a frontmatter\n\n...\nThis is a text", "<p>This is a text</p>", "yaml");
|
||||
}
|
||||
}
|
||||
// If the end front matter marker (`...` or `---`) is not present, it will render the `---` has a `<hr>`:
|
||||
|
||||
@@ -47,6 +47,7 @@ It can end with three dots `...`:
|
||||
```````````````````````````````` example
|
||||
---
|
||||
this: is a frontmatter
|
||||
|
||||
...
|
||||
This is a text
|
||||
.
|
||||
|
||||
@@ -82,10 +82,10 @@ namespace Markdig.Extensions.Yaml
|
||||
{
|
||||
c = fullLine.NextChar();
|
||||
}
|
||||
nc = fullLine.NextChar(); // skip \n
|
||||
nc = fullLine.PeekChar();
|
||||
if (nc == '-')
|
||||
{
|
||||
if (fullLine.NextChar() == '-' && fullLine.NextChar() == '-' && (fullLine.NextChar() == '\0' || fullLine.SkipSpacesToEndOfLineOrEndOfDocument()))
|
||||
if (fullLine.NextChar() == '-' && fullLine.NextChar() == '-' && fullLine.NextChar() == '-' && (fullLine.NextChar() == '\0' || fullLine.SkipSpacesToEndOfLineOrEndOfDocument()))
|
||||
{
|
||||
hasFullYamlFrontMatter = true;
|
||||
break;
|
||||
@@ -93,7 +93,7 @@ namespace Markdig.Extensions.Yaml
|
||||
}
|
||||
else if (nc == '.')
|
||||
{
|
||||
if (fullLine.NextChar() == '.' && fullLine.NextChar() == '.' && (fullLine.NextChar() == '\0' || fullLine.SkipSpacesToEndOfLineOrEndOfDocument()))
|
||||
if (fullLine.NextChar() == '.' && fullLine.NextChar() == '.' && fullLine.NextChar() == '.' && (fullLine.NextChar() == '\0' || fullLine.SkipSpacesToEndOfLineOrEndOfDocument()))
|
||||
{
|
||||
hasFullYamlFrontMatter = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user