2018-01-21 21:44:25 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2019-04-13 11:18:57 -07:00
|
|
|
const { addErrorDetailIf, filterTokens } = require("../helpers");
|
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();
|
2021-12-14 23:05:03 -08:00
|
|
|
filterTokens(params, "hr", (token) => {
|
2022-04-28 21:53:51 -07:00
|
|
|
const { line, lineNumber } = token;
|
|
|
|
let { markup } = token;
|
2022-12-19 21:36:24 -08:00
|
|
|
const match = line.match(/[_*\-\s]+$/);
|
2022-04-28 21:53:51 -07:00
|
|
|
if (match) {
|
|
|
|
markup = match[0].trim();
|
|
|
|
}
|
2018-01-21 21:44:25 -08:00
|
|
|
if (style === "consistent") {
|
2021-12-14 23:05:03 -08:00
|
|
|
style = markup;
|
2018-01-21 21:44:25 -08:00
|
|
|
}
|
2021-12-14 23:05:03 -08:00
|
|
|
addErrorDetailIf(onError, lineNumber, style, markup);
|
2018-01-21 21:44:25 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|