Merge pull request #170 from yishengjin1413/master

fix yaml frontmatter issue when ending with a empty line
This commit is contained in:
Alexandre Mutel
2017-11-20 08:26:47 +01:00
committed by GitHub
3 changed files with 6 additions and 4 deletions

View File

@@ -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>`:

View File

@@ -47,6 +47,7 @@ It can end with three dots `...`:
```````````````````````````````` example
---
this: is a frontmatter
...
This is a text
.

View File

@@ -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;