source: node_modules/refractor/lang/sass.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1'use strict'
2
3module.exports = sass
4sass.displayName = 'sass'
5sass.aliases = []
6function sass(Prism) {
7 ;(function (Prism) {
8 Prism.languages.sass = Prism.languages.extend('css', {
9 // Sass comments don't need to be closed, only indented
10 comment: {
11 pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,
12 lookbehind: true,
13 greedy: true
14 }
15 })
16 Prism.languages.insertBefore('sass', 'atrule', {
17 // We want to consume the whole line
18 'atrule-line': {
19 // Includes support for = and + shortcuts
20 pattern: /^(?:[ \t]*)[@+=].+/m,
21 greedy: true,
22 inside: {
23 atrule: /(?:@[\w-]+|[+=])/
24 }
25 }
26 })
27 delete Prism.languages.sass.atrule
28 var variable = /\$[-\w]+|#\{\$[-\w]+\}/
29 var operator = [
30 /[+*\/%]|[=!]=|<=?|>=?|\b(?:and|not|or)\b/,
31 {
32 pattern: /(\s)-(?=\s)/,
33 lookbehind: true
34 }
35 ]
36 Prism.languages.insertBefore('sass', 'property', {
37 // We want to consume the whole line
38 'variable-line': {
39 pattern: /^[ \t]*\$.+/m,
40 greedy: true,
41 inside: {
42 punctuation: /:/,
43 variable: variable,
44 operator: operator
45 }
46 },
47 // We want to consume the whole line
48 'property-line': {
49 pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,
50 greedy: true,
51 inside: {
52 property: [
53 /[^:\s]+(?=\s*:)/,
54 {
55 pattern: /(:)[^:\s]+/,
56 lookbehind: true
57 }
58 ],
59 punctuation: /:/,
60 variable: variable,
61 operator: operator,
62 important: Prism.languages.sass.important
63 }
64 }
65 })
66 delete Prism.languages.sass.property
67 delete Prism.languages.sass.important // Now that whole lines for other patterns are consumed,
68 // what's left should be selectors
69 Prism.languages.insertBefore('sass', 'punctuation', {
70 selector: {
71 pattern:
72 /^([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/m,
73 lookbehind: true,
74 greedy: true
75 }
76 })
77 })(Prism)
78}
Note: See TracBrowser for help on using the repository browser.