Update MD041/first-line-heading to recognize HTML headings (fixes #366).

This commit is contained in:
David Anson 2021-01-31 15:48:00 -08:00
parent c7d2416f95
commit 1d042aa3fd
7 changed files with 69 additions and 4 deletions

View file

@ -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;