refactor: merge rehype plugins

This commit is contained in:
one 2025-04-15 06:01:23 +08:00 committed by 亢奋猫
parent c5161b9da4
commit 36aa13c4f1

View File

@ -36,8 +36,6 @@ const Markdown: FC<Props> = ({ message }) => {
const { t } = useTranslation()
const { renderInputMessageAsMarkdown, mathEngine } = useSettings()
const rehypeMath = useMemo(() => (mathEngine === 'KaTeX' ? rehypeKatex : rehypeMathjax), [mathEngine])
const messageContent = useMemo(() => {
const empty = isEmpty(message.content)
const paused = message.status === 'paused'
@ -46,8 +44,8 @@ const Markdown: FC<Props> = ({ message }) => {
}, [message, t])
const rehypePlugins = useMemo(() => {
return [rehypeRaw, [rehypeSanitize, sanitizeSchema], rehypeMath]
}, [rehypeMath])
return [rehypeRaw, [rehypeSanitize, sanitizeSchema], mathEngine === 'KaTeX' ? rehypeKatex : rehypeMathjax]
}, [mathEngine])
const components = useMemo(() => {
const baseComponents = {