Skip to content

Commit

Permalink
Merge pull request #14 from asadgulxar/fix-initial-latex-issue
Browse files Browse the repository at this point in the history
Handle Double Backslashes in initialLatex prop.
  • Loading branch information
krirkrirk authored Jul 9, 2024
2 parents d496d8b + 97b177c commit b821336
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mathInput/mathInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const vanillaKeys = [
"/",
];

const convertDoubleBackslashes = (str: string) => {
return str.replace(/\\\\/g, "\\");
};

export const MathInput = ({
numericToolbarKeys,
numericToolbarTabs,
Expand Down Expand Up @@ -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]);

Expand Down

0 comments on commit b821336

Please sign in to comment.