Skip to content

Commit deb238a

Browse files
authoredNov 23, 2020
SCSS: Added support for Sass modules (#2643)
1 parent 8bfcc81 commit deb238a

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed
 

‎components/prism-scss.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Prism.languages.scss = Prism.languages.extend('css', {
4141

4242
Prism.languages.insertBefore('scss', 'atrule', {
4343
'keyword': [
44-
/@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
44+
/@(?:if|else(?: if)?|forward|for|each|while|import|use|extend|debug|warn|mixin|include|function|return|content)\b/i,
4545
{
4646
pattern: /( +)(?:from|through)(?= )/,
4747
lookbehind: true
@@ -55,6 +55,10 @@ Prism.languages.insertBefore('scss', 'important', {
5555
});
5656

5757
Prism.languages.insertBefore('scss', 'function', {
58+
'module-modifier': {
59+
pattern: /\b(?:as|with|show|hide)\b/i,
60+
alias: 'keyword'
61+
},
5862
'placeholder': {
5963
pattern: /%[-\w]+/,
6064
alias: 'selector'

‎components/prism-scss.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/languages/scss/keyword_feature.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@if @else if @else
22
@for @each @while
3-
@import @extend
3+
@import @extend @use @forward
44
@debug @warn @mixin
55
@include @function
66
@return @content
@@ -12,7 +12,7 @@
1212
[
1313
["keyword", "@if"], ["keyword", "@else if"], ["keyword", "@else"],
1414
["keyword", "@for"], ["keyword", "@each"], ["keyword", "@while"],
15-
["keyword", "@import"], ["keyword", "@extend"],
15+
["keyword", "@import"], ["keyword", "@extend"], ["keyword", "@use"], ["keyword", "@forward"],
1616
["keyword", "@debug"], ["keyword", "@warn"], ["keyword", "@mixin"],
1717
["keyword", "@include"], ["keyword", "@function"],
1818
["keyword", "@return"], ["keyword", "@content"],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@use "foo" as bar;
2+
@use "foo" with ($color: blue);
3+
@forward "foo" show bar;
4+
@forward "foo" hide baz;
5+
6+
----------------------------------------------------
7+
8+
[
9+
["keyword", "@use"], ["string", "\"foo\""], ["module-modifier", "as"], " bar", ["punctuation", ";"],
10+
["keyword", "@use"], ["string", "\"foo\""], ["module-modifier", "with"], ["punctuation", "("], ["property", [["variable", "$color"]]], ["punctuation", ":"], " blue", ["punctuation", ")"], ["punctuation", ";"],
11+
["keyword", "@forward"], ["string", "\"foo\""], ["module-modifier", "show"], " bar", ["punctuation", ";"],
12+
["keyword", "@forward"], ["string", "\"foo\""], ["module-modifier", "hide"], " baz", ["punctuation", ";"]
13+
]
14+
15+
----------------------------------------------------
16+
17+
Checks for Sass module modifiers

0 commit comments

Comments
 (0)
Please sign in to comment.