fix: 回复表情通知为空的问题 #735

This commit is contained in:
Tim
2025-08-27 19:44:27 +08:00
parent 2b3c60f9a7
commit 3d51f29be7

View File

@@ -92,7 +92,7 @@ function linkPlugin(md) {
/** @section MarkdownIt 实例:开启 HTML但配合强净化 */
const md = new MarkdownIt({
html: true, // ⭐ 允许行内 HTML为 <video> 服务)
html: true,
linkify: true,
breaks: true,
highlight: (str, lang) => {
@@ -106,11 +106,16 @@ const md = new MarkdownIt({
.trim()
.split('\n')
.map(() => `<div class="line-number"></div>`)
// 保留你原有的 CodeBlock + 复制按钮 + 行号结构
return `<pre class="code-block"><button class="copy-code-btn">Copy</button><div class="line-numbers">${lineNumbers.join('')}</div><code class="hljs language-${lang || ''}">${code.trim()}</code></pre>`
},
})
const md2TextRender = new MarkdownIt({
html: true,
linkify: true,
breaks: true,
})
md.use(mentionPlugin)
md.use(tiebaEmojiPlugin)
md.use(linkPlugin)
@@ -221,7 +226,7 @@ export function handleMarkdownClick(e) {
/** @section 纯文本提取(保持你原有“统一正则法”) */
export function stripMarkdown(text) {
const html = md.render(text || '')
const html = md2TextRender.render(text || '')
let plainText = html.replace(/<[^>]+>/g, '')
plainText = plainText
.replace(/\r\n/g, '\n')