mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Refactor to freeze parser tokens only when custom rules are present (negligable performance improvement).
This commit is contained in:
parent
a63972a666
commit
5e1b269fa5
4 changed files with 110 additions and 92 deletions
|
|
@ -495,8 +495,12 @@ function lintContent(
|
|||
const needMarkdownItTokens = enabledRuleList.some(
|
||||
(rule) => (rule.parser === "markdownit") || (rule.parser === undefined)
|
||||
);
|
||||
const customRulesPresent = (ruleList.length !== rules.length);
|
||||
// Parse content into parser tokens
|
||||
const micromarkTokens = micromark.parse(content);
|
||||
const micromarkTokens = micromark.parse(
|
||||
content,
|
||||
{ "freezeTokens": customRulesPresent, "shimReferences": true }
|
||||
);
|
||||
// Hide the content of HTML comments from rules
|
||||
const preClearedContent = content;
|
||||
content = helpers.clearHtmlCommentText(content);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ module.exports = {
|
|||
if (autoLinks.length > 0) {
|
||||
// Re-parse with correct link/image reference definition handling
|
||||
const document = params.lines.join("\n");
|
||||
const tokens = parse(document, undefined, false);
|
||||
const tokens = parse(document);
|
||||
for (const token of literalAutolinks(tokens)) {
|
||||
const range = [
|
||||
token.startColumn,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue