Public Access
feat: add LaTeX rendering utilities and Tex component
This commit is contained in:
1 parent
611277ee8a
commit
95de63bd98
2 files changed
+56
No files matched your search
@@ -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 }} />
|
||||
}
|
||||
Reference in new issue
Block a user