Ver Fonte

refac: latex handling

Timothy J. Baek há 9 meses atrás
pai
commit
ebce006974

+ 1 - 0
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 },

+ 3 - 0
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 <video> tags with a placeholder
 	const videoTagRegex = /<video\s+src="([^"]+)"\s+controls><\/video>/gi;
 	const placeholders: string[] = [];