Files
cabrits-math/components/math/math-display.tsx
2026-03-01 18:50:29 -04:00

37 lines
673 B
TypeScript

"use client";
import katex from "katex";
interface MathDisplayProps {
math: string;
className?: string;
}
export function MathDisplay({ math, className }: MathDisplayProps) {
const html = katex.renderToString(math, {
displayMode: true,
throwOnError: false,
});
return (
<div
className={className}
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}
export function MathInline({ math, className }: MathDisplayProps) {
const html = katex.renderToString(math, {
displayMode: false,
throwOnError: false,
});
return (
<span
className={className}
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}