Create tableLineBreaks.ts
parent
3aaf05b16d
commit
5ba2b24060
|
|
@ -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>");
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue