Add MD049/emphasis-style (fixes #150).

This commit is contained in:
Sébastien Règne 2021-10-24 06:54:58 +02:00 committed by GitHub
parent aa8aa83db8
commit 39724b991a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 418 additions and 35 deletions

28
lib/md049.js Normal file
View file

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