1
1
Prism . languages . scss = Prism . languages . extend ( 'css' , {
2
2
'comment' : {
3
- pattern : / ( ^ | [ ^ \\ ] ) ( \/ \* [ \w \W ] * ?\* \/ | \/ \/ .* ? ( \r ? \n | $ ) ) / ,
3
+ pattern : / ( ^ | [ ^ \\ ] ) (?: \/ \* [ \w \W ] * ?\* \/ | \/ \/ .* ) / ,
4
4
lookbehind : true
5
5
} ,
6
6
'atrule' : {
7
- pattern : / @ [ \w - ] + (?: \( [ ^ ( ) ] + \) | [ ^ ( ] ) * ?(? = \s + ( \{ | ; ) ) / i ,
7
+ pattern : / @ [ \w - ] + (?: \( [ ^ ( ) ] + \) | [ ^ ( ] ) * ?(? = \s + [ { ; ] ) / ,
8
8
inside : {
9
9
'rule' : / @ [ \w - ] + /
10
10
// See rest below
11
11
}
12
12
} ,
13
13
// url, compassified
14
- 'url' : / ( [ - a - z ] + - ) * u r l (? = \( ) / i,
14
+ 'url' : / (?: [ - a - z ] + - ) * u r l (? = \( ) / i,
15
15
// CSS selector regex is not appropriate for Sass
16
16
// since there can be lot more things (var, @ directive, nesting..)
17
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 caracters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
18
+ // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
19
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
20
// can "pass" as a selector- e.g: proper#{$erty})
21
- // this one was ard to do, so please be careful if you edit this one :)
21
+ // this one was hard to do, so please be careful if you edit this one :)
22
22
'selector' : {
23
- pattern : / ( [ ^ @ ; \{ \} \( \) ] ? ( [ ^ @ ; \{ \} \( \) ] | & | # \{ \$ [ - _ \w ] + \} ) + ) (? = \s * \{ ( \} | \s | [ ^ \} ] + ( : | \{ ) [ ^ \} ] + ) ) / m,
23
+ // Initial look-ahead is used to prevent matching of blank selectors
24
+ pattern : / (? = \S ) [ ^ @ ; \{ \} \( \) ] ? ( [ ^ @ ; \{ \} \( \) ] | & | # \{ \$ [ - _ \w ] + \} ) + (? = \s * \{ ( \} | \s | [ ^ \} ] + ( : | \{ ) [ ^ \} ] + ) ) / m,
24
25
inside : {
25
- 'placeholder' : / % [ - _ \w ] + / i
26
+ 'placeholder' : / % [ - _ \w ] + /
26
27
}
27
28
}
28
29
} ) ;
29
30
30
31
Prism . languages . insertBefore ( 'scss' , 'atrule' , {
31
- 'keyword' : / @ ( i f | e l s e i f | e l s e | f o r | e a c h | w h i l e | i m p o r t | e x t e n d | d e b u g | w a r n | m i x i n | i n c l u d e | f u n c t i o n | r e t u r n | c o n t e n t ) | (? = @ f o r \s + \$ [ - _ \w ] + \s ) + f r o m / i
32
+ 'keyword' : [
33
+ / @ (?: i f | e l s e (?: i f ) ? | f o r | e a c h | w h i l e | i m p o r t | e x t e n d | d e b u g | w a r n | m i x i n | i n c l u d e | f u n c t i o n | r e t u r n | c o n t e n t ) / i,
34
+ {
35
+ pattern : / ( + ) (?: f r o m | t h r o u g h ) (? = ) / ,
36
+ lookbehind : true
37
+ }
38
+ ]
32
39
} ) ;
33
40
34
41
Prism . languages . insertBefore ( 'scss' , 'property' , {
35
42
// var and interpolated vars
36
- 'variable' : / ( ( \$ [ - _ \w ] + ) | ( # \{ \$ [ - _ \w ] + \} ) ) / i
43
+ 'variable' : / \$ [ - _ \w ] + | # \{ \$ [ - _ \w ] + \} /
37
44
} ) ;
38
45
39
46
Prism . languages . insertBefore ( 'scss' , 'function' , {
40
47
'placeholder' : {
41
- pattern : / % [ - _ \w ] + / i ,
48
+ pattern : / % [ - _ \w ] + / ,
42
49
alias : 'selector'
43
50
} ,
44
- 'statement' : / \B ! ( d e f a u l t | o p t i o n a l ) \b / i,
45
- 'boolean' : / \b ( t r u e | f a l s e ) \b / ,
46
- 'null' : / \b ( n u l l ) \b / ,
47
- 'operator' : / \s + ( [ - + ] { 1 , 2 } | = { 1 , 2 } | ! = | \| ? \| | \? | \* | \/ | % ) \s + /
51
+ 'statement' : / \B ! (?: d e f a u l t | o p t i o n a l ) \b / i,
52
+ 'boolean' : / \b (?: t r u e | f a l s e ) \b / ,
53
+ 'null' : / \b n u l l \b / ,
54
+ 'operator' : {
55
+ pattern : / ( \s ) (?: [ - + * \/ % ] | [ = ! ] = | < = ? | > = ? | a n d | o r | n o t ) (? = \s ) / ,
56
+ lookbehind : true
57
+ }
48
58
} ) ;
49
59
50
60
Prism . languages . scss [ 'atrule' ] . inside . rest = Prism . util . clone ( Prism . languages . scss ) ;
0 commit comments