import React, { useMemo } from "react"; import katex from "katex"; interface MathFormulaProps { math: string; block?: boolean; className?: string; } export const MathFormula: React.FC = ({ math, block = false, className = "", }) => { const renderedHtml = useMemo(() => { try { return katex.renderToString(math, { throwOnError: false, displayMode: block, }); } catch { return math; } }, [math, block]); if (block) { return (
); } return ( ); };