From 6d8c8e678e85a7c31d7671f738d214114354b786 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Mon, 14 Aug 2023 09:15:30 +0100 Subject: [PATCH] Merge pull request #14226 from overleaf/mj-table-gen-reinstate-regex [visual] Reinstate regex for escaping ampersands GitOrigin-RevId: 61f561fdee0ff9393fb20eb0a0485ce7fbf75bea --- .../source-editor/components/table-generator/cell.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/source-editor/components/table-generator/cell.tsx b/services/web/frontend/js/features/source-editor/components/table-generator/cell.tsx index d1571c896b..7991b7f057 100644 --- a/services/web/frontend/js/features/source-editor/components/table-generator/cell.tsx +++ b/services/web/frontend/js/features/source-editor/components/table-generator/cell.tsx @@ -62,7 +62,11 @@ export const Cell: FC<{ const filterInput = (input: string) => { // TODO: Are there situations where we don't want to filter the input? - return input.replaceAll('\\\\', '') + return input + .replaceAll(/(^&|[^\\]&)/g, match => + match.length === 1 ? '\\&' : `${match[0]}\\&` + ) + .replaceAll('\\\\', '') } const isFocused =