diff --git a/README.md b/README.md index c6f9d08c..f36d7c3b 100644 --- a/README.md +++ b/README.md @@ -301,15 +301,13 @@ Some Markdown content begins with metadata; the default `RegExp` for this option ignores common forms of "front matter". To match differently, specify a custom `RegExp` or use the value `null` to disable the feature. -Note: Matches must occur at the start of the file. - -Default: +The default value: ```js -/^---$[^]*?^---$(\r\n|\r|\n)/m +/^(---|\+\+\+)$[^]*?^\1$(\r\n|\r|\n)/m ``` -Ignores: +Ignores [YAML](https://en.wikipedia.org/wiki/YAML) and [TOML](https://en.wikipedia.org/wiki/TOML) such as: ```text --- @@ -318,6 +316,8 @@ title: Title --- ``` +Note: Matches must occur at the start of the file. + ##### options.noInlineConfig Type: `Boolean` diff --git a/lib/shared.js b/lib/shared.js index c3c9f69f..ea64160a 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -3,8 +3,8 @@ // Regular expression for matching common newline characters module.exports.newLineRe = /\r\n|\r|\n/; -// Regular expression for matching common front matter -module.exports.frontMatterRe = /^---$[^]*?^---$(\r\n|\r|\n)/m; +// Regular expression for matching common front matter (YAML and TOML) +module.exports.frontMatterRe = /^(---|\+\+\+)$[^]*?^\1$(\r\n|\r|\n)/m; // Regular expression for matching inline disable/enable comments module.exports.inlineCommentRe = diff --git a/test/front-matter-empty.json b/test/front-matter-empty.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/front-matter-empty.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/front-matter.json b/test/front-matter.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/front-matter.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/front-matter.md b/test/front-matter.md index 16820c72..80662431 100644 --- a/test/front-matter.md +++ b/test/front-matter.md @@ -1,7 +1,6 @@ --- front: matter --- - # Header 1 ## Header 2 diff --git a/test/hugo-quickstart-example-clean.json b/test/hugo-quickstart-example-clean.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/hugo-quickstart-example-clean.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/hugo-quickstart-example-clean.md b/test/hugo-quickstart-example-clean.md new file mode 100644 index 00000000..e0b19bcb --- /dev/null +++ b/test/hugo-quickstart-example-clean.md @@ -0,0 +1,7 @@ ++++ +date = "2016-02-14T16:11:58+05:30" +draft = true +title = "Good to Great Book Review" + ++++ +# Header 1 diff --git a/test/hugo-quickstart-example-issue.json b/test/hugo-quickstart-example-issue.json new file mode 100644 index 00000000..054e8566 --- /dev/null +++ b/test/hugo-quickstart-example-issue.json @@ -0,0 +1,4 @@ +{ + "default": true, + "MD041": true +} diff --git a/test/hugo-quickstart-example-issue.md b/test/hugo-quickstart-example-issue.md new file mode 100644 index 00000000..601cf4f8 --- /dev/null +++ b/test/hugo-quickstart-example-issue.md @@ -0,0 +1,8 @@ ++++ +date = "2016-02-14T16:11:58+05:30" +draft = true +title = "Good to Great Book Review" + ++++ + +# Header 1 {MD041}