mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Refactor to remove micromark helper getTokenTextByType, update getDescendantsByType to allow sub-arrays.
This commit is contained in:
parent
0f210d5c1a
commit
8cbbed8e79
7 changed files with 44 additions and 94 deletions
|
|
@ -451,15 +451,10 @@ function getReferenceLinkImageData(tokens) {
|
|||
if (definitions.has(reference)) {
|
||||
duplicateDefinitions.push([ reference, token.startLine - 1 ]);
|
||||
} else {
|
||||
let destinationString = null;
|
||||
const parent =
|
||||
micromark.getTokenParentOfType(token, [ "definition" ]);
|
||||
if (parent) {
|
||||
destinationString = micromark.getTokenTextByType(
|
||||
micromark.filterByPredicate(parent.children),
|
||||
"definitionDestinationString"
|
||||
);
|
||||
}
|
||||
const destinationString = parent &&
|
||||
micromark.getDescendantsByType(parent, [ "definitionDestination", "definitionDestinationRaw", "definitionDestinationString" ])[0]?.text;
|
||||
definitions.set(
|
||||
reference,
|
||||
[ token.startLine - 1, destinationString ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue