2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2023-03-06 21:38:40 -08:00
|
|
|
const { addErrorDetailIf } = require("../helpers");
|
|
|
|
const { filterByTypes } = require("../helpers/micromark.cjs");
|
2018-01-21 21:44:25 -08:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
"names": [ "MD035", "hr-style" ],
|
|
|
|
"description": "Horizontal rule style",
|
|
|
|
"tags": [ "hr" ],
|
|
|
|
"function": function MD035(params, onError) {
|
2022-04-28 21:53:51 -07:00
|
|
|
let style = String(params.config.style || "consistent").trim();
|
2023-03-06 21:38:40 -08:00
|
|
|
const thematicBreaks =
|
|
|
|
filterByTypes(params.parsers.micromark.tokens, [ "thematicBreak" ]);
|
|
|
|
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
|
|
|
}
|
|
|
|
};
|