feat: add LaTeX rendering utilities and Tex component

This commit is contained in:
LaurensBartelds committed 2026-04-21 21:29:26 +02:00
1 parent 611277ee8a
commit 95de63bd98
2 files changed
+56

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import { renderLatex } from '../utils/latex'
interface TexProps {
children?: string | null
tag?: keyof JSX.IntrinsicElements
className?: string
style?: React.CSSProperties
}
// Safe: renderLatex only produces KaTeX-controlled HTML + HTML-escaped plain text.
export default function Tex({ children, tag: Tag = 'span', className, style }: TexProps) {
const html = String(children ?? '').split('\n').map(renderLatex).join('<br/>')
return <Tag className={className} style={style} dangerouslySetInnerHTML={{ __html: html }} />
}