2018-02-15 21:35:58 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2024-12-03 19:58:28 -08:00
|
|
|
/** @type {import("markdownlint").Rule[]} */
|
2024-10-01 22:41:10 -07:00
|
|
|
module.exports = [
|
|
|
|
|
|
|
|
// micromark parser (preferred)
|
|
|
|
{
|
|
|
|
"names": [ "any-blockquote-micromark" ],
|
|
|
|
"description": "Rule that reports an error for any blockquote",
|
|
|
|
"information": new URL(
|
|
|
|
"https://github.com/DavidAnson/markdownlint/blob/main/test/rules/any-blockquote.js"
|
|
|
|
),
|
|
|
|
"tags": [ "test" ],
|
|
|
|
"parser": "micromark",
|
|
|
|
"function": (params, onError) => {
|
|
|
|
const blockquotes = params.parsers.micromark.tokens
|
2024-10-06 21:03:07 -07:00
|
|
|
.filter((token) => token.type === "blockQuote");
|
2024-10-01 22:41:10 -07:00
|
|
|
for (const blockquote of blockquotes) {
|
|
|
|
const lines = blockquote.endLine - blockquote.startLine + 1;
|
|
|
|
onError({
|
|
|
|
"lineNumber": blockquote.startLine,
|
|
|
|
"detail": "Blockquote spans " + lines + " line(s).",
|
|
|
|
"context": params.lines[blockquote.startLine - 1]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// markdown-it parser (legacy)
|
|
|
|
{
|
|
|
|
"names": [ "any-blockquote-markdown-it" ],
|
|
|
|
"description": "Rule that reports an error for any blockquote",
|
|
|
|
"information": new URL(
|
|
|
|
"https://github.com/DavidAnson/markdownlint/blob/main/test/rules/any-blockquote.js"
|
|
|
|
),
|
|
|
|
"tags": [ "test" ],
|
|
|
|
"parser": "markdownit",
|
|
|
|
"function": (params, onError) => {
|
|
|
|
const blockquotes = params.parsers.markdownit.tokens
|
2024-10-06 21:03:07 -07:00
|
|
|
.filter((token) => token.type === "blockquote_open");
|
2024-10-01 22:41:10 -07:00
|
|
|
for (const blockquote of blockquotes) {
|
|
|
|
const [ startIndex, endIndex ] = blockquote.map;
|
|
|
|
const lines = endIndex - startIndex;
|
|
|
|
onError({
|
|
|
|
"lineNumber": blockquote.lineNumber,
|
|
|
|
"detail": "Blockquote spans " + lines + " line(s).",
|
|
|
|
"context": blockquote.line
|
|
|
|
});
|
|
|
|
}
|
2024-08-18 15:34:26 -07:00
|
|
|
}
|
2018-02-15 21:35:58 -08:00
|
|
|
}
|
2024-10-01 22:41:10 -07:00
|
|
|
|
|
|
|
];
|