2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2019-04-13 11:18:57 -07:00
|
|
|
const { addErrorContext, atxHeadingSpaceRe, filterTokens, headingStyleFor,
|
|
|
|
rangeFromRegExp } = require("../helpers");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
"names": [ "MD019", "no-multiple-space-atx" ],
|
2018-03-19 23:39:42 +01:00
|
|
|
"description": "Multiple spaces after hash on atx style heading",
|
|
|
|
"tags": [ "headings", "headers", "atx", "spaces" ],
|
2018-01-21 21:44:25 -08:00
|
|
|
"function": function MD019(params, onError) {
|
2019-04-13 11:18:57 -07:00
|
|
|
filterTokens(params, "heading_open", function forToken(token) {
|
|
|
|
if ((headingStyleFor(token) === "atx") &&
|
2018-01-21 21:44:25 -08:00
|
|
|
/^#+\s\s/.test(token.line)) {
|
2019-04-13 11:18:57 -07:00
|
|
|
addErrorContext(onError, token.lineNumber, token.line.trim(),
|
2018-01-21 21:44:25 -08:00
|
|
|
null, null,
|
2019-04-13 11:18:57 -07:00
|
|
|
rangeFromRegExp(token.line, atxHeadingSpaceRe));
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|