biofriction-wp-theme/node_modules/highlight.js/lib/languages/css.js

101 lines
2.5 KiB
JavaScript
Raw Normal View History

2021-10-26 14:18:09 +02:00
module.exports = function(hljs) {
var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
var FUNCTION = {
className: 'function',
begin: IDENT_RE + '\\(',
returnBegin: true,
excludeEnd: true,
end: '\\('
};
var RULE = {
className: 'rule',
begin: /[A-Z\_\.\-]+\s*:/, returnBegin: true, end: ';', endsWithParent: true,
contains: [
{
className: 'attribute',
begin: /\S/, end: ':', excludeEnd: true,
starts: {
className: 'value',
endsWithParent: true, excludeEnd: true,
contains: [
FUNCTION,
hljs.CSS_NUMBER_MODE,
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
hljs.C_BLOCK_COMMENT_MODE,
{
className: 'hexcolor', begin: '#[0-9A-Fa-f]+'
},
{
className: 'important', begin: '!important'
}
]
}
}
]
};
return {
case_insensitive: true,
illegal: /[=\/|'\$]/,
contains: [
hljs.C_BLOCK_COMMENT_MODE,
{
className: 'id', begin: /\#[A-Za-z0-9_-]+/
},
{
className: 'class', begin: /\.[A-Za-z0-9_-]+/
},
{
className: 'attr_selector',
begin: /\[/, end: /\]/,
illegal: '$'
},
{
className: 'pseudo',
begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"']+/
},
{
className: 'at_rule',
begin: '@(font-face|page)',
lexemes: '[a-z-]+',
keywords: 'font-face page'
},
{
className: 'at_rule',
begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
// because it doesnt let it to be parsed as
// a rule set but instead drops parser into
// the default mode which is how it should be.
contains: [
{
className: 'keyword',
begin: /\S+/
},
{
begin: /\s/, endsWithParent: true, excludeEnd: true,
relevance: 0,
contains: [
FUNCTION,
hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE,
hljs.CSS_NUMBER_MODE
]
}
]
},
{
className: 'tag', begin: IDENT_RE,
relevance: 0
},
{
className: 'rules',
begin: '{', end: '}',
illegal: /\S/,
contains: [
hljs.C_BLOCK_COMMENT_MODE,
RULE,
]
}
]
};
};