Skip to content

Commit

Permalink
Sass: Fixed issues with CSS Extras (#2994)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Jul 15, 2021
1 parent 693b743 commit 14fdfe3
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@
"sass": {
"title": "Sass (Sass)",
"require": "css",
"optional": "css-extras",
"owner": "Golmote"
},
"scss": {
Expand Down
7 changes: 5 additions & 2 deletions components/prism-css-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
});

var unit = {
pattern: /(\b\d+)(?:%|[a-z]+\b)/,
pattern: /(\b\d+)(?:%|[a-z]+(?![\w-]))/,
lookbehind: true
};
// 123 -123 .123 -.123 12.3 -12.3
Expand All @@ -97,7 +97,10 @@
alias: 'color'
},
'color': [
/\b(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b/i,
{
pattern: /(^|[^\w-])(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)(?![\w-])/i,
lookbehind: true
},
{
pattern: /\b(?:rgb|hsl)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:rgb|hsl)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,
inside: {
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.

11 changes: 8 additions & 3 deletions components/prism-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// Sass comments don't need to be closed, only indented
'comment': {
pattern: /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t].+)*/m,
lookbehind: true
lookbehind: true,
greedy: true
}
});

Expand All @@ -12,6 +13,7 @@
'atrule-line': {
// Includes support for = and + shortcuts
pattern: /^(?:[ \t]*)[@+=].+/m,
greedy: true,
inside: {
'atrule': /(?:@[\w-]+|[+=])/m
}
Expand All @@ -33,6 +35,7 @@
// We want to consume the whole line
'variable-line': {
pattern: /^[ \t]*\$.+/m,
greedy: true,
inside: {
'punctuation': /:/,
'variable': variable,
Expand All @@ -42,6 +45,7 @@
// We want to consume the whole line
'property-line': {
pattern: /^[ \t]*(?:[^:\s]+ *:.*|:[^:\s].*)/m,
greedy: true,
inside: {
'property': [
/[^:\s]+(?=\s*:)/,
Expand All @@ -64,8 +68,9 @@
// what's left should be selectors
Prism.languages.insertBefore('sass', 'punctuation', {
'selector': {
pattern: /([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/,
lookbehind: true
pattern: /^([ \t]*)\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,[^,\r\n]+|[^,\r\n]*)(?:,[^,\r\n]+)*)*/m,
lookbehind: true,
greedy: true
}
});

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.

31 changes: 31 additions & 0 deletions tests/languages/css+css-extras+sass/issue2992.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.lucidagrande-normal-black-14px
color: var(--black)
font-family: var(--font-family-lucidagrande)
font-size: var(--font-size-m)
--foo: black

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

[
["selector", ".lucidagrande-normal-black-14px"],
["property-line", [
["property", "color"],
["punctuation", ":"],
" var(--black)"
]],
["property-line", [
["property", "font-family"],
["punctuation", ":"],
" var(--font-family-lucidagrande)"
]],
["property-line", [
["property", "font-size"],
["punctuation", ":"],
" var(--font-size-m)"
]],
["property-line", [
["property", "--foo"],
["punctuation", ":"],
" black"
]]
]

0 comments on commit 14fdfe3

Please sign in to comment.