This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
old
宇天 2021-05-18 15:25:45 +08:00
parent 0e990eb657
commit c2243e04e2
2 changed files with 7 additions and 6 deletions

View File

@ -10,9 +10,11 @@ const TAG_END_EXP = /<\/([\w\-]+)>/g
const TAG_ATTR_EXP = /[@a-zA-Z\-.]+=(["'])[^"]+\1|[@a-zA-Z\-.]+=[a-zA-Z0-9]+|[@a-zA-Z\-.]+/g
const TAG_CM_EXP = /<!--([\w\W]*?)-->/g
const SCRIPT_TAG = /(<script[^>]*?>)([\w\W]*?)(<\/script>)/g
const KEYWOWRD1 = /\b(var|const|let|function|for|switch|with|if|else|export|import|async|await|break|continue|return|class|try|catch|throw|new|while|this|super|default|case|debugger|delete|do|goto|in|public|private|protected|package|typeof)\b/g
const KEYWOWRD1 = /\b(var|const|let|function|for|switch|with|if|else|export|import|async|await|break|continue|return|class|try|catch|throw|new|while|this|super|default|case|debugger|delete|do|goto|in|public|private|protected|package|typeof|void)\b/g
const KEYWOWRD2 = /\b\s(=|-|\+|\/|\*|<|>|%)\s\b/g
const KEYWOWRD3 = /(\+\=|-=|\/=|\*=|--|\+\+|==|===)/g
const BUILDIN1 = /\b(null|undefined|true|false|NaN|Infinity)\b/g
const BUILDIN2 = /\b(Object|String|Array|Boolean|Number|Function|class)\b/g
const STR = /(['"`])(.*?)\1/g
const NUM = /\b(\d+)\b/g
const FN = /([\.\s])([a-zA-Z$][\da-zA-Z_]*)(\(.*?\))/g
@ -40,6 +42,8 @@ function parseJs(code) {
.replace(KEYWOWRD1, '[key]$1[/key]')
.replace(KEYWOWRD2, '[key] $1 [/key]')
.replace(KEYWOWRD3, '[key]$1[/key]')
.replace(BUILDIN1, '[num]<em>$1</em>[/num]')
.replace(BUILDIN2, '[type]<strong><em>$1</em></strong>[/type]')
.replace(NUM, '[num]$1[/num]')
.replace(STR, (m, q, str) => {
return `[str]${q}${str.replace(/\[\/?num\]/g, '')}${q}[/str]`
@ -57,7 +61,7 @@ function rebuild(code) {
.replace(/\[(\/?)num\]/g, (m, s) => (s ? '</i>' : '<i class="pp">'))
.replace(/\[(\/?)fn\]/g, (m, s) => (s ? '</i>' : '<i class="b">'))
.replace(/\[(\/?)cm\]/g, (m, s) => (s ? '</i>' : '<i class="gr">'))
.replace(/\[(\/?)bold\]/g, (m, s) => (s ? '</i>' : '<i class="bold">'))
.replace(/\[(\/?)type\]/g, (m, s) => (s ? '</i>' : '<i class="o">'))
.replace(/\[(\/?)link\]/g, (m, s) => (s ? '</i>' : '<i class="link">'))
}

View File

@ -118,7 +118,7 @@
color: var(--color-blue-1);
}
.g {
color: var(--color-green-1);
color: var(--color-green-2);
}
.gr {
color: var(--color-grey-2);
@ -129,9 +129,6 @@
.pp {
color: #6a1ea8;
}
.bold {
font-weight: bold;
}
.link {
font-style: italic;
text-decoration: underline;