mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Update MD049/emphasis-style and MD050/strong-style to correctly report and fix multiple identical violations on the same line (fixes #486).
This commit is contained in:
parent
54369a00e6
commit
c4f51090ae
8 changed files with 258 additions and 42 deletions
13
lib/md050.js
13
lib/md050.js
|
|
@ -11,6 +11,8 @@ module.exports = {
|
|||
"tags": [ "emphasis" ],
|
||||
"function": function MD050(params, onError) {
|
||||
let expectedStyle = String(params.config.style || "consistent");
|
||||
let lastLineNumber = -1;
|
||||
const instances = new Map();
|
||||
forEachInlineChild(params, "strong_open", (token, parent) => {
|
||||
const { lineNumber, markup } = token;
|
||||
const markupStyle = emphasisOrStrongStyleFor(markup);
|
||||
|
|
@ -27,8 +29,17 @@ module.exports = {
|
|||
const actual = `${markup}${content}${markup}`;
|
||||
const expectedMarkup = (expectedStyle === "asterisk") ? "**" : "__";
|
||||
const expected = `${expectedMarkup}${content}${expectedMarkup}`;
|
||||
if (lastLineNumber !== lineNumber) {
|
||||
lastLineNumber = lineNumber;
|
||||
instances.clear();
|
||||
}
|
||||
instances.set(expected, (instances.get(expected) || 0) + 1);
|
||||
rangeAndFixInfo = getRangeAndFixInfoIfFound(
|
||||
params.lines, lineNumber - 1, actual, expected
|
||||
params.lines,
|
||||
lineNumber - 1,
|
||||
actual,
|
||||
expected,
|
||||
instances.get(expected)
|
||||
);
|
||||
}
|
||||
addError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue