0
This repository has been archived on 2024-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
highlight_js-rails/vendor/assets/javascripts/highlight_js/languages/css.js
2015-01-25 16:00:01 +01:00

109 lines
2.8 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.
/*
Language: CSS
Category: common, css
*/
function(hljs) {
var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
var FUNCTION = {
className: 'function',
begin: IDENT_RE + '\\(',
returnBegin: true,
excludeEnd: true,
end: '\\('
};
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_-]+',
relevance: 0
},
{
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]',
relevance: 0,
contains: [
hljs.C_BLOCK_COMMENT_MODE,
{
className: 'rule',
begin: '[^\\s]', returnBegin: true, end: ';', endsWithParent: true,
contains: [
{
className: 'attribute',
begin: '[A-Z\\_\\.\\-]+', end: ':',
excludeEnd: true,
illegal: '[^\\s]',
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'
}
]
}
}
]
}
]
}
]
};
}