Create tableLineBreaks.ts

pull/1140/head
Ganni 2024-12-02 22:20:53 -05:00 committed by GitHub
parent 3aaf05b16d
commit 5ba2b24060
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { visit } from "unist-util-visit";
/**
* Remark plugin to replace \n with <br> in table cells
*/
export function remarkTableLineBreaks() {
return (tree: any) => {
visit(tree, "tableCell", (node) => {
node.children.forEach((child: any) => {
if (child.type === "text") {
// Replace \n with <br> for text within table cells
child.value = child.value.replace(/\n/g, "<br>");
}
});
});
};
}