27 lines
2.0 KiB
JavaScript
27 lines
2.0 KiB
JavaScript
|
hljs.registerLanguage("less",function(){"use strict";return function(e){
|
||
|
var n="([\\w-]+|@{[\\w-]+})",a=[],s=[],t=function(e){return{className:"string",
|
||
|
begin:"~?"+e+".*?"+e}},r=function(e,n,a){return{className:e,begin:n,relevance:a}
|
||
|
},i={begin:"\\(",end:"\\)",contains:s,relevance:0}
|
||
|
;s.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t("'"),t('"'),e.CSS_NUMBER_MODE,{
|
||
|
begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",
|
||
|
excludeEnd:!0}
|
||
|
},r("number","#[0-9A-Fa-f]+\\b"),i,r("variable","@@?[\\w-]+",10),r("variable","@{[\\w-]+}"),r("built_in","~?`[^`]*?`"),{
|
||
|
className:"attribute",begin:"[\\w-]+\\s*:",end:":",returnBegin:!0,excludeEnd:!0
|
||
|
},{className:"meta",begin:"!important"});var c=s.concat({begin:"{",end:"}",
|
||
|
contains:a}),l={beginKeywords:"when",endsWithParent:!0,contains:[{
|
||
|
beginKeywords:"and not"}].concat(s)},o={begin:n+"\\s*:",returnBegin:!0,
|
||
|
end:"[;}]",relevance:0,contains:[{className:"attribute",begin:n,end:":",
|
||
|
excludeEnd:!0,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:s}
|
||
|
}]},g={className:"keyword",
|
||
|
begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",
|
||
|
starts:{end:"[;{}]",returnEnd:!0,contains:s,relevance:0}},d={
|
||
|
className:"variable",variants:[{begin:"@[\\w-]+\\s*:",relevance:15},{
|
||
|
begin:"@[\\w-]+"}],starts:{end:"[;}]",returnEnd:!0,contains:c}},b={variants:[{
|
||
|
begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:n,end:"{"}],returnBegin:!0,
|
||
|
returnEnd:!0,illegal:"[<='$\"]",relevance:0,
|
||
|
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,l,r("keyword","all\\b"),r("variable","@{[\\w-]+}"),r("selector-tag",n+"%?",0),r("selector-id","#"+n),r("selector-class","\\."+n,0),r("selector-tag","&",0),{
|
||
|
className:"selector-attr",begin:"\\[",end:"\\]"},{className:"selector-pseudo",
|
||
|
begin:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{begin:"\\(",end:"\\)",contains:c},{
|
||
|
begin:"!important"}]}
|
||
|
;return a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,g,d,o,b),{
|
||
|
name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:a}}}());
|