리팩토링: 코드 최적화

This commit is contained in:
2026-05-25 18:42:13 +09:00
parent 5ee33bf0d3
commit d56cada1ec
11 changed files with 215 additions and 175 deletions
+8 -2
View File
@@ -1,6 +1,6 @@
"use client";
import { BlockMath, InlineMath } from "react-katex";
import { renderToString } from "katex";
interface KatexRendererProps {
latex: string;
@@ -11,5 +11,11 @@ export default function KatexRenderer({
latex,
displayMode = false,
}: KatexRendererProps) {
return displayMode ? <BlockMath math={latex} /> : <InlineMath math={latex} />;
const html = renderToString(latex, {
displayMode,
throwOnError: false,
});
const Tag = displayMode ? "div" : "span";
return <Tag dangerouslySetInnerHTML={{ __html: html }} />;
}