mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update MD027/no-multiple-space-blockquote to add a list_items parameter (fixes #1473).
This commit is contained in:
parent
d02090db2c
commit
435c55f72a
14 changed files with 333 additions and 14 deletions
18
lib/configuration-strict.d.ts
vendored
18
lib/configuration-strict.d.ts
vendored
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue