Add MD050/strong-style (fixes #150).

This commit is contained in:
Sébastien Règne 2021-10-21 06:42:48 +02:00 committed by GitHub
parent 6294ad3ef0
commit ab9e5875a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 255 additions and 19 deletions

28
lib/md050.js Normal file
View file

@ -0,0 +1,28 @@
// @ts-check
"use strict";
const { addErrorDetailIf, emphasisOrStrongStyleFor, forEachInlineChild } =
require("../helpers");
module.exports = {
"names": [ "MD050", "strong-style" ],
"description": "Strong style should be consistent",
"tags": [ "emphasis" ],
"function": function MD050(params, onError) {
let expectedStyle = String(params.config.style || "consistent");
forEachInlineChild(params, "strong_open", (token) => {
const { lineNumber, markup } = token;
const markupStyle = emphasisOrStrongStyleFor(markup);
if (expectedStyle === "consistent") {
expectedStyle = markupStyle;
}
addErrorDetailIf(
onError,
lineNumber,
expectedStyle,
markupStyle
);
});
}
};

View file

@ -50,7 +50,8 @@ const rules = [
require("./md045"),
require("./md046"),
require("./md047"),
require("./md048")
require("./md048"),
require("./md050")
];
rules.forEach((rule) => {
const name = rule.names[0].toLowerCase();