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
|
? 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