fix(markdown): trailing spaces after front matters are allowed (#5107)
```md ---···· <--- allowed yaml ---···· <--- allowed markdown ```master
parent
27bf64f6ce
commit
0cbacd3156
|
@ -13,14 +13,17 @@ function parse(text) {
|
|||
.join("|");
|
||||
|
||||
const match = text.match(
|
||||
new RegExp(`^(${delimiterRegex})\\n(?:([\\s\\S]*?)\\n)?\\1(\\n|$)`)
|
||||
// trailing spaces after delimiters are allowed
|
||||
new RegExp(
|
||||
`^(${delimiterRegex})[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)`
|
||||
)
|
||||
);
|
||||
|
||||
if (match === null) {
|
||||
return { frontMatter: null, content: text };
|
||||
}
|
||||
|
||||
const raw = match[0].trimRight();
|
||||
const raw = match[0].replace(/\n$/, "");
|
||||
const delimiter = match[1];
|
||||
const value = match[2];
|
||||
|
||||
|
|
|
@ -64,3 +64,22 @@ hello: world
|
|||
Content
|
||||
|
||||
`;
|
||||
|
||||
exports[`trailing-spaces.md - markdown-verify 1`] = `
|
||||
---
|
||||
v spaces
|
||||
---
|
||||
|
||||
This paragraph should be considered part of the _markdown_ instead of *yaml*.
|
||||
|
||||
---
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
---
|
||||
v spaces
|
||||
---
|
||||
|
||||
This paragraph should be considered part of the _markdown_ instead of _yaml_.
|
||||
|
||||
---
|
||||
|
||||
`;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
v spaces
|
||||
---
|
||||
|
||||
This paragraph should be considered part of the _markdown_ instead of *yaml*.
|
||||
|
||||
---
|
Loading…
Reference in New Issue