Add mhchem extension support for chemistry formulas in ChatMessage
This commit is contained in:
parent
0aa77fdbcb
commit
aeaa0b32f9
1 changed files with 5 additions and 1 deletions
|
|
@ -76,10 +76,14 @@ export const ChatMessage = ({
|
||||||
? message.content
|
? message.content
|
||||||
: (displayContent !== undefined ? displayContent : (message.content || ''))
|
: (displayContent !== undefined ? displayContent : (message.content || ''))
|
||||||
|
|
||||||
// Load KaTeX dynamically
|
// Load KaTeX dynamically with mhchem extension for chemistry formulas
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadKaTeX = async () => {
|
const loadKaTeX = async () => {
|
||||||
try {
|
try {
|
||||||
|
// First load mhchem extension (must be loaded before rehype-katex)
|
||||||
|
// This enables \ce and \pu commands for chemistry formulas
|
||||||
|
await import('katex/contrib/mhchem');
|
||||||
|
// Then load rehype-katex
|
||||||
const { default: rehypeKatex } = await import('rehype-katex');
|
const { default: rehypeKatex } = await import('rehype-katex');
|
||||||
setKatexPlugin(() => rehypeKatex);
|
setKatexPlugin(() => rehypeKatex);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue