Skip to content

Commit b2763e7

Browse files
committed
Sass: Highlight "-" as operator only if surrounded by spaces, in order to not break hyphenated values (e.g. "ease-in-out")
1 parent 895bf46 commit b2763e7

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

components/prism-sass.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121

2222

2323
var variable = /((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i;
24-
var operator = /[-+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/;
24+
var operator = [
25+
/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/,
26+
{
27+
pattern: /(\s+)-(?=\s)/,
28+
lookbehind: true
29+
}
30+
];
2531

2632
Prism.languages.insertBefore('sass', 'property', {
2733
// We want to consume the whole line

components/prism-sass.min.js

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

tests/languages/sass/property-line_feature.test

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
foo: bar
22
color: $color !important
33
-moz-border-radius: 10px
4+
transition-timing-function: ease-in-out
45

56
:color #{$color}
67
:font-size 0.5em + 3em
@@ -24,6 +25,11 @@ foo: bar
2425
["punctuation", ":"],
2526
" 10px"
2627
]],
28+
["property-line", [
29+
["property", "transition-timing-function"],
30+
["punctuation", ":"],
31+
" ease-in-out"
32+
]],
2733
["property-line", [
2834
["punctuation", ":"],
2935
["property", "color"],

0 commit comments

Comments
 (0)