diff --git a/src/language-css/parser-postcss.js b/src/language-css/parser-postcss.js index 3d59faaf..cb30fb48 100644 --- a/src/language-css/parser-postcss.js +++ b/src/language-css/parser-postcss.js @@ -439,7 +439,7 @@ function parseNestedCSS(node) { function parseWithParser(parser, text) { let result; - const frontMatterMatches = text.match(/^---(\n[\s\S]*)?\n---/); + const frontMatterMatches = text.match(/^---(\n[\s\S]*?)?\n---/); const frontMatter = frontMatterMatches && frontMatterMatches[0]; const normalizedText = frontMatter ? text.substr(frontMatter.length) : text; diff --git a/tests/css_yaml/__snapshots__/jsfmt.spec.js.snap b/tests/css_yaml/__snapshots__/jsfmt.spec.js.snap index 1e00f08c..34c7e9ab 100644 --- a/tests/css_yaml/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css_yaml/__snapshots__/jsfmt.spec.js.snap @@ -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`] = ` --- # comment 1 diff --git a/tests/css_yaml/malformed-2.css b/tests/css_yaml/malformed-2.css new file mode 100644 index 00000000..9f429f27 --- /dev/null +++ b/tests/css_yaml/malformed-2.css @@ -0,0 +1,13 @@ +--- +foo: bar +--- + +a { +color:blue +} + +--- + +.b { +color:red +} \ No newline at end of file