123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- module.exports = function(hljs) {
- var FUNCTION_LIKE = {
- begin: /[\w-]+\(/, returnBegin: true,
- contains: [
- {
- className: 'built_in',
- begin: /[\w-]+/
- },
- {
- begin: /\(/, end: /\)/,
- contains: [
- hljs.APOS_STRING_MODE,
- hljs.QUOTE_STRING_MODE,
- hljs.CSS_NUMBER_MODE,
- ]
- }
- ]
- }
- var ATTRIBUTE = {
- className: 'attribute',
- begin: /\S/, end: ':', excludeEnd: true,
- starts: {
- endsWithParent: true, excludeEnd: true,
- contains: [
- FUNCTION_LIKE,
- hljs.CSS_NUMBER_MODE,
- hljs.QUOTE_STRING_MODE,
- hljs.APOS_STRING_MODE,
- hljs.C_BLOCK_COMMENT_MODE,
- {
- className: 'number', begin: '#[0-9A-Fa-f]+'
- },
- {
- className: 'meta', begin: '!important'
- }
- ]
- }
- }
- var AT_IDENTIFIER = '@[a-z-]+' // @font-face
- var AT_MODIFIERS = "and or not only"
- var MEDIA_TYPES = "all print screen speech"
- var AT_PROPERTY_RE = /@\-?\w[\w]*(\-\w+)*/ // @-webkit-keyframes
- var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
- var RULE = {
- begin: /(?:[A-Z\_\.\-]+|--[a-zA-Z0-9_-]+)\s*:/, returnBegin: true, end: ';', endsWithParent: true,
- contains: [
- ATTRIBUTE
- ]
- };
- return {
- case_insensitive: true,
- illegal: /[=\/|'\$]/,
- contains: [
- hljs.C_BLOCK_COMMENT_MODE,
- {
- className: 'selector-id', begin: /#[A-Za-z0-9_-]+/
- },
- {
- className: 'selector-class', begin: /\.[A-Za-z0-9_-]+/
- },
- {
- className: 'selector-attr',
- begin: /\[/, end: /\]/,
- illegal: '$',
- contains: [
- hljs.APOS_STRING_MODE,
- hljs.QUOTE_STRING_MODE,
- ]
- },
- {
- className: 'selector-pseudo',
- begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/
- },
- // matching these here allows us to treat them more like regular CSS
- // rules so everything between the {} gets regular rule highlighting,
- // which is what we want for page and font-face
- {
- begin: '@(page|font-face)',
- lexemes: AT_IDENTIFIER,
- keywords: '@page @font-face'
- },
- {
- begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
- // because it doesn’t let it to be parsed as
- // a rule set but instead drops parser into
- // the default mode which is how it should be.
- illegal: /:/, // break on Less variables @var: ...
- returnBegin: true,
- contains: [
- {
- className: 'keyword',
- begin: AT_PROPERTY_RE
- },
- {
- begin: /\s/, endsWithParent: true, excludeEnd: true,
- relevance: 0,
- keywords: AT_MODIFIERS,
- contains: [
- {
- begin: /[a-z-]+:/,
- className:"attribute"
- },
- hljs.APOS_STRING_MODE,
- hljs.QUOTE_STRING_MODE,
- hljs.CSS_NUMBER_MODE
- ]
- }
- ]
- },
- {
- className: 'selector-tag', begin: IDENT_RE,
- relevance: 0
- },
- {
- begin: '{', end: '}',
- illegal: /\S/,
- contains: [
- hljs.C_BLOCK_COMMENT_MODE,
- RULE,
- ]
- }
- ]
- };
- };
|