Refactor MD032/blanks-around-lists to remove redundant micromark flattenedChildren function.

This commit is contained in:
David Anson 2023-08-29 22:38:00 -07:00
parent 84e664e86e
commit 96a36de713
3 changed files with 11 additions and 42 deletions

View file

@ -4,8 +4,7 @@
const { addErrorContext, blockquotePrefixRe, isBlankLine } =
require("../helpers");
const { filterByPredicate, flattenedChildren } =
require("../helpers/micromark.cjs");
const { filterByPredicate } = require("../helpers/micromark.cjs");
const nonContentTokens = new Set([
"blockQuoteMarker",
@ -59,7 +58,11 @@ module.exports = {
// Find the "visual" end of the list
let endLine = list.endLine;
for (const child of flattenedChildren(list).reverse()) {
const flattenedChildren = filterByPredicate(
list.children,
() => true
);
for (const child of flattenedChildren.reverse()) {
if (!nonContentTokens.has(child.type)) {
endLine = child.endLine;
break;