prismjs_components_prism-scss.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // node_modules/prismjs/components/prism-scss.js
  2. Prism.languages.scss = Prism.languages.extend("css", {
  3. "comment": {
  4. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  5. lookbehind: true
  6. },
  7. "atrule": {
  8. pattern: /@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,
  9. inside: {
  10. "rule": /@[\w-]+/
  11. // See rest below
  12. }
  13. },
  14. // url, compassified
  15. "url": /(?:[-a-z]+-)?url(?=\()/i,
  16. // CSS selector regex is not appropriate for Sass
  17. // since there can be lot more things (var, @ directive, nesting..)
  18. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  19. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  20. // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
  21. // can "pass" as a selector- e.g: proper#{$erty})
  22. // this one was hard to do, so please be careful if you edit this one :)
  23. "selector": {
  24. // Initial look-ahead is used to prevent matching of blank selectors
  25. pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,
  26. inside: {
  27. "parent": {
  28. pattern: /&/,
  29. alias: "important"
  30. },
  31. "placeholder": /%[-\w]+/,
  32. "variable": /\$[-\w]+|#\{\$[-\w]+\}/
  33. }
  34. },
  35. "property": {
  36. pattern: /(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,
  37. inside: {
  38. "variable": /\$[-\w]+|#\{\$[-\w]+\}/
  39. }
  40. }
  41. });
  42. Prism.languages.insertBefore("scss", "atrule", {
  43. "keyword": [
  44. /@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,
  45. {
  46. pattern: /( )(?:from|through)(?= )/,
  47. lookbehind: true
  48. }
  49. ]
  50. });
  51. Prism.languages.insertBefore("scss", "important", {
  52. // var and interpolated vars
  53. "variable": /\$[-\w]+|#\{\$[-\w]+\}/
  54. });
  55. Prism.languages.insertBefore("scss", "function", {
  56. "module-modifier": {
  57. pattern: /\b(?:as|hide|show|with)\b/i,
  58. alias: "keyword"
  59. },
  60. "placeholder": {
  61. pattern: /%[-\w]+/,
  62. alias: "selector"
  63. },
  64. "statement": {
  65. pattern: /\B!(?:default|optional)\b/i,
  66. alias: "keyword"
  67. },
  68. "boolean": /\b(?:false|true)\b/,
  69. "null": {
  70. pattern: /\bnull\b/,
  71. alias: "keyword"
  72. },
  73. "operator": {
  74. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,
  75. lookbehind: true
  76. }
  77. });
  78. Prism.languages.scss["atrule"].inside.rest = Prism.languages.scss;
  79. //# sourceMappingURL=prismjs_components_prism-scss.js.map