Skip to content

Commit 7315fb1

Browse files
authored
enh(css) add support for hex color alpha channel (#3360) (#3362)
1 parent 7cb4e3d commit 7315fb1

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Grammars:
4040
- enh(nsis) add new NSIS commands (#3351) [idleberg][]
4141
- fix(nsis) set `case_insensitive` to `true` (#3351) [idleberg][]
4242
- fix(css/less/stylus/scss) highlight single-colon psuedo-elements properly (#3240) [zsoltlengyelit][]
43+
- fix(css) add css hex color alpha support (#3360) [ierehon1905][]
4344

4445
[Austin Schick]: https://github.com/austin-schick
4546
[Josh Goebel]: https://github.com/joshgoebel
@@ -53,6 +54,7 @@ Grammars:
5354
[zsoltlengyelit]: github.com/zsoltlengyelit
5455
[Syb Wartna]:https://github.com/waarissyb
5556
[idleberg]: https://github.com/idleberg
57+
[ierehon1905]: https://github.com/ierehon1905
5658

5759

5860
## Version 11.2.0

src/languages/lib/css-shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const MODES = (hljs) => {
77
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE,
88
HEXCOLOR: {
99
scope: 'number',
10-
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'
10+
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
1111
},
1212
FUNCTION_DISPATCH: {
1313
className: "built_in",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<span class="hljs-selector-class">.test-short</span> {
2+
<span class="hljs-attribute">color</span>: <span class="hljs-number">#abc</span>;
3+
}
4+
5+
<span class="hljs-selector-class">.test-short-alpha</span> {
6+
<span class="hljs-attribute">color</span>: <span class="hljs-number">#abcd</span>;
7+
}
8+
9+
<span class="hljs-selector-class">.test-long</span> {
10+
<span class="hljs-attribute">color</span>: <span class="hljs-number">#aabbcc</span>;
11+
}
12+
13+
<span class="hljs-selector-class">.test-long-alpha</span> {
14+
<span class="hljs-attribute">color</span>: <span class="hljs-number">#aabbccdd</span>;
15+
}
16+
17+
<span class="hljs-selector-class">.test-invalid</span> {
18+
<span class="hljs-attribute">color</span>: #aabbccd;
19+
}

test/markup/css/hex-colors.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.test-short {
2+
color: #abc;
3+
}
4+
5+
.test-short-alpha {
6+
color: #abcd;
7+
}
8+
9+
.test-long {
10+
color: #aabbcc;
11+
}
12+
13+
.test-long-alpha {
14+
color: #aabbccdd;
15+
}
16+
17+
.test-invalid {
18+
color: #aabbccd;
19+
}

0 commit comments

Comments
 (0)