Update MD032/blanks-around-lists to ignore (end-appended) undefined reference tokens when determining the last line of a list (fixes #1453).

This commit is contained in:
David Anson 2024-12-16 20:54:37 -08:00
parent 599b687849
commit 8ad4698536
5 changed files with 24 additions and 10 deletions

View file

@ -45,13 +45,14 @@ export default {
}
// Find the "visual" end of the list
const flattenedChildren = filterByPredicate(
list.children,
(token) => !nonContentTokens.has(token.type),
(token) => nonContentTokens.has(token.type) ? [] : token.children
);
let endLine = list.endLine;
const flattenedChildren = filterByPredicate(list.children);
for (const child of flattenedChildren.reverse()) {
if (!nonContentTokens.has(child.type)) {
endLine = child.endLine;
break;
}
if (flattenedChildren.length > 0) {
endLine = flattenedChildren[flattenedChildren.length - 1].endLine;
}
// Look for a blank line below the list