UNPKG

1.67 kBJavaScriptView Raw
1(function(Prism) {
2 Prism.languages.sass = Prism.languages.extend('css', {
3 // Sass comments don't need to be closed, only indented
4 'comment': /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m
5 });
6
7 Prism.languages.insertBefore('sass', 'atrule', {
8 // We want to consume the whole line
9 'atrule-line': {
10 // Includes support for = and + shortcuts
11 pattern: /^(?:[ \t]*)[@+=].+/m,
12 inside: {
13 'atrule': /^(?:[ \t]*)(?:@[\w-]+|[+=])/m
14 }
15 }
16 });
17 delete Prism.languages.sass.atrule;
18
19
20 var variable = /((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i;
21 var operator = /[-+]{1,2}|==?|!=|\|?\||\?|\*|\/|%/;
22
23 Prism.languages.insertBefore('sass', 'property', {
24 // We want to consume the whole line
25 'variable-line': {
26 pattern: /(^|(?:\r?\n|\r))[ \t]*\$.+/,
27 lookbehind: true,
28 inside: {
29 'punctuation': /:/,
30 'variable': variable,
31 'operator': operator
32 }
33 },
34 // We want to consume the whole line
35 'property-line': {
36 pattern: /(^|(?:\r?\n|\r))[ \t]*(?:[^:\s]+[ ]*:.*|:[^:\s]+.*)/i,
37 lookbehind: true,
38 inside: {
39 'property': [
40 /[^:\s]+(?=\s*:)/,
41 {
42 pattern: /(:)[^:\s]+/,
43 lookbehind: true
44 }
45 ],
46 'punctuation': /:/,
47 'variable': variable,
48 'operator': operator,
49 'important': Prism.languages.sass.important
50 }
51 }
52 });
53 delete Prism.languages.sass.property;
54 delete Prism.languages.sass.important;
55
56 // Now that whole lines for other patterns are consumed,
57 // what's left should be selectors
58 delete Prism.languages.sass.selector;
59 Prism.languages.insertBefore('sass', 'punctuation', {
60 'selector': {
61 pattern: /([ \t]*).+(?:,(?:\r?\n|\r)\1[ \t]+.+)*/,
62 lookbehind: true
63 }
64 });
65
66}(Prism));
\No newline at end of file