Open zhoubin-me opened 6 months ago
Please can you do a bit more research and tell us how to do this. E.g. goes the library we use now support this?
@samuelcolvin basially you need to update
https://github.com/pydantic/FastUI/blob/main/src/npm-fastui/src/components/MarkdownLazy.tsx
by using react-markdown's plugins like
import React from 'react'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'
import rehypeKatex from 'rehype-katex'
import remarkMath from 'remark-math'
import 'katex/dist/katex.min.css' // `rehype-katex` does not import the CSS for you
const markdown = `The lift coefficient ($C_L$) is a dimensionless coefficient.`
createRoot(document.body).render(
<Markdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>
{markdown}
</Markdown>
)
PR welcome to try this. I've no idea how much it increase the bundle size. If it has a big affect, we might need a different lazy module for markdown with math.
As titled