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