feat: add LaTeX extension support via Marked (#2766)
This commit is contained in:
parent
54af9f9e43
commit
7725347cdb
@ -23,10 +23,12 @@
|
|||||||
"framer-motion": "^10.16.4",
|
"framer-motion": "^10.16.4",
|
||||||
"highlight.js": "^11.9.0",
|
"highlight.js": "^11.9.0",
|
||||||
"jotai": "^2.6.0",
|
"jotai": "^2.6.0",
|
||||||
|
"katex": "^0.16.10",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lucide-react": "^0.291.0",
|
"lucide-react": "^0.291.0",
|
||||||
"marked": "^9.1.2",
|
"marked": "^9.1.2",
|
||||||
"marked-highlight": "^2.0.6",
|
"marked-highlight": "^2.0.6",
|
||||||
|
"marked-katex-extension": "^5.0.1",
|
||||||
"next": "14.0.1",
|
"next": "14.0.1",
|
||||||
"next-themes": "^0.2.1",
|
"next-themes": "^0.2.1",
|
||||||
"postcss": "8.4.31",
|
"postcss": "8.4.31",
|
||||||
|
|||||||
@ -19,8 +19,8 @@ import hljs from 'highlight.js'
|
|||||||
import { useAtomValue } from 'jotai'
|
import { useAtomValue } from 'jotai'
|
||||||
import { FolderOpenIcon } from 'lucide-react'
|
import { FolderOpenIcon } from 'lucide-react'
|
||||||
import { Marked, Renderer } from 'marked'
|
import { Marked, Renderer } from 'marked'
|
||||||
|
|
||||||
import { markedHighlight } from 'marked-highlight'
|
import { markedHighlight } from 'marked-highlight'
|
||||||
|
import markedKatex from 'marked-katex-extension'
|
||||||
|
|
||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
@ -100,6 +100,8 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
marked.use(markedKatex({ throwOnError: false }))
|
||||||
|
|
||||||
const { onViewFile, onViewFileContainer } = usePath()
|
const { onViewFile, onViewFileContainer } = usePath()
|
||||||
const parsedText = marked.parse(text)
|
const parsedText = marked.parse(text)
|
||||||
const [tokenCount, setTokenCount] = useState(0)
|
const [tokenCount, setTokenCount] = useState(0)
|
||||||
@ -297,7 +299,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
|
|||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
'message flex flex-grow flex-col gap-y-2 text-[15px] font-normal leading-relaxed',
|
'message max-width-[100%] flex flex-grow flex-col gap-y-2 overflow-auto text-[15px] font-normal leading-relaxed',
|
||||||
isUser
|
isUser
|
||||||
? 'whitespace-pre-wrap break-words'
|
? 'whitespace-pre-wrap break-words'
|
||||||
: 'rounded-xl bg-secondary p-4'
|
: 'rounded-xl bg-secondary p-4'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user