mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Remove state from shared.js, move to cache.js.
This commit is contained in:
parent
827e1acb56
commit
f614f3e1ce
17 changed files with 124 additions and 98 deletions
|
@ -2,7 +2,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const shared = require("./shared");
|
||||
const { addErrorContext, forEachLine, rangeFromRegExp } = require("./shared");
|
||||
const { lineMetadata } = require("./cache");
|
||||
|
||||
const atxClosedHeadingNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
|
||||
|
||||
|
@ -11,13 +12,13 @@ module.exports = {
|
|||
"description": "No space inside hashes on closed atx style heading",
|
||||
"tags": [ "headings", "headers", "atx_closed", "spaces" ],
|
||||
"function": function MD020(params, onError) {
|
||||
shared.forEachLine(function forLine(line, lineIndex, inCode) {
|
||||
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
||||
if (!inCode && /^#+[^#]*[^\\]#+$/.test(line)) {
|
||||
const left = /^#+[^#\s]/.test(line);
|
||||
const right = /[^#\s]#+$/.test(line);
|
||||
if (left || right) {
|
||||
shared.addErrorContext(onError, lineIndex + 1, line.trim(), left,
|
||||
right, shared.rangeFromRegExp(line, atxClosedHeadingNoSpaceRe));
|
||||
addErrorContext(onError, lineIndex + 1, line.trim(), left,
|
||||
right, rangeFromRegExp(line, atxClosedHeadingNoSpaceRe));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue