markdownlint/lib/md001.js
Milos Levacic 45424cf459 Change "header" to "heading" across the library
This should be backward compatible, as all "header" aliases are still
available, though documented as discouraged for future use.
2018-04-18 22:27:48 -07:00

22 lines
663 B
JavaScript

// @ts-check
"use strict";
var shared = require("./shared");
module.exports = {
"names": [ "MD001", "heading-increment", "header-increment" ],
"description": "Heading levels should only increment by one level at a time",
"tags": [ "headings", "headers" ],
"function": function MD001(params, onError) {
var prevLevel = 0;
shared.filterTokens(params, "heading_open", function forToken(token) {
var level = parseInt(token.tag.slice(1), 10);
if (prevLevel && (level > prevLevel)) {
shared.addErrorDetailIf(onError, token.lineNumber,
"h" + (prevLevel + 1), "h" + level);
}
prevLevel = level;
});
}
};