mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Add TOML title syntax to MD041/first-line-h1 default RegExp (fixes #77).
This commit is contained in:
parent
77e27cbe09
commit
0c38635afe
7 changed files with 26 additions and 4 deletions
|
|
@ -1045,7 +1045,7 @@ module.exports = [
|
||||||
var frontMatterTitle = params.options.front_matter_title;
|
var frontMatterTitle = params.options.front_matter_title;
|
||||||
var tag = "h" + level;
|
var tag = "h" + level;
|
||||||
var frontMatterTitleRe =
|
var frontMatterTitleRe =
|
||||||
new RegExp(frontMatterTitle || "^\\s*title:", "i");
|
new RegExp(frontMatterTitle || "^\\s*title\\s*[:=]", "i");
|
||||||
params.tokens.every(function forToken(token, index) {
|
params.tokens.every(function forToken(token, index) {
|
||||||
if (token.type === "heading_open") {
|
if (token.type === "heading_open") {
|
||||||
if (!((token.lineNumber === 1) || (index > 0)) ||
|
if (!((token.lineNumber === 1) || (index > 0)) ||
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ rules.forEach(function forRule(rule) {
|
||||||
"front_matter_title": {
|
"front_matter_title": {
|
||||||
"description": "RegExp for matching title in front matter",
|
"description": "RegExp for matching title in front matter",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "^\\s*title:"
|
"default": "^\\s*title\\s*[:=]"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -832,7 +832,7 @@
|
||||||
"front_matter_title": {
|
"front_matter_title": {
|
||||||
"description": "RegExp for matching title in front matter",
|
"description": "RegExp for matching title in front matter",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "^\\s*title:"
|
"default": "^\\s*title\\s*[:=]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
@ -853,7 +853,7 @@
|
||||||
"front_matter_title": {
|
"front_matter_title": {
|
||||||
"description": "RegExp for matching title in front matter",
|
"description": "RegExp for matching title in front matter",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "^\\s*title:"
|
"default": "^\\s*title\\s*[:=]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
|
||||||
6
test/front-matter-alt-title-toml.json
Normal file
6
test/front-matter-alt-title-toml.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"MD041": {
|
||||||
|
"front_matter_title": "^\\s*alternate\\s*="
|
||||||
|
}
|
||||||
|
}
|
||||||
6
test/front-matter-alt-title-toml.md
Normal file
6
test/front-matter-alt-title-toml.md
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
+++
|
||||||
|
date = "2017-01-26T22:17:00+02:00"
|
||||||
|
alternate = "My document title and header"
|
||||||
|
+++
|
||||||
|
|
||||||
|
Some plain text here.
|
||||||
4
test/front-matter-title-toml.json
Normal file
4
test/front-matter-title-toml.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"MD041": true
|
||||||
|
}
|
||||||
6
test/front-matter-title-toml.md
Normal file
6
test/front-matter-title-toml.md
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
+++
|
||||||
|
date = "2017-01-26T22:17:00+02:00"
|
||||||
|
title = "My document title and header"
|
||||||
|
+++
|
||||||
|
|
||||||
|
Some plain text here.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue