mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02: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
|
@ -3558,11 +3558,24 @@ module.exports = {
|
|||
var tag = "h" + level;
|
||||
var foundFrontMatterTitle = frontMatterHasTitle(params.frontMatterLines, params.config.front_matter_title);
|
||||
if (!foundFrontMatterTitle) {
|
||||
var htmlHeadingRe_1 = new RegExp("^<h" + level + "[ />]", "i");
|
||||
params.tokens.every(function (token) {
|
||||
var isError = false;
|
||||
if (token.type === "html_block") {
|
||||
return true;
|
||||
if (token.content.startsWith("<!--")) {
|
||||
// Ignore leading HTML comments
|
||||
return true;
|
||||
}
|
||||
else if (!htmlHeadingRe_1.test(token.content)) {
|
||||
// Something other than an HTML heading
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
if ((token.type !== "heading_open") || (token.tag !== tag)) {
|
||||
else if ((token.type !== "heading_open") || (token.tag !== tag)) {
|
||||
// Something other than a Markdown heading
|
||||
isError = true;
|
||||
}
|
||||
if (isError) {
|
||||
addErrorContext(onError, token.lineNumber, token.line);
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue