2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2024-02-25 15:06:28 -08:00
|
|
|
const { addErrorContext } = require("../helpers");
|
2024-02-26 21:07:24 -08:00
|
|
|
const { filterByTypes } = require("../helpers/micromark.cjs");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
2024-02-27 20:42:09 -08:00
|
|
|
// eslint-disable-next-line jsdoc/valid-types
|
|
|
|
/** @type import("./markdownlint").Rule */
|
2018-01-21 21:44:25 -08:00
|
|
|
module.exports = {
|
2024-02-25 15:06:28 -08:00
|
|
|
"names": ["MD027", "no-multiple-space-blockquote"],
|
2018-01-21 21:44:25 -08:00
|
|
|
"description": "Multiple spaces after blockquote symbol",
|
2024-02-25 15:06:28 -08:00
|
|
|
"tags": ["blockquote", "whitespace", "indentation"],
|
2024-03-09 16:17:50 -08:00
|
|
|
"parser": "micromark",
|
2018-01-21 21:44:25 -08:00
|
|
|
"function": function MD027(params, onError) {
|
2024-02-28 21:01:23 -08:00
|
|
|
// eslint-disable-next-line jsdoc/valid-types
|
|
|
|
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
|
|
const micromarkTokens =
|
|
|
|
// @ts-ignore
|
|
|
|
params.parsers.micromark.tokens;
|
|
|
|
for (const token of filterByTypes(micromarkTokens, [ "linePrefix" ])) {
|
|
|
|
const siblings = token.parent?.children || micromarkTokens;
|
2024-02-26 21:07:24 -08:00
|
|
|
if (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,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
[ startColumn, length ],
|
|
|
|
{
|
|
|
|
"editColumn": startColumn,
|
|
|
|
"deleteCount": length
|
|
|
|
}
|
|
|
|
);
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
|
|
|
};
|