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

101 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
]
}
]
};
};