mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
26
lib/md021.js
Normal file
26
lib/md021.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
var atxClosedHeaderSpaceRe = /(?:^#+\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 header",
|
||||
"tags": [ "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, atxClosedHeaderSpaceRe));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue