Merge branch 'master' of ssh://github.com/bd-js/wcui
commit
98bc68a617
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@bd/ui",
|
||||
"version": "0.1.11",
|
||||
"version": "0.1.12",
|
||||
"description": "",
|
||||
"files": [
|
||||
"dist/*"
|
||||
|
|
|
@ -170,6 +170,7 @@ class Code extends Component {
|
|||
|
||||
setCode(txt, a) {
|
||||
let lang = this.lang
|
||||
let skip = false
|
||||
|
||||
switch (lang) {
|
||||
case 'js':
|
||||
|
@ -180,12 +181,14 @@ class Code extends Component {
|
|||
break
|
||||
|
||||
case 'html':
|
||||
case 'xml':
|
||||
txt = colorHtml(txt)
|
||||
break
|
||||
|
||||
case 'css':
|
||||
case 'scss':
|
||||
case 'less':
|
||||
skip = true
|
||||
txt = colorCss(txt)
|
||||
break
|
||||
|
||||
|
@ -194,6 +197,16 @@ class Code extends Component {
|
|||
txt = colorMd(txt)
|
||||
break
|
||||
}
|
||||
// 除代码高亮用的特殊标签 <c></c> 外, 其他的全部转义
|
||||
// 避免渲染时混乱
|
||||
|
||||
if (skip === false) {
|
||||
txt = txt
|
||||
.replace(/<(\/?)(?!c)(\w+)([^>]*?)>/g, '<$1$2$3>')
|
||||
.replace(/<!(doctype)([^>]*?)>/gi, '<$1$2>')
|
||||
.replace(/<\?([^\?>]*?)\?>/g, '<?$1?>')
|
||||
.replace(/<\!\-\-([^>]*?)\-\->/g, '<!--$1-->')
|
||||
}
|
||||
|
||||
this.#code = txt.split('\n')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue