Files
outline/server/utils/turndown/emptyParagraph.ts
Tom Moor bf45e97641 chore: Enforce type import consistency (#10968)
* Update types

* fix circular dep

* type imports

* lint type imports and --fix
2025-12-19 23:07:02 -05:00

23 lines
580 B
TypeScript

import type TurndownService from "turndown";
/**
* A turndown plugin for converting paragraphs with only breaks to newlines.
*
* @param turndownService The TurndownService instance.
*/
export default function emptyParagraphs(turndownService: TurndownService) {
turndownService.addRule("emptyParagraphs", {
filter(node) {
return (
node.nodeName === "P" &&
node.children.length === 1 &&
node.textContent?.trim() === "" &&
node.children[0].nodeName === "BR"
);
},
replacement() {
return "\n\n\\\n";
},
});
}