fix: Paragraphs in table cells skipped in import

Port HTML importer rules from enterprise fork
This commit is contained in:
Tom Moor
2023-10-15 10:51:50 -04:00
parent 00ee8729ec
commit d5bac6cbca
7 changed files with 86 additions and 85 deletions

View File

@@ -0,0 +1,21 @@
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";
},
});
}