Fix: not greedy match the frontmatter in postcss parser (#4457)
parent
b504e79113
commit
2f5c00ad18
|
@ -439,7 +439,7 @@ function parseNestedCSS(node) {
|
||||||
|
|
||||||
function parseWithParser(parser, text) {
|
function parseWithParser(parser, text) {
|
||||||
let result;
|
let result;
|
||||||
const frontMatterMatches = text.match(/^---(\n[\s\S]*)?\n---/);
|
const frontMatterMatches = text.match(/^---(\n[\s\S]*?)?\n---/);
|
||||||
const frontMatter = frontMatterMatches && frontMatterMatches[0];
|
const frontMatter = frontMatterMatches && frontMatterMatches[0];
|
||||||
const normalizedText = frontMatter ? text.substr(frontMatter.length) : text;
|
const normalizedText = frontMatter ? text.substr(frontMatter.length) : text;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,33 @@ a {
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`malformed-2.css 1`] = `
|
||||||
|
---
|
||||||
|
foo: bar
|
||||||
|
---
|
||||||
|
|
||||||
|
a {
|
||||||
|
color:blue
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
.b {
|
||||||
|
color:red
|
||||||
|
}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
---
|
||||||
|
foo: bar
|
||||||
|
---
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
--- .b {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`only_comments.css 1`] = `
|
exports[`only_comments.css 1`] = `
|
||||||
---
|
---
|
||||||
# comment 1
|
# comment 1
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
foo: bar
|
||||||
|
---
|
||||||
|
|
||||||
|
a {
|
||||||
|
color:blue
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
.b {
|
||||||
|
color:red
|
||||||
|
}
|
Loading…
Reference in New Issue