mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Update MD027/no-multiple-space-blockquote to handle multiple lines of indented code inside a blockquote (fixes #1393).
This commit is contained in:
parent
368cb1be5f
commit
0eedda0a6c
5 changed files with 44 additions and 4 deletions
|
@ -4680,9 +4680,15 @@ module.exports = {
|
||||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD027(params, onError) {
|
"function": function MD027(params, onError) {
|
||||||
|
const { tokens } = params.parsers.micromark;
|
||||||
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
||||||
const siblings = token.parent?.children || params.parsers.micromark.tokens;
|
const parent = token.parent;
|
||||||
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
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 { startColumn, startLine, text } = token;
|
||||||
const { length } = text;
|
const { length } = text;
|
||||||
const line = params.lines[startLine - 1];
|
const line = params.lines[startLine - 1];
|
||||||
|
|
10
lib/md027.js
10
lib/md027.js
|
@ -13,9 +13,15 @@ module.exports = {
|
||||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD027(params, onError) {
|
"function": function MD027(params, onError) {
|
||||||
|
const { tokens } = params.parsers.micromark;
|
||||||
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
||||||
const siblings = token.parent?.children || params.parsers.micromark.tokens;
|
const parent = token.parent;
|
||||||
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
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 { startColumn, startLine, text } = token;
|
||||||
const { length } = text;
|
const { length } = text;
|
||||||
const line = params.lines[startLine - 1];
|
const line = params.lines[startLine - 1];
|
||||||
|
|
|
@ -46,3 +46,17 @@ Test nothing in the blockquote:
|
||||||
|
|
||||||
>
|
>
|
||||||
{MD027:-1}
|
{MD027:-1}
|
||||||
|
|
||||||
|
<!-- markdownlint-disable code-block-style -->
|
||||||
|
|
||||||
|
> Blockquoted code blocks:
|
||||||
|
>
|
||||||
|
> Code
|
||||||
|
> Code
|
||||||
|
> Code
|
||||||
|
>
|
||||||
|
> ```text
|
||||||
|
> Code
|
||||||
|
> Code
|
||||||
|
> Code
|
||||||
|
> ```
|
||||||
|
|
|
@ -6825,6 +6825,20 @@ Generated by [AVA](https://avajs.dev).
|
||||||
␊
|
␊
|
||||||
> ␊
|
> ␊
|
||||||
{MD027:-1}␊
|
{MD027:-1}␊
|
||||||
|
␊
|
||||||
|
<!-- markdownlint-disable code-block-style -->␊
|
||||||
|
␊
|
||||||
|
> Blockquoted code blocks:␊
|
||||||
|
>␊
|
||||||
|
> Code␊
|
||||||
|
> Code␊
|
||||||
|
> Code␊
|
||||||
|
>␊
|
||||||
|
> \`\`\`text␊
|
||||||
|
> Code␊
|
||||||
|
> Code␊
|
||||||
|
> Code␊
|
||||||
|
> \`\`\`␊
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue