Update MD027/no-multiple-space-blockquote to add a list_items parameter (fixes #1473).

This commit is contained in:
David Anson 2025-03-03 23:22:28 -08:00
parent d02090db2c
commit 435c55f72a
14 changed files with 333 additions and 14 deletions

View file

@ -470,11 +470,25 @@ export interface ConfigurationStrict {
/**
* MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md027.md
*/
MD027?: boolean;
MD027?:
| boolean
| {
/**
* Include list items
*/
list_items?: boolean;
};
/**
* MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md027.md
*/
"no-multiple-space-blockquote"?: boolean;
"no-multiple-space-blockquote"?:
| boolean
| {
/**
* Include list items
*/
list_items?: boolean;
};
/**
* MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md028.md
*/

View file

@ -1,8 +1,12 @@
// @ts-check
import { addErrorContext } from "../helpers/helpers.cjs";
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
const listTypes = [ "listOrdered", "listUnordered" ];
/** @type {import("markdownlint").Rule} */
export default {
"names": [ "MD027", "no-multiple-space-blockquote" ],
@ -10,6 +14,8 @@ export default {
"tags": [ "blockquote", "whitespace", "indentation" ],
"parser": "micromark",
"function": function MD027(params, onError) {
const listItems = params.config.list_items;
const includeListItems = (listItems === undefined) ? true : !!listItems;
const { tokens } = params.parsers.micromark;
for (const token of filterByTypesCached([ "linePrefix" ])) {
const parent = token.parent;
@ -17,7 +23,11 @@ export default {
const siblings = parent?.children || tokens;
if (
!codeIndented &&
(siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix")
(siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") &&
(includeListItems || (
!listTypes.includes(siblings[siblings.indexOf(token) + 1]?.type) &&
!getParentOfType(token, listTypes)
))
) {
const { startColumn, startLine, text } = token;
const { length } = text;