2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
2024-11-28 20:36:44 -08:00
|
|
|
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|
|
|
import { filterByTypesCached } from "./cache.mjs";
|
2018-01-21 21:44:25 -08:00
|
|
|
|
2024-12-03 19:58:28 -08:00
|
|
|
/** @type {import("markdownlint").Rule} */
|
2024-11-28 20:36:44 -08:00
|
|
|
export default {
|
2018-01-21 21:44:25 -08:00
|
|
|
"names": [ "MD035", "hr-style" ],
|
|
|
|
"description": "Horizontal rule style",
|
|
|
|
"tags": [ "hr" ],
|
2024-03-09 16:17:50 -08:00
|
|
|
"parser": "micromark",
|
2018-01-21 21:44:25 -08:00
|
|
|
"function": function MD035(params, onError) {
|
2022-04-28 21:53:51 -07:00
|
|
|
let style = String(params.config.style || "consistent").trim();
|
2024-08-24 22:05:16 -07:00
|
|
|
const thematicBreaks = filterByTypesCached([ "thematicBreak" ]);
|
2023-03-06 21:38:40 -08:00
|
|
|
for (const token of thematicBreaks) {
|
|
|
|
const { startLine, text } = token;
|
2018-01-21 21:44:25 -08:00
|
|
|
if (style === "consistent") {
|
2023-03-06 21:38:40 -08:00
|
|
|
style = text;
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
2023-03-06 21:38:40 -08:00
|
|
|
addErrorDetailIf(onError, startLine, style, text);
|
|
|
|
}
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
|
|
|
};
|