mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update MD041/first-line-heading to recognize HTML headings (fixes #366).
This commit is contained in:
parent
c7d2416f95
commit
1d042aa3fd
7 changed files with 69 additions and 4 deletions
15
lib/md041.js
15
lib/md041.js
|
|
@ -17,11 +17,22 @@ module.exports = {
|
|||
params.config.front_matter_title
|
||||
);
|
||||
if (!foundFrontMatterTitle) {
|
||||
const htmlHeadingRe = new RegExp(`^<h${level}[ />]`, "i");
|
||||
params.tokens.every((token) => {
|
||||
let isError = false;
|
||||
if (token.type === "html_block") {
|
||||
return true;
|
||||
if (token.content.startsWith("<!--")) {
|
||||
// Ignore leading HTML comments
|
||||
return true;
|
||||
} else if (!htmlHeadingRe.test(token.content)) {
|
||||
// Something other than an HTML heading
|
||||
isError = true;
|
||||
}
|
||||
} else if ((token.type !== "heading_open") || (token.tag !== tag)) {
|
||||
// Something other than a Markdown heading
|
||||
isError = true;
|
||||
}
|
||||
if ((token.type !== "heading_open") || (token.tag !== tag)) {
|
||||
if (isError) {
|
||||
addErrorContext(onError, token.lineNumber, token.line);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue