From a0bf323ac98c6046afe09b405af9c1dabfe3ff4f Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Wed, 24 Sep 2025 09:23:31 +0800 Subject: [PATCH] feat(wip): Markdown --- client/ui/chat/ChatFragment.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index d50c1d4..41746ad 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -18,6 +18,15 @@ interface Args extends React.HTMLAttributes { onReturnButtonClicked?: () => void } +const markedInstance = new marked.Marked({ + renderer: { + heading({ tokens, depth: _depth }) { + const text = this.parser.parseInline(tokens); + return `${text}` + } + } +}) + export default function ChatFragment({ target, showReturnButton, onReturnButtonClicked, ...props }: Args) { const [messagesList, setMessagesList] = React.useState([] as Message[]) const [chatInfo, setChatInfo] = React.useState({ @@ -177,7 +186,7 @@ export default function ChatFragment({ target, showReturnButton, onReturnButtonC - {msg.text} + {markedInstance.parse(msg.text) as string} ) }