css.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * CSS patterns
  3. *
  4. * @author Craig Campbell
  5. */
  6. Rainbow.extend('css', [
  7. {
  8. name: 'comment',
  9. pattern: /\/\*[\s\S]*?\*\//gm
  10. },
  11. {
  12. name: 'constant.hex-color',
  13. pattern: /#([a-f0-9]{3}|[a-f0-9]{6})(?=;|\s|,|\))/gi
  14. },
  15. {
  16. matches: {
  17. 1: 'constant.numeric',
  18. 2: 'keyword.unit'
  19. },
  20. pattern: /(\d+)(px|em|cm|s|%)?/g
  21. },
  22. {
  23. name: 'string',
  24. pattern: /('|")(.*?)\1/g
  25. },
  26. {
  27. name: 'support.css-property',
  28. matches: {
  29. 1: 'support.vendor-prefix'
  30. },
  31. pattern: /(-o-|-moz-|-webkit-|-ms-)?[\w-]+(?=\s?:)(?!.*\{)/g
  32. },
  33. {
  34. matches: {
  35. 1: [
  36. {
  37. name: 'entity.name.sass',
  38. pattern: /&/g
  39. },
  40. {
  41. name: 'direct-descendant',
  42. pattern: />/g
  43. },
  44. {
  45. name: 'entity.name.class',
  46. pattern: /\.[\w\-_]+/g
  47. },
  48. {
  49. name: 'entity.name.id',
  50. pattern: /\#[\w\-_]+/g
  51. },
  52. {
  53. name: 'entity.name.pseudo',
  54. pattern: /:[\w\-_]+/g
  55. },
  56. {
  57. name: 'entity.name.tag',
  58. pattern: /\w+/g
  59. }
  60. ]
  61. },
  62. pattern: /([\w\ ,\n:\.\#\&\;\-_]+)(?=.*\{)/g
  63. },
  64. {
  65. matches: {
  66. 2: 'support.vendor-prefix',
  67. 3: 'support.css-value'
  68. },
  69. pattern: /(:|,)\s*(-o-|-moz-|-webkit-|-ms-)?([a-zA-Z-]*)(?=\b)(?!.*\{)/g
  70. }
  71. ]);
  72. Rainbow.addAlias('scss', 'css');