优化css高亮
							parent
							
								
									66687150f8
								
							
						
					
					
						commit
						3d29009977
					
				| 
						 | 
					@ -195,15 +195,19 @@ export function colorHtml(code) {
 | 
				
			||||||
export function colorCss(code) {
 | 
					export function colorCss(code) {
 | 
				
			||||||
  code = code
 | 
					  code = code
 | 
				
			||||||
    .replace(STR, '<cc class="t-str">$1$2$1</cc>')
 | 
					    .replace(STR, '<cc class="t-str">$1$2$1</cc>')
 | 
				
			||||||
    .replace(/(\$[a-zA-Z\d_]+)/g, '<c class="t-var">$1</c>')
 | 
					    .replace(/(\$[a-zA-Z\d_\-]+)/g, '<c class="t-var">$1</c>')
 | 
				
			||||||
    .replace(/(\-\-[a-z\d]+\-[a-z\d]+)/g, '<c class="t-const">$1</c>')
 | 
					    .replace(/(\-\-[a-z\d]+\-[a-z\d]+)/g, '<c class="t-const">$1</c>')
 | 
				
			||||||
    .replace(
 | 
					    .replace(
 | 
				
			||||||
      /:(hover|after|active|last\-child|first\-child|nth\-child)/g,
 | 
					      /:(hover|after|active|last\-child|first\-child|nth\-child)/g,
 | 
				
			||||||
      '<c class="t-buildin">:$1</c>'
 | 
					      '<c class="t-buildin">:$1</c>'
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    .replace(
 | 
					    .replace(
 | 
				
			||||||
      /(?=\s)?([ ][\.#])([\w\-]+)/g,
 | 
					      /^((?:[ ])*)([\.#])([\w\-]+)/gm,
 | 
				
			||||||
      '<c class="t-comment">$1</c><c class="t-buildin">$2</c>'
 | 
					      '$1<c class="t-comment">$2</c><c class="t-keyword">$3</c>'
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    .replace(
 | 
				
			||||||
 | 
					      /:(root|host)/g,
 | 
				
			||||||
 | 
					      '<c class="t-comment">:</c><c class="t-keyword">$1</c>'
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    .replace(/([a-zA-Z\-]+):(\s?[^\n]+)/g, (m, k, v) => {
 | 
					    .replace(/([a-zA-Z\-]+):(\s?[^\n]+)/g, (m, k, v) => {
 | 
				
			||||||
      if (v.trim() !== '(' && !v.endsWith('</cc>;')) {
 | 
					      if (v.trim() !== '(' && !v.endsWith('</cc>;')) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue