From 3e26895f7259c9e0b05a9b9077478da20b3a58ed Mon Sep 17 00:00:00 2001 From: Muhammad Faishol Amirul Mukminin Date: Sat, 7 Oct 2023 11:28:01 +0700 Subject: [PATCH] Fix katex render error --- src/components/module/dashboard/docs/DocsPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/module/dashboard/docs/DocsPage.tsx b/src/components/module/dashboard/docs/DocsPage.tsx index 36d9371..541ac9a 100644 --- a/src/components/module/dashboard/docs/DocsPage.tsx +++ b/src/components/module/dashboard/docs/DocsPage.tsx @@ -44,20 +44,20 @@ export default function DocsPage() { // Replace $$ expressions with KaTeX rendering const htmlWithMath = docsMenu[menuActive].content; const renderedHtml = htmlWithMath.replace( - /\$\$(.*?)\$\$/g, + /(? { return katex.renderToString(mathExpression); } ); // Replace $ expressions with KaTeX rendering - const finalRenderedHtml = renderedHtml.replace( - /\$(.*?)\$/g, + const secondRenderedHtml = renderedHtml.replace( + /(? { return katex.renderToString(mathExpression, { displayMode: false }); } ); - + const finalRenderedHtml = secondRenderedHtml.replaceAll("\\$", "$"); setDocsContent(finalRenderedHtml); }, [menuActive, docsMenu]);