From aac495fa584c289c59f1bf0b1890a6c9554e7c96 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 28 Jan 2023 13:01:02 -0500 Subject: [PATCH] fix: Pipe characters in code marks within tables cause the table layout to break closes #4783 --- shared/editor/lib/markdown/serializer.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shared/editor/lib/markdown/serializer.ts b/shared/editor/lib/markdown/serializer.ts index 5c83c78ff..1f8b46dc2 100644 --- a/shared/editor/lib/markdown/serializer.ts +++ b/shared/editor/lib/markdown/serializer.ts @@ -296,12 +296,16 @@ export class MarkdownSerializerState { this.text(this.markString(add, true, parent, index), false); } - // Render the node. Special case code marks, since their content - // may not be escaped. + // Render the node. Special case code marks, since their content is not + // escaped, apart from pipes in tables. if (noEsc && node.isText) { + const text = this.inTable + ? node.text.replace(/\|/gi, "\\$&") + : node.text; + this.text( this.markString(inner, true, parent, index) + - node.text + + text + this.markString(inner, false, parent, index + 1), false );