Create tableLineBreaks.ts

This commit is contained in:
Ganni
2024-12-02 22:20:53 -05:00
committed by GitHub
parent 3aaf05b16d
commit 5ba2b24060

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>");
}
});
});
};
}