diff --git a/lib/md041.mjs b/lib/md041.mjs index 89a9a0a9..a3abe923 100644 --- a/lib/md041.mjs +++ b/lib/md041.mjs @@ -11,10 +11,15 @@ export default { "parser": "micromark", "function": function MD041(params, onError) { const level = Number(params.config.level || 1); - if (!frontMatterHasTitle(params.frontMatterLines, params.config.front_matter_title)) { - params.parsers.micromark.tokens - .filter((token) => !nonContentTokens.has(token.type) && !isHtmlFlowComment(token)) - .every((token) => { + const { tokens } = params.parsers.micromark; + if ( + !frontMatterHasTitle( + params.frontMatterLines, + params.config.front_matter_title + ) + ) { + for (const token of tokens) { + if (!nonContentTokens.has(token.type) && !isHtmlFlowComment(token)) { let isError = true; if ((token.type === "atxHeading") || (token.type === "setextHeading")) { isError = (getHeadingLevel(token) !== level); @@ -26,8 +31,9 @@ export default { if (isError) { addErrorContext(onError, token.startLine, params.lines[token.startLine - 1]); } - return false; - }); + break; + } + } } } };