scss.js 7.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. module.exports = function(hljs) {
  2. var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
  3. var VARIABLE = {
  4. className: 'variable',
  5. begin: '(\\$' + IDENT_RE + ')\\b'
  6. };
  7. var HEXCOLOR = {
  8. className: 'number', begin: '#[0-9A-Fa-f]+'
  9. };
  10. var DEF_INTERNALS = {
  11. className: 'attribute',
  12. begin: '[A-Z\\_\\.\\-]+', end: ':',
  13. excludeEnd: true,
  14. illegal: '[^\\s]',
  15. starts: {
  16. endsWithParent: true, excludeEnd: true,
  17. contains: [
  18. HEXCOLOR,
  19. hljs.CSS_NUMBER_MODE,
  20. hljs.QUOTE_STRING_MODE,
  21. hljs.APOS_STRING_MODE,
  22. hljs.C_BLOCK_COMMENT_MODE,
  23. {
  24. className: 'meta', begin: '!important'
  25. }
  26. ]
  27. }
  28. };
  29. return {
  30. case_insensitive: true,
  31. illegal: '[=/|\']',
  32. contains: [
  33. hljs.C_LINE_COMMENT_MODE,
  34. hljs.C_BLOCK_COMMENT_MODE,
  35. {
  36. className: 'selector-id', begin: '\\#[A-Za-z0-9_-]+',
  37. relevance: 0
  38. },
  39. {
  40. className: 'selector-class', begin: '\\.[A-Za-z0-9_-]+',
  41. relevance: 0
  42. },
  43. {
  44. className: 'selector-attr', begin: '\\[', end: '\\]',
  45. illegal: '$'
  46. },
  47. {
  48. className: 'selector-tag', // begin: IDENT_RE, end: '[,|\\s]'
  49. begin: '\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b',
  50. relevance: 0
  51. },
  52. {
  53. begin: ':(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)'
  54. },
  55. {
  56. begin: '::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)'
  57. },
  58. VARIABLE,
  59. {
  60. className: 'attribute',
  61. begin: '\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b',
  62. illegal: '[^\\s]'
  63. },
  64. {
  65. begin: '\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b'
  66. },
  67. {
  68. begin: ':', end: ';',
  69. contains: [
  70. VARIABLE,
  71. HEXCOLOR,
  72. hljs.CSS_NUMBER_MODE,
  73. hljs.QUOTE_STRING_MODE,
  74. hljs.APOS_STRING_MODE,
  75. {
  76. className: 'meta', begin: '!important'
  77. }
  78. ]
  79. },
  80. {
  81. begin: '@', end: '[{;]',
  82. keywords: 'mixin include extend for if else each while charset import debug media page content font-face namespace warn',
  83. contains: [
  84. VARIABLE,
  85. hljs.QUOTE_STRING_MODE,
  86. hljs.APOS_STRING_MODE,
  87. HEXCOLOR,
  88. hljs.CSS_NUMBER_MODE,
  89. {
  90. begin: '\\s[A-Za-z0-9_.-]+',
  91. relevance: 0
  92. }
  93. ]
  94. }
  95. ]
  96. };
  97. };