mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-09 10:15:26 +00:00
Create tableLineBreaks.ts
This commit is contained in:
17
src/components/markdown/plugins/tableLineBreaks.ts
Normal file
17
src/components/markdown/plugins/tableLineBreaks.ts
Normal 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>");
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user