Repository Public
1import { latexToHtml } from "./latex";2import { latexToUnicode } from "./mathtext";34/**5 * A formula. KaTeX's own output (trust: false) is the only HTML the renderer ever injects; if KaTeX rejects the6 * formula, a readable Unicode form is shown as plain text (never the raw source).7 */8export function MathView({ latex, display = false }: { latex: string; display?: boolean }) {9 const html = latexToHtml(latex, display);10 if (!html) return <span className={display ? "sh-math-fallback sh-math--display" : "sh-math-fallback"}>{latexToUnicode(latex)}</span>;11 return <span className={display ? "sh-math sh-math--display" : "sh-math"} dangerouslySetInnerHTML={{ __html: html }} />;12}13