Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed CSS extra variable
  • Loading branch information
RunDevelopment committed Dec 3, 2018
commit ba10934e98658c88455ded955df095b8d51a867c
9 changes: 6 additions & 3 deletions components/prism-css-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ Prism.languages.css.selector = {
}
};

Prism.languages.insertBefore('css', 'function', {
Prism.languages.insertBefore('css', 'property', {
'variable': {
pattern: /(var\()[^)]+(?=\))/,
pattern: /(^|[^-\w\xA0-\uFFFF])--[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*/i,
lookbehind: true
},
}
});

Prism.languages.insertBefore('css', 'function', {
'operator': {
pattern: /(\s)[+\-*\/](?=\s)/,
lookbehind: true
Expand Down
2 changes: 1 addition & 1 deletion components/prism-css-extras.min.js

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

20 changes: 20 additions & 0 deletions tests/languages/css!+css-extras/variable_feature.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
element {
--foo: green;
}

var(--color-primary)
var(--level-3)
var(--foo, red)
calc(100% - var(--margin-size) * 2)

----------------------------------------------------

[
["selector", ["element"]],
["punctuation", "{"],
["variable", "--foo"],
["punctuation", ":"],
" green",
["punctuation", ";"],
["punctuation", "}"],

["function", "var"],
["punctuation", "("],
["variable", "--color-primary"],
Expand All @@ -15,6 +28,13 @@ calc(100% - var(--margin-size) * 2)
["variable", "--level-3"],
["punctuation", ")"],

["function", "var"],
["punctuation", "("],
["variable", "--foo"],
["punctuation", ","],
" red",
["punctuation", ")"],

["function", "calc"],
["punctuation", "("],
["number", "100"],
Expand Down