mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-21 16:30:12 +01:00
Refactor various code to do shallow/constrained search instead of deep search for better performance, make cache key for filterByTypesCached unique.
This commit is contained in:
parent
2fa7730a6b
commit
d22c1f19ef
12 changed files with 171 additions and 220 deletions
|
|
@ -3,7 +3,6 @@
|
|||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
||||
|
|
@ -17,10 +16,7 @@ module.exports = {
|
|||
"parser": "micromark",
|
||||
"function": function MD014(params, onError) {
|
||||
for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
|
||||
const codeFlowValues = filterByTypes(
|
||||
codeBlock.children,
|
||||
[ "codeFlowValue" ]
|
||||
);
|
||||
const codeFlowValues = codeBlock.children.filter((child) => child.type === "codeFlowValue");
|
||||
const dollarMatches = codeFlowValues
|
||||
.map((codeFlowValue) => ({
|
||||
"result": codeFlowValue.text.match(dollarCommandRe),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue