Skip to content

Commit

Permalink
Sass: Highlight "-" as operator only if surrounded by spaces, in orde…
Browse files Browse the repository at this point in the history
…r to not break hyphenated values (e.g. "ease-in-out")
  • Loading branch information
Golmote committed Sep 21, 2015
1 parent 895bf46 commit b2763e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion components/prism-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@


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

Prism.languages.insertBefore('sass', 'property', {
// We want to consume the whole line
Expand Down
2 changes: 1 addition & 1 deletion components/prism-sass.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/languages/sass/property-line_feature.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
foo: bar
color: $color !important
-moz-border-radius: 10px
transition-timing-function: ease-in-out

:color #{$color}
:font-size 0.5em + 3em
Expand All @@ -24,6 +25,11 @@ foo: bar
["punctuation", ":"],
" 10px"
]],
["property-line", [
["property", "transition-timing-function"],
["punctuation", ":"],
" ease-in-out"
]],
["property-line", [
["punctuation", ":"],
["property", "color"],
Expand Down

0 comments on commit b2763e7

Please sign in to comment.