Skip to content

Commit

Permalink
Fix katex render error
Browse files Browse the repository at this point in the history
  • Loading branch information
faishol01 committed Oct 7, 2023
1 parent 62807ed commit 3e26895
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/module/dashboard/docs/DocsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ export default function DocsPage() {
// Replace $$ expressions with KaTeX rendering
const htmlWithMath = docsMenu[menuActive].content;
const renderedHtml = htmlWithMath.replace(
/\$\$(.*?)\$\$/g,
/(?<!\\)\$\$(.*?)\$\$/g,
(_, mathExpression) => {
return katex.renderToString(mathExpression);
}
);

// Replace $ expressions with KaTeX rendering
const finalRenderedHtml = renderedHtml.replace(
/\$(.*?)\$/g,
const secondRenderedHtml = renderedHtml.replace(
/(?<!\\)\$(.*?)\$/g,
(_, mathExpression) => {
return katex.renderToString(mathExpression, { displayMode: false });
}
);

const finalRenderedHtml = secondRenderedHtml.replaceAll("\\$", "$");
setDocsContent(finalRenderedHtml);
}, [menuActive, docsMenu]);

Expand Down

0 comments on commit 3e26895

Please sign in to comment.