markdownlint/lib/md021.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

26 lines
865 B
JavaScript

// @ts-check
"use strict";
var shared = require("./shared");
var atxClosedHeadingSpaceRe = /(?:^#+\s\s+?\S)|(?:\S\s\s+?#+\s*$)/;
module.exports = {
"names": [ "MD021", "no-multiple-space-closed-atx" ],
"description": "Multiple spaces inside hashes on closed atx style heading",
"tags": [ "headings", "headers", "atx_closed", "spaces" ],
"function": function MD021(params, onError) {
shared.filterTokens(params, "heading_open", function forToken(token) {
if (shared.headingStyleFor(token) === "atx_closed") {
var left = /^#+\s\s/.test(token.line);
var right = /\s\s#+$/.test(token.line);
if (left || right) {
shared.addErrorContext(onError, token.lineNumber, token.line.trim(),
left, right,
shared.rangeFromRegExp(token.line, atxClosedHeadingSpaceRe));
}
}
});
}
};