Update MD027/no-multiple-space-blockquote to handle multiple lines of indented code inside a blockquote (fixes #1393).

This commit is contained in:
David Anson 2024-10-28 21:40:39 -07:00
parent 368cb1be5f
commit 0eedda0a6c
5 changed files with 44 additions and 4 deletions

View file

@ -4680,9 +4680,15 @@ module.exports = {
"tags": [ "blockquote", "whitespace", "indentation" ],
"parser": "micromark",
"function": function MD027(params, onError) {
const { tokens } = params.parsers.micromark;
for (const token of filterByTypesCached([ "linePrefix" ])) {
const siblings = token.parent?.children || params.parsers.micromark.tokens;
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
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];

View file

@ -13,9 +13,15 @@ module.exports = {
"tags": [ "blockquote", "whitespace", "indentation" ],
"parser": "micromark",
"function": function MD027(params, onError) {
const { tokens } = params.parsers.micromark;
for (const token of filterByTypesCached([ "linePrefix" ])) {
const siblings = token.parent?.children || params.parsers.micromark.tokens;
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
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];

View file

@ -46,3 +46,17 @@ Test nothing in the blockquote:
>
{MD027:-1}
<!-- markdownlint-disable code-block-style -->
> Blockquoted code blocks:
>
> Code
> Code
> Code
>
> ```text
> Code
> Code
> Code
> ```

View file

@ -6825,6 +6825,20 @@ Generated by [AVA](https://avajs.dev).
> ␊
{MD027:-1}␊
<!-- markdownlint-disable code-block-style -->
> Blockquoted code blocks:␊
>␊
> Code␊
> Code␊
> Code␊
>␊
> \`\`\`text␊
> Code␊
> Code␊
> Code␊
> \`\`\`␊
`,
}