mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
26 lines
801 B
JavaScript
26 lines
801 B
JavaScript
![]() |
// @ts-check
|
||
|
|
||
|
"use strict";
|
||
|
|
||
|
var shared = require("./shared");
|
||
|
|
||
|
var atxClosedHeaderNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
|
||
|
|
||
|
module.exports = {
|
||
|
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
||
|
"description": "No space inside hashes on closed atx style header",
|
||
|
"tags": [ "headers", "atx_closed", "spaces" ],
|
||
|
"function": function MD020(params, onError) {
|
||
|
shared.forEachLine(params, 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, atxClosedHeaderNoSpaceRe));
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
};
|