Add TOML title syntax to MD041/first-line-h1 default RegExp (fixes #77).

This commit is contained in:
David Anson 2017-10-24 22:15:03 -07:00
parent 77e27cbe09
commit 0c38635afe
7 changed files with 26 additions and 4 deletions

View file

@ -1045,7 +1045,7 @@ module.exports = [
var frontMatterTitle = params.options.front_matter_title;
var tag = "h" + level;
var frontMatterTitleRe =
new RegExp(frontMatterTitle || "^\\s*title:", "i");
new RegExp(frontMatterTitle || "^\\s*title\\s*[:=]", "i");
params.tokens.every(function forToken(token, index) {
if (token.type === "heading_open") {
if (!((token.lineNumber === 1) || (index > 0)) ||

View file

@ -224,7 +224,7 @@ rules.forEach(function forRule(rule) {
"front_matter_title": {
"description": "RegExp for matching title in front matter",
"type": "string",
"default": "^\\s*title:"
"default": "^\\s*title\\s*[:=]"
}
};
break;

View file

@ -832,7 +832,7 @@
"front_matter_title": {
"description": "RegExp for matching title in front matter",
"type": "string",
"default": "^\\s*title:"
"default": "^\\s*title\\s*[:=]"
}
},
"additionalProperties": false
@ -853,7 +853,7 @@
"front_matter_title": {
"description": "RegExp for matching title in front matter",
"type": "string",
"default": "^\\s*title:"
"default": "^\\s*title\\s*[:=]"
}
},
"additionalProperties": false

View file

@ -0,0 +1,6 @@
{
"default": true,
"MD041": {
"front_matter_title": "^\\s*alternate\\s*="
}
}

View file

@ -0,0 +1,6 @@
+++
date = "2017-01-26T22:17:00+02:00"
alternate = "My document title and header"
+++
Some plain text here.

View file

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

View file

@ -0,0 +1,6 @@
+++
date = "2017-01-26T22:17:00+02:00"
title = "My document title and header"
+++
Some plain text here.