mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Expose shared.js helper code for custom rule authors (fixes #134).
This commit is contained in:
parent
f614f3e1ce
commit
7e980401b8
52 changed files with 283 additions and 184 deletions
11
lib/md019.js
11
lib/md019.js
|
@ -2,19 +2,20 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, atxHeadingSpaceRe, filterTokens, headingStyleFor,
|
||||
rangeFromRegExp } = require("../helpers");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD019", "no-multiple-space-atx" ],
|
||||
"description": "Multiple spaces after hash on atx style heading",
|
||||
"tags": [ "headings", "headers", "atx", "spaces" ],
|
||||
"function": function MD019(params, onError) {
|
||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||
if ((shared.headingStyleFor(token) === "atx") &&
|
||||
filterTokens(params, "heading_open", function forToken(token) {
|
||||
if ((headingStyleFor(token) === "atx") &&
|
||||
/^#+\s\s/.test(token.line)) {
|
||||
shared.addErrorContext(onError, token.lineNumber, token.line.trim(),
|
||||
addErrorContext(onError, token.lineNumber, token.line.trim(),
|
||||
null, null,
|
||||
shared.rangeFromRegExp(token.line, shared.atxHeadingSpaceRe));
|
||||
rangeFromRegExp(token.line, atxHeadingSpaceRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue