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