fix: Remove empty top-level list items in imported HTML content

This commit is contained in:
Tom Moor
2023-05-25 21:34:26 -04:00
parent e9ec31e5b8
commit be3bcebf6b
5 changed files with 39 additions and 15 deletions

View File

@@ -10,16 +10,14 @@ export default function confluenceTaskList(turndownService: TurndownService) {
filter(node) {
return (
node.nodeName === "LI" &&
node.parentNode?.nodeName === "UL" &&
// @ts-expect-error className exists
node.parentNode?.className.includes("inline-task-list")
node.parentElement?.nodeName === "UL" &&
node.parentElement?.className.includes("inline-task-list")
);
},
replacement(content, node) {
return (
// @ts-expect-error className exists
(node.className === "checked" ? "- [x]" : "- [ ]") + ` ${content} \n`
);
return "className" in node
? (node.className === "checked" ? "- [x]" : "- [ ]") + ` ${content} \n`
: content;
},
});
}