From 3d29009977253571a077ce35738ec014843e276d Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 24 Apr 2023 18:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96css=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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/code/colorful.js b/src/code/colorful.js index 29de7ff..91d2468 100644 --- a/src/code/colorful.js +++ b/src/code/colorful.js @@ -195,15 +195,19 @@ export function colorHtml(code) { export function colorCss(code) { code = code .replace(STR, '$1$2$1') - .replace(/(\$[a-zA-Z\d_]+)/g, '$1') + .replace(/(\$[a-zA-Z\d_\-]+)/g, '$1') .replace(/(\-\-[a-z\d]+\-[a-z\d]+)/g, '$1') .replace( /:(hover|after|active|last\-child|first\-child|nth\-child)/g, ':$1' ) .replace( - /(?=\s)?([ ][\.#])([\w\-]+)/g, - '$1$2' + /^((?:[ ])*)([\.#])([\w\-]+)/gm, + '$1$2$3' + ) + .replace( + /:(root|host)/g, + ':$1' ) .replace(/([a-zA-Z\-]+):(\s?[^\n]+)/g, (m, k, v) => { if (v.trim() !== '(' && !v.endsWith(';')) {