Add mhchem extension support for chemistry formulas in ChatMessage
(cherry picked from commit aeaa0b32f9)
This commit is contained in:
parent
bd93f13012
commit
411290a013
1 changed files with 5 additions and 1 deletions
|
|
@ -70,10 +70,14 @@ export const ChatMessage = ({ message }: { message: MessageWithError }) => { //
|
|||
? message.content
|
||||
: (displayContent !== undefined ? displayContent : (message.content || ''))
|
||||
|
||||
// Load KaTeX dynamically
|
||||
// Load KaTeX dynamically with mhchem extension for chemistry formulas
|
||||
useEffect(() => {
|
||||
const loadKaTeX = async () => {
|
||||
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');
|
||||
setKatexPlugin(() => rehypeKatex);
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue