fix(frontend): 完善Markdown与Chat事件渲染
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import DOMPurify from 'dompurify'
|
||||
import { marked } from 'marked'
|
||||
|
||||
marked.setOptions({ gfm: true, breaks: true })
|
||||
|
||||
export function renderMarkdown(source: string): string {
|
||||
const html = marked.parse(source, { async: false }) as string
|
||||
return DOMPurify.sanitize(html, { USE_PROFILES: { html: true } })
|
||||
}
|
||||
Reference in New Issue
Block a user