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

25 lines
808 B
JavaScript

// @ts-check
"use strict";
var shared = require("./shared");
var atxClosedHeadingNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
module.exports = {
"names": [ "MD020", "no-missing-space-closed-atx" ],
"description": "No space inside hashes on closed atx style heading",
"tags": [ "headings", "headers", "atx_closed", "spaces" ],
"function": function MD020(params, onError) {
shared.forEachLine(function forLine(line, lineIndex, inCode) {
if (!inCode && /^#+[^#]*[^\\]#+$/.test(line)) {
var left = /^#+[^#\s]/.test(line);
var right = /[^#\s]#+$/.test(line);
if (left || right) {
shared.addErrorContext(onError, lineIndex + 1, line.trim(), left,
right, shared.rangeFromRegExp(line, atxClosedHeadingNoSpaceRe));
}
}
});
}
};