From a0e1ce654ee0381e10b7df30c42b6f5778869c8f Mon Sep 17 00:00:00 2001 From: Andrii Ieroshenko Date: Wed, 6 Mar 2024 10:22:57 -0800 Subject: [PATCH] use regex in TeX replace function to catch repeating occurences (#675) --- .../jupyter-ai/src/components/rendermime-markdown.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jupyter-ai/src/components/rendermime-markdown.tsx b/packages/jupyter-ai/src/components/rendermime-markdown.tsx index 63dfc9300..176c1cfa9 100644 --- a/packages/jupyter-ai/src/components/rendermime-markdown.tsx +++ b/packages/jupyter-ai/src/components/rendermime-markdown.tsx @@ -17,10 +17,10 @@ type RendermimeMarkdownProps = { */ function escapeLatexDelimiters(text: string) { return text - .replace('\\(', '\\\\(') - .replace('\\)', '\\\\)') - .replace('\\[', '\\\\[') - .replace('\\]', '\\\\]'); + .replace(/\\\(/g, '\\\\(') + .replace(/\\\)/g, '\\\\)') + .replace(/\\\[/g, '\\\\[') + .replace(/\\\]/g, '\\\\]'); } function RendermimeMarkdownBase(props: RendermimeMarkdownProps): JSX.Element {