diff --git a/src/code/colorful.js b/src/code/colorful.js index f60bb95..793f78e 100644 --- a/src/code/colorful.js +++ b/src/code/colorful.js @@ -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 = //g const SCRIPT_TAG = /(]*?>)([\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]$1[/num]') + .replace(BUILDIN2, '[type]$1[/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 ? '' : '')) .replace(/\[(\/?)fn\]/g, (m, s) => (s ? '' : '')) .replace(/\[(\/?)cm\]/g, (m, s) => (s ? '' : '')) - .replace(/\[(\/?)bold\]/g, (m, s) => (s ? '' : '')) + .replace(/\[(\/?)type\]/g, (m, s) => (s ? '' : '')) .replace(/\[(\/?)link\]/g, (m, s) => (s ? '' : '')) } diff --git a/src/code/index.wc b/src/code/index.wc index 8cc8bab..2a164bb 100644 --- a/src/code/index.wc +++ b/src/code/index.wc @@ -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;