Reimplement MD032/blanks-around-lists using micromark tokens, add newly-detected violations to test snapshot.

This commit is contained in:
David Anson 2023-07-18 22:33:57 -07:00
parent 900fb349ee
commit 9646590496
5 changed files with 143 additions and 51 deletions

View file

@ -145,6 +145,23 @@ function filterByTypes(tokens, allowed) {
);
}
/**
* Returns a list of all nested child tokens.
*
* @param {Token} parent Micromark token.
* @returns {Token[]} Flattened children.
*/
function flattenedChildren(parent) {
const result = [];
const pending = [ ...parent.children ];
let token = null;
while ((token = pending.shift())) {
result.push(token);
pending.unshift(...token.children);
}
return result;
}
/**
* Gets information about the tag in an HTML token.
*
@ -219,6 +236,7 @@ module.exports = {
"parse": micromarkParse,
filterByPredicate,
filterByTypes,
flattenedChildren,
getHtmlTagInfo,
getMicromarkEvents,
getTokenTextByType,