From 9c78c80bc8adbee943684ec3cf4c947db94d4595 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 12 Jan 2023 17:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E8=A1=8C=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E6=96=87=E6=9C=AC=E7=9A=84=E6=B8=B2=E6=9F=93;?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=87=BD=E6=95=B0=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/code/colorful.js | 19 +++++++++++++++---- src/code/index.wc | 1 - 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/code/colorful.js b/src/code/colorful.js index 0c815be..05ef57f 100644 --- a/src/code/colorful.js +++ b/src/code/colorful.js @@ -20,8 +20,9 @@ const BUILDIN2 = /\b(Object|String|Array|Boolean|Number|Function|class|Promise|Map|Set|WeakMap|WeakSet|URL)\b/g const STR = /(['"`])(.*?)(?$1[/key]') .replace(KEYWOWRD2, ' [key]$1[/key] ') .replace(KEYWOWRD3, '[key]$1[/key]') .replace(BUILDIN1, '[num]$1[/num]') @@ -67,7 +68,7 @@ function parseJs(code) { return `[cm]${pun}[/cm][str]${str}[/str][cm]${pun}[/cm]` }) - .replace(CM, (m, str) => { + .replace(CM1, (m, str) => { str = str .replace(/\[(\w+)\](.*?)\[\/\1\]/g, '$2') .replace(/&/g, '&') @@ -75,6 +76,16 @@ function parseJs(code) { .replace(/>/g, '>') return `[cm]${str}[/cm]` }) + .replace(CM2, (m, str) => { + str = str + .replace(/\[(\w+)\](.*?)\[\/\1\]/g, '$2') + .replace(/&/g, '&') + .replace(//g, '>') + + str = `/*${str}*/`.split('\n').map(s => `[cm]${s}[/cm]`) + return str.join('\n') + }) } function rebuild(code) { diff --git a/src/code/index.wc b/src/code/index.wc index c37953c..fb47a62 100644 --- a/src/code/index.wc +++ b/src/code/index.wc @@ -80,7 +80,6 @@ .scroll { overflow: hidden; flex: 1; - padding: 5px 0 0; line-height: 20px; font-size: 14px; color: var(--color-dark-1);