mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Reimplement MD028/no-blanks-blockquote using micromark tokens.
This commit is contained in:
parent
89eef68dbd
commit
f5b5773b50
4 changed files with 94 additions and 30 deletions
|
|
@ -295,6 +295,28 @@ function filterByTypes(tokens, types) {
|
|||
return filterByPredicate(tokens, predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all sibling token groups for a list of Micromark tokens.
|
||||
*
|
||||
* @param {Token[]} tokens Micromark tokens.
|
||||
* @returns {Token[][]} Sibling token groups.
|
||||
*/
|
||||
function getSiblingTokens(tokens) {
|
||||
const result = [];
|
||||
const queue = [ tokens ];
|
||||
// eslint-disable-next-line init-declarations
|
||||
let current;
|
||||
while ((current = queue.shift())) {
|
||||
result.push(current);
|
||||
for (const token of current) {
|
||||
if (token.children.length > 0) {
|
||||
queue.push(token.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the heading level of a Micromark heading tokan.
|
||||
*
|
||||
|
|
@ -419,6 +441,7 @@ module.exports = {
|
|||
getHeadingLevel,
|
||||
getHtmlTagInfo,
|
||||
getMicromarkEvents,
|
||||
getSiblingLists: getSiblingTokens,
|
||||
getTokenParentOfType,
|
||||
getTokenTextByType,
|
||||
inHtmlFlow,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue