From ebce006974a815de9475d44b71a7f9820d6a00b7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 20 Jul 2024 10:58:29 +0200 Subject: [PATCH] refac: latex handling --- src/lib/components/chat/Messages/ResponseMessage.svelte | 1 + src/lib/utils/index.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index eded26fb3..c1224b5e1 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -178,6 +178,7 @@ { left: '\\pu{', right: '}', display: false }, { left: '\\ce{', right: '}', display: false }, { left: '\\(', right: '\\)', display: false }, + { left: '( ', right: ' )', display: false }, { left: '\\[', right: '\\]', display: false }, { left: '[ ', right: ' ]', display: false }, { left: '\\begin{equation}', right: '\\end{equation}', display: true }, diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index d80fcc799..196085dbd 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -7,6 +7,9 @@ import { WEBUI_BASE_URL } from '$lib/constants'; ////////////////////////// export const sanitizeResponseContent = (content: string) => { + // replace single backslash with double backslash + content = content.replace(/\\/g, '\\\\'); + // First, temporarily replace valid