Feature: 页面内Markdown渲染 & 规格参数表格
This commit is contained in:
15
app/utils/markdown.ts
Normal file
15
app/utils/markdown.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import MarkdownIt from 'markdown-it';
|
||||
import DOMPurify from 'dompurify';
|
||||
|
||||
const md = new MarkdownIt({
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
breaks: true,
|
||||
})
|
||||
|
||||
export function renderMarkdown(content: string): string {
|
||||
const dirtyHtml = md.render(content);
|
||||
return DOMPurify.sanitize(dirtyHtml)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user