-
-
Notifications
You must be signed in to change notification settings - Fork 745
/
Copy pathmd027.mjs
40 lines (38 loc) · 1.21 KB
/
md027.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ts-check
import { addErrorContext } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";
/** @type {import("markdownlint").Rule} */
export default {
"names": [ "MD027", "no-multiple-space-blockquote" ],
"description": "Multiple spaces after blockquote symbol",
"tags": [ "blockquote", "whitespace", "indentation" ],
"parser": "micromark",
"function": function MD027(params, onError) {
const { tokens } = params.parsers.micromark;
for (const token of filterByTypesCached([ "linePrefix" ])) {
const parent = token.parent;
const codeIndented = parent?.type === "codeIndented";
const siblings = parent?.children || tokens;
if (
!codeIndented &&
(siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix")
) {
const { startColumn, startLine, text } = token;
const { length } = text;
const line = params.lines[startLine - 1];
addErrorContext(
onError,
startLine,
line,
undefined,
undefined,
[ startColumn, length ],
{
"editColumn": startColumn,
"deleteCount": length
}
);
}
}
}
};