fix: HTML 渲染异常 (#152)

* fix: 修复 `API` 版本 HTML 会被渲染的问题[#146]

* chore: version 2.8.1
This commit is contained in:
Redon authored and GitHub committed 2023-02-27 19:25:15 +08:00
1 parent 2c509c329f
commit 21fb4f817c
8 files changed
+73 -17

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
// 转义 HTML 字符
export function encodeHTML(source: string) {
return source
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
}
// 判断是否为代码块
export function includeCode(text: string | null | undefined) {
const regexp = /^(?:\s{4}|\t).+/gm
return !!(text?.includes(' = ') || text?.match(regexp))
}
-6
View File
@@ -1,6 +0,0 @@
function includeCode(text: string | null | undefined) {
const regexp = /^(?:\s{4}|\t).+/gm
return !!(text?.includes(' = ') || text?.match(regexp))
}
export default includeCode