mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-06 12:00:44 +08:00
markdown 调试信息中的错误日志删除
This commit is contained in:
@@ -268,23 +268,21 @@ export function stripMarkdownLength(text, length) {
|
|||||||
|
|
||||||
// 朴素文本带贴吧表情
|
// 朴素文本带贴吧表情
|
||||||
export function stripMarkdownWithTiebaMoji(text, length){
|
export function stripMarkdownWithTiebaMoji(text, length){
|
||||||
console.error(text)
|
|
||||||
if (!text) return ''
|
if (!text) return ''
|
||||||
|
|
||||||
// Markdown 转成纯文本
|
// Markdown 转成纯文本
|
||||||
const plain = stripMarkdown(text)
|
const plain = stripMarkdown(text)
|
||||||
console.error(plain)
|
// 替换 :tieba123: 为 <img>
|
||||||
// 替换 :tieba123: 为 <img>
|
const withEmoji = plain.replace(/:tieba(\d+):/g, (match, num) => {
|
||||||
const withEmoji = plain.replace(/:tieba(\d+):/g, (match, num) => {
|
const key = `tieba${num}`
|
||||||
const key = `tieba${num}`
|
const file = tiebaEmoji[key]
|
||||||
const file = tiebaEmoji[key]
|
return file
|
||||||
return file
|
? `<img loading="lazy" class="emoji" src="${file}" alt="${key}">`
|
||||||
? `<img loading="lazy" class="emoji" src="${file}" alt="${key}">`
|
: match // 没有匹配到图片则保留原样
|
||||||
: match // 没有匹配到图片则保留原样
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// 截断纯文本长度(防止撑太长)
|
// 截断纯文本长度(防止撑太长)
|
||||||
const truncated = withEmoji.length > length ? withEmoji.slice(0, length) + '...' : withEmoji
|
const truncated = withEmoji.length > length ? withEmoji.slice(0, length) + '...' : withEmoji
|
||||||
return truncated
|
return truncated
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user