mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +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,7 @@
|
|||
"use strict";
|
||||
|
||||
const { addError, getHtmlAttributeRe, nextLinesRe } = require("../helpers");
|
||||
const { filterByTypes, getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
|
||||
const { getHtmlTagInfo, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
const altRe = getHtmlAttributeRe("alt");
|
||||
|
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
// Process Markdown images
|
||||
const images = filterByTypesCached([ "image" ]);
|
||||
for (const image of images) {
|
||||
const labelTexts = filterByTypes(image.children, [ "labelText" ]);
|
||||
const labelTexts = getDescendantsByType(image, [ "label", "labelText" ]);
|
||||
if (labelTexts.some((labelText) => labelText.text.length === 0)) {
|
||||
const range = (image.startLine === image.endLine) ?
|
||||
[ image.startColumn, image.endColumn - image.startColumn ] :
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue