From 97b177c348f6ea04e4131663137779742811e775 Mon Sep 17 00:00:00 2001 From: asadgulxar Date: Sat, 6 Jul 2024 17:48:15 +0500 Subject: [PATCH] fix initial latext issue --- src/mathInput/mathInput.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mathInput/mathInput.tsx b/src/mathInput/mathInput.tsx index fffd090..c547d7d 100644 --- a/src/mathInput/mathInput.tsx +++ b/src/mathInput/mathInput.tsx @@ -61,6 +61,10 @@ const vanillaKeys = [ "/", ]; +const convertDoubleBackslashes = (str: string) => { + return str.replace(/\\\\/g, "\\"); +}; + export const MathInput = ({ numericToolbarKeys, numericToolbarTabs, @@ -195,7 +199,7 @@ export const MathInput = ({ useEffect(() => { if (!loaded || !initialLatex) return; if (wasInitialLatexSet.current) return; - mathfield.current.latex(initialLatex); + mathfield.current.latex(convertDoubleBackslashes(initialLatex)); wasInitialLatexSet.current = true; }, [loaded, initialLatex]);