mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-20 07:50:12 +01:00
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.
This commit is contained in:
parent
f80b61d8b7
commit
d249888ed2
148 changed files with 861 additions and 699 deletions
16
lib/md043.js
16
lib/md043.js
|
|
@ -5,12 +5,12 @@
|
|||
var shared = require("./shared");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD043", "required-headers" ],
|
||||
"description": "Required header structure",
|
||||
"tags": [ "headers" ],
|
||||
"names": [ "MD043", "required-headings", "required-headers" ],
|
||||
"description": "Required heading structure",
|
||||
"tags": [ "headings", "headers" ],
|
||||
"function": function MD043(params, onError) {
|
||||
var requiredHeaders = params.config.headers;
|
||||
if (requiredHeaders) {
|
||||
var requiredHeadings = params.config.headings || params.config.headers;
|
||||
if (requiredHeadings) {
|
||||
var levels = {};
|
||||
[ 1, 2, 3, 4, 5, 6 ].forEach(function forLevel(level) {
|
||||
levels["h" + level] = "######".substr(-level);
|
||||
|
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
shared.forEachHeading(params, function forHeading(heading, content) {
|
||||
if (!errorCount) {
|
||||
var actual = levels[heading.tag] + " " + content;
|
||||
var expected = requiredHeaders[i++] || "[None]";
|
||||
var expected = requiredHeadings[i++] || "[None]";
|
||||
if (expected === "*") {
|
||||
optional = true;
|
||||
} else if (expected.toLowerCase() === actual.toLowerCase()) {
|
||||
|
|
@ -35,9 +35,9 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
});
|
||||
if ((i < requiredHeaders.length) && !errorCount) {
|
||||
if ((i < requiredHeadings.length) && !errorCount) {
|
||||
shared.addErrorContext(onError, params.lines.length,
|
||||
requiredHeaders[i]);
|
||||
requiredHeadings[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue