From bb82b4a95d8cc706d080214ec2278f060cc5ff34 Mon Sep 17 00:00:00 2001 From: Yury Puzynya <3y3@ya.ru> Date: Mon, 14 Apr 2025 03:05:07 +0000 Subject: [PATCH] Omit micromark parsing if there is no related rules --- lib/markdownlint.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/markdownlint.mjs b/lib/markdownlint.mjs index 7930cb83..26a855ff 100644 --- a/lib/markdownlint.mjs +++ b/lib/markdownlint.mjs @@ -490,12 +490,14 @@ function lintContent( const needMarkdownItTokens = enabledRuleList.some( (rule) => (rule.parser === "markdownit") || (rule.parser === undefined) ); + const needMicromarkTokens = enabledRuleList.some( + (rule) => (rule.parser === "micromark") + ); const customRulesPresent = (ruleList.length !== rules.length); // Parse content into parser tokens - const micromarkTokens = micromarkParse( - content, - { "freezeTokens": customRulesPresent } - ); + const micromarkTokens = needMicromarkTokens ? + micromarkParse(content, { "freezeTokens": customRulesPresent }) : + []; // Hide the content of HTML comments from rules const preClearedContent = content; content = helpers.clearHtmlCommentText(content);