fix: Paragraphs in table cells skipped in import
Port HTML importer rules from enterprise fork
This commit is contained in:
22
server/utils/turndown/emptyLists.ts
Normal file
22
server/utils/turndown/emptyLists.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import TurndownService from "turndown";
|
||||
|
||||
/**
|
||||
* A turndown plugin for unwrapping top-level empty list items.
|
||||
*
|
||||
* @param turndownService The TurndownService instance.
|
||||
*/
|
||||
export default function emptyLists(turndownService: TurndownService) {
|
||||
turndownService.addRule("empty-lists", {
|
||||
filter(node) {
|
||||
return (
|
||||
node.nodeName === "LI" &&
|
||||
node.childNodes.length === 1 &&
|
||||
(node.firstChild?.nodeName === "OL" ||
|
||||
node.firstChild?.nodeName === "UL")
|
||||
);
|
||||
},
|
||||
replacement(content) {
|
||||
return content;
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user