Files
outline/server/utils/turndown/emptyParagraph.ts
Tom Moor d5bac6cbca fix: Paragraphs in table cells skipped in import
Port HTML importer rules from enterprise fork
2023-10-15 10:54:27 -04:00

22 lines
532 B
TypeScript

import 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.children[0].nodeName === "BR"
);
},
replacement() {
return "\n\n\\\n";
},
});
}