mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Add front_matter_title parameter to MD025/single-title/single-h1 (refs #169).
This commit is contained in:
parent
050cbbba82
commit
61d6311a3e
14 changed files with 124 additions and 32 deletions
|
|
@ -5,16 +5,21 @@
|
|||
const shared = require("./shared");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD025", "single-h1" ],
|
||||
"names": [ "MD025", "single-title", "single-h1" ],
|
||||
"description": "Multiple top level headings in the same document",
|
||||
"tags": [ "headings", "headers" ],
|
||||
"function": function MD025(params, onError) {
|
||||
const level = params.config.level || 1;
|
||||
const tag = "h" + level;
|
||||
const foundFrontMatterTitle =
|
||||
shared.frontMatterHasTitle(
|
||||
params.frontMatterLines,
|
||||
params.config.front_matter_title
|
||||
);
|
||||
let hasTopLevelHeading = false;
|
||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||
if (token.tag === tag) {
|
||||
if (hasTopLevelHeading) {
|
||||
if (hasTopLevelHeading || foundFrontMatterTitle) {
|
||||
shared.addErrorContext(onError, token.lineNumber,
|
||||
token.line.trim());
|
||||
} else if (token.lineNumber === 1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue