mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Reimplement MD032/blanks-around-lists using micromark tokens, add newly-detected violations to test snapshot.
This commit is contained in:
parent
900fb349ee
commit
9646590496
5 changed files with 143 additions and 51 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue