diff --git a/src/components/markdown/plugins/tableLineBreaks.ts b/src/components/markdown/plugins/tableLineBreaks.ts new file mode 100644 index 00000000..24361afe --- /dev/null +++ b/src/components/markdown/plugins/tableLineBreaks.ts @@ -0,0 +1,17 @@ +import { visit } from "unist-util-visit"; + +/** + * Remark plugin to replace \n with
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
for text within table cells + child.value = child.value.replace(/\n/g, "
"); + } + }); + }); + }; +}