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(';')) {