리팩토링: 코드 최적화
This commit is contained in:
@@ -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 }} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user