fix: Paragraphs in table cells skipped in import
Port HTML importer rules from enterprise fork
This commit is contained in:
21
server/utils/turndown/emptyParagraph.ts
Normal file
21
server/utils/turndown/emptyParagraph.ts
Normal 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";
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user