Skip to content

Commit

Permalink
Merge pull request #16 from CTF-Compfest-15/fix-katex-render
Browse files Browse the repository at this point in the history
Fix katex render error
  • Loading branch information
rorre authored Oct 7, 2023
2 parents 62807ed + 3e26895 commit 1c6b46e
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 1c6b46e

Please sign in to comment.