优化code组件的渲染

master
yutent 2023-05-04 15:24:48 +08:00
parent d47c6e5c13
commit 30a8738092
1 changed files with 3 additions and 1 deletions

View File

@ -194,7 +194,9 @@ class Code extends Component {
txt = colorMd(txt)
break
}
// 除代码高亮用的特殊标签 <c></c> 外, 其他的全部转义
// 避免渲染时混乱
txt = txt.replace(/<(\/?)(?!c)(\w+)([^>]*?)>/g, '&lt;$1$2$3>')
this.#code = txt.split('\n')
}