mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-20 16:00:13 +01: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
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, filterTokens, rangeFromRegExp } =
|
||||
require("../helpers");
|
||||
|
||||
const spaceBeforeHeadingRe = /^((?:\s+)|(?:[>\s]+\s\s))[^>\s]/;
|
||||
|
||||
|
|
@ -11,10 +12,10 @@ module.exports = {
|
|||
"description": "Headings must start at the beginning of the line",
|
||||
"tags": [ "headings", "headers", "spaces" ],
|
||||
"function": function MD023(params, onError) {
|
||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||
filterTokens(params, "heading_open", function forToken(token) {
|
||||
if (spaceBeforeHeadingRe.test(token.line)) {
|
||||
shared.addErrorContext(onError, token.lineNumber, token.line, null,
|
||||
null, shared.rangeFromRegExp(token.line, spaceBeforeHeadingRe));
|
||||
addErrorContext(onError, token.lineNumber, token.line, null,
|
||||
null, rangeFromRegExp(token.line, spaceBeforeHeadingRe));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue