Ignore TOML front matter in addition to YAML (fixes #63).

This commit is contained in:
David Anson 2017-07-02 20:33:29 -07:00
parent 0e8cb8f0dd
commit 5bea80f5cd
9 changed files with 38 additions and 8 deletions

View file

@ -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`

View file

@ -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 =

View file

@ -0,0 +1,4 @@
{
"default": true,
"MD041": true
}

4
test/front-matter.json Normal file
View file

@ -0,0 +1,4 @@
{
"default": true,
"MD041": true
}

View file

@ -1,7 +1,6 @@
---
front: matter
---
# Header 1
## Header 2

View file

@ -0,0 +1,4 @@
{
"default": true,
"MD041": true
}

View file

@ -0,0 +1,7 @@
+++
date = "2016-02-14T16:11:58+05:30"
draft = true
title = "Good to Great Book Review"
+++
# Header 1

View file

@ -0,0 +1,4 @@
{
"default": true,
"MD041": true
}

View file

@ -0,0 +1,8 @@
+++
date = "2016-02-14T16:11:58+05:30"
draft = true
title = "Good to Great Book Review"
+++
# Header 1 {MD041}