mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD043 to fix required header checks in middle and last when using special char "*" (#396)
This commit is contained in:
parent
9122b8d935
commit
c6d95cb904
8 changed files with 90 additions and 6 deletions
11
lib/md043.js
11
lib/md043.js
|
@ -28,8 +28,11 @@ module.exports = {
|
|||
const actual = levels[heading.tag] + " " + content;
|
||||
const expected = getExpected();
|
||||
if (expected === "*") {
|
||||
matchAny = true;
|
||||
getExpected();
|
||||
const nextExpected = getExpected();
|
||||
if (nextExpected.toLowerCase() !== actual.toLowerCase()) {
|
||||
matchAny = true;
|
||||
i--;
|
||||
}
|
||||
} else if (expected === "+") {
|
||||
matchAny = true;
|
||||
} else if (expected.toLowerCase() === actual.toLowerCase()) {
|
||||
|
@ -43,9 +46,11 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
});
|
||||
const extraHeadings = requiredHeadings.length - i;
|
||||
if (
|
||||
!hasError &&
|
||||
(i < requiredHeadings.length) &&
|
||||
((extraHeadings > 1) ||
|
||||
((extraHeadings === 1) && (requiredHeadings[i] !== "*"))) &&
|
||||
(anyHeadings || !requiredHeadings.every((heading) => heading === "*"))
|
||||
) {
|
||||
addErrorContext(onError, params.lines.length,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue