Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) add css hex color alpha support (#3360) #3362

Merged
merged 2 commits into from Oct 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -40,6 +40,7 @@ Grammars:
- enh(nsis) add new NSIS commands (#3351) [idleberg][]
- fix(nsis) set `case_insensitive` to `true` (#3351) [idleberg][]
- fix(css/less/stylus/scss) highlight single-colon psuedo-elements properly (#3240) [zsoltlengyelit][]
- fix(css) add css hex color alpha support (#3360) [ierehon1905][]

[Austin Schick]: https://github.com/austin-schick
[Josh Goebel]: https://github.com/joshgoebel
Expand All @@ -53,6 +54,7 @@ Grammars:
[zsoltlengyelit]: github.com/zsoltlengyelit
[Syb Wartna]:https://github.com/waarissyb
[idleberg]: https://github.com/idleberg
[ierehon1905]: https://github.com/ierehon1905


## Version 11.2.0
Expand Down
2 changes: 1 addition & 1 deletion src/languages/lib/css-shared.js
Expand Up @@ -7,7 +7,7 @@ export const MODES = (hljs) => {
BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE,
HEXCOLOR: {
scope: 'number',
begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
},
FUNCTION_DISPATCH: {
className: "built_in",
Expand Down
19 changes: 19 additions & 0 deletions test/markup/css/hex-colors.expect.txt
@@ -0,0 +1,19 @@
<span class="hljs-selector-class">.test-short</span> {
<span class="hljs-attribute">color</span>: <span class="hljs-number">#abc</span>;
}

<span class="hljs-selector-class">.test-short-alpha</span> {
<span class="hljs-attribute">color</span>: <span class="hljs-number">#abcd</span>;
}

<span class="hljs-selector-class">.test-long</span> {
<span class="hljs-attribute">color</span>: <span class="hljs-number">#aabbcc</span>;
}

<span class="hljs-selector-class">.test-long-alpha</span> {
<span class="hljs-attribute">color</span>: <span class="hljs-number">#aabbccdd</span>;
}

<span class="hljs-selector-class">.test-invalid</span> {
<span class="hljs-attribute">color</span>: #aabbccd;
}
19 changes: 19 additions & 0 deletions test/markup/css/hex-colors.txt
@@ -0,0 +1,19 @@
.test-short {
color: #abc;
}

.test-short-alpha {
color: #abcd;
}

.test-long {
color: #aabbcc;
}

.test-long-alpha {
color: #aabbccdd;
}

.test-invalid {
color: #aabbccd;
}