diff --git a/README.md b/README.md index d25e93f9..61eee608 100644 --- a/README.md +++ b/README.md @@ -367,7 +367,7 @@ ignores common forms of "front matter". To match differently, specify a custom The default value: ```js -/((^---$[^]*?^---$)|(^\+\+\+$[^]*?^(\+\+\+|\.\.\.)$))(\r\n|\r|\n|$)/m +/((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m ``` Ignores [YAML](https://en.wikipedia.org/wiki/YAML) and diff --git a/helpers/helpers.js b/helpers/helpers.js index 0bd8d8e2..a8f1ae60 100644 --- a/helpers/helpers.js +++ b/helpers/helpers.js @@ -8,7 +8,8 @@ module.exports.newLineRe = /\r[\n\u0085]?|[\n\u2424\u2028\u0085]/; // Regular expression for matching common front matter (YAML and TOML) module.exports.frontMatterRe = - /((^---$[^]*?^---$)|(^\+\+\+$[^]*?^(\+\+\+|\.\.\.)$))(\r\n|\r|\n|$)/m; + // eslint-disable-next-line max-len + /((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m; // Regular expression for matching inline disable/enable comments const inlineCommentRe = diff --git a/test/front-matter-title-pandoc-spaces.json b/test/front-matter-title-pandoc-spaces.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/front-matter-title-pandoc-spaces.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/front-matter-title-pandoc-spaces.md b/test/front-matter-title-pandoc-spaces.md new file mode 100644 index 00000000..29dc4345 --- /dev/null +++ b/test/front-matter-title-pandoc-spaces.md @@ -0,0 +1,6 @@ ++++ +title: "Welcome to pandoc!" +date: 2015-11-17 16:16:01 -0600 +... + +Some plain text here. diff --git a/test/front-matter-title-spaces.json b/test/front-matter-title-spaces.json new file mode 100644 index 00000000..3c524e19 --- /dev/null +++ b/test/front-matter-title-spaces.json @@ -0,0 +1,5 @@ +{ + "default": true, + "MD013": false, + "MD041": true +} diff --git a/test/front-matter-title-spaces.md b/test/front-matter-title-spaces.md new file mode 100644 index 00000000..85516f0e --- /dev/null +++ b/test/front-matter-title-spaces.md @@ -0,0 +1,8 @@ +--- +layout: post +title: "Welcome to Jekyll!" +date: 2015-11-17 16:16:01 -0600 +categories: jekyll update +--- + +Front matter from [Jekyll documentation](https://jekyllrb.com/docs/posts/#a-typical-post). diff --git a/test/front-matter-title-toml-spaces.json b/test/front-matter-title-toml-spaces.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/front-matter-title-toml-spaces.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/front-matter-title-toml-spaces.md b/test/front-matter-title-toml-spaces.md new file mode 100644 index 00000000..46dd03b3 --- /dev/null +++ b/test/front-matter-title-toml-spaces.md @@ -0,0 +1,6 @@ ++++ +date = "2017-01-26T22:17:00+02:00" +title = "My document title and heading" ++++ + +Some plain text here.