mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
28 lines
800 B
JavaScript
28 lines
800 B
JavaScript
// @ts-check
|
|
|
|
"use strict";
|
|
|
|
const { addErrorDetailIf, fencedCodeBlockStyleFor } = require("../helpers");
|
|
|
|
module.exports = {
|
|
"names": [ "MD048", "code-fence-style" ],
|
|
"description": "Code fence style",
|
|
"tags": [ "code" ],
|
|
"function": function MD048(params, onError) {
|
|
const style = String(params.config.style || "consistent");
|
|
let expectedStyle = style;
|
|
const fenceTokens = params.tokens.filter((token) => token.type === "fence");
|
|
for (const fenceToken of fenceTokens) {
|
|
const { lineNumber, markup } = fenceToken;
|
|
if (expectedStyle === "consistent") {
|
|
expectedStyle = fencedCodeBlockStyleFor(markup);
|
|
}
|
|
addErrorDetailIf(
|
|
onError,
|
|
lineNumber,
|
|
expectedStyle,
|
|
fencedCodeBlockStyleFor(markup)
|
|
);
|
|
}
|
|
}
|
|
};
|