Skip to content

Commit c7d9973

Browse files
authored
Fix for CSS unicode-range support, issue #4253. (#4254)
* Fix for CSS unicode-range support, issue #4253. * Update CHANGES.md. * Update less/scss/styles tests. * Take care of unexpected case sensitivity issues.
1 parent 4d386f8 commit c7d9973

14 files changed

+21
-12
lines changed

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Core Grammars:
2222
- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][]
2323
- enh(php) support single line and hash comments in attributes, constructor and functions [Antoine Musso][]
2424
- enh(json) add json5 support [Kerry Shetline][]
25+
- fix(css) `unicode-range` parsing, issue #4253 [Kerry Shetline][]
2526
- fix(csharp) Support digit separators [te-ing][]
2627

2728
Documentation:
@@ -41,17 +42,16 @@ CONTRIBUTORS
4142
[Chris Wilson]: https://github.com/sushicw
4243
[Antoine Musso]: https://github.com/hashar
4344
[Chester Moses]: https://github.com/Chester-Moses-HCL
45+
[Kerry Shetline]: https://github.com/kshetline
4446
[SungHyun Kim]: https://github.com/witch-factory
4547
[Adam Lui]: https://github.com/adamlui
4648
[Sebastiaan Speck]: https://github.com/sebastiaanspeck
4749
[Filip Hoffmann]: https://github.com/folospior
48-
[Kerry Shetline]: https://github.com/kshetline
4950
[Twineee1]: https://github.com/Twineee1
5051
[hbgl]: https://github.com/hbgl
5152
[te-ing]: https://github.com/te-ing
5253
[Anthony Martin]: https://github.com/anthony-c-martin
5354

54-
5555
## Version 11.11.1
5656

5757
- Fixes regression with Rust grammar.

src/languages/css.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ export default function(hljs) {
7373
modes.HEXCOLOR,
7474
modes.IMPORTANT,
7575
modes.CSS_NUMBER_MODE,
76+
modes.UNICODE_RANGE,
7677
...STRINGS,
7778
// needed to highlight these as strings and to avoid issues with
78-
// illegal characters that might be inside urls that would tigger the
79+
// illegal characters that might be inside urls that would trigger the
7980
// languages illegal stack
8081
{
8182
begin: /(url|data-uri)\(/,

src/languages/less.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default function(hljs) {
6767
excludeEnd: true
6868
}
6969
},
70+
modes.UNICODE_RANGE,
7071
modes.HEXCOLOR,
7172
PARENS_MODE,
7273
IDENT_MODE('variable', '@@?' + IDENT_RE, 10),
@@ -177,7 +178,7 @@ export default function(hljs) {
177178
MIXIN_GUARD_MODE,
178179
IDENT_MODE('keyword', 'all\\b'),
179180
IDENT_MODE('variable', '@\\{' + IDENT_RE + '\\}'), // otherwise it’s identified as tag
180-
181+
181182
{
182183
begin: '\\b(' + css.TAGS.join('|') + ')\\b',
183184
className: 'selector-tag'

src/languages/lib/css-shared.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const MODES = (hljs) => {
99
scope: 'number',
1010
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
1111
},
12+
UNICODE_RANGE: {
13+
scope: 'number',
14+
begin: /\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,4}(-[0-9A-Fa-f][0-9A-Fa-f]{0,4})?/
15+
},
1216
FUNCTION_DISPATCH: {
1317
className: "built_in",
1418
begin: /[\w-]+(?=\()/
@@ -777,6 +781,7 @@ export const ATTRIBUTES = [
777781
'transition-timing-function',
778782
'translate',
779783
'unicode-bidi',
784+
'unicode-range',
780785
'user-modify',
781786
'user-select',
782787
'vector-effect',

src/languages/scss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default function(hljs) {
7979
VARIABLE,
8080
modes.HEXCOLOR,
8181
modes.CSS_NUMBER_MODE,
82+
modes.UNICODE_RANGE,
8283
hljs.QUOTE_STRING_MODE,
8384
hljs.APOS_STRING_MODE,
8485
modes.IMPORTANT,

src/languages/stylus.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export default function(hljs) {
148148
VARIABLE,
149149
hljs.APOS_STRING_MODE,
150150
modes.CSS_NUMBER_MODE,
151+
modes.UNICODE_RANGE,
151152
hljs.QUOTE_STRING_MODE
152153
]
153154
}

test/markup/css/css_consistency.expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<span class="hljs-attribute">font-variant</span>: no-common-ligatures proportional-nums;
5555
<span class="hljs-attribute">font-feature-settings</span>: <span class="hljs-string">&quot;liga&quot;</span> <span class="hljs-number">0</span>;
5656
<span class="hljs-attribute">font-variation-settings</span>: <span class="hljs-string">&quot;xhgt&quot;</span> <span class="hljs-number">0.7</span>;
57-
<span class="hljs-comment">/* unicode-range: U+0025-00FF, U+4??; */</span>
57+
<span class="hljs-attribute">unicode-range</span>: <span class="hljs-number">U+0025-00FF</span>, <span class="hljs-number">U+4??</span>;
5858
<span class="hljs-comment">/* it&#x27;s not 100% clear how url and format should be highlighted universally */</span>
5959
<span class="hljs-comment">/* src: url(&quot;/fonts/OpenSans-Regular-webfont.woff2&quot;) format(&quot;woff2&quot;),
6060
url(&quot;/fonts/OpenSans-Regular-webfont.woff&quot;) format(&quot;woff&quot;); */</span>

test/markup/css/css_consistency.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ a[href*="example"] {}
5454
font-variant: no-common-ligatures proportional-nums;
5555
font-feature-settings: "liga" 0;
5656
font-variation-settings: "xhgt" 0.7;
57-
/* unicode-range: U+0025-00FF, U+4??; */
57+
unicode-range: U+0025-00FF, U+4??;
5858
/* it's not 100% clear how url and format should be highlighted universally */
5959
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
6060
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */

test/markup/less/css_consistency.expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<span class="hljs-attribute">font-variant</span>: no-common-ligatures proportional-nums;
5555
<span class="hljs-attribute">font-feature-settings</span>: <span class="hljs-string">&quot;liga&quot;</span> <span class="hljs-number">0</span>;
5656
<span class="hljs-attribute">font-variation-settings</span>: <span class="hljs-string">&quot;xhgt&quot;</span> <span class="hljs-number">0.7</span>;
57-
<span class="hljs-comment">/* unicode-range: U+0025-00FF, U+4??; */</span>
57+
<span class="hljs-attribute">unicode-range</span>: <span class="hljs-number">U+0025-00FF</span>, <span class="hljs-number">U+4??</span>;
5858
<span class="hljs-comment">/* it&#x27;s not 100% clear how url and format should be highlighted universally */</span>
5959
<span class="hljs-comment">/* src: url(&quot;/fonts/OpenSans-Regular-webfont.woff2&quot;) format(&quot;woff2&quot;),
6060
url(&quot;/fonts/OpenSans-Regular-webfont.woff&quot;) format(&quot;woff&quot;); */</span>

test/markup/less/css_consistency.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ a[href*="example"] {}
5454
font-variant: no-common-ligatures proportional-nums;
5555
font-feature-settings: "liga" 0;
5656
font-variation-settings: "xhgt" 0.7;
57-
/* unicode-range: U+0025-00FF, U+4??; */
57+
unicode-range: U+0025-00FF, U+4??;
5858
/* it's not 100% clear how url and format should be highlighted universally */
5959
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
6060
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */

test/markup/scss/css_consistency.expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<span class="hljs-attribute">font-variant</span>: no-common-ligatures proportional-nums;
5555
<span class="hljs-attribute">font-feature-settings</span>: <span class="hljs-string">&quot;liga&quot;</span> <span class="hljs-number">0</span>;
5656
<span class="hljs-attribute">font-variation-settings</span>: <span class="hljs-string">&quot;xhgt&quot;</span> <span class="hljs-number">0.7</span>;
57-
<span class="hljs-comment">/* unicode-range: U+0025-00FF, U+4??; */</span>
57+
<span class="hljs-attribute">unicode-range</span>: <span class="hljs-number">U+0025-00FF</span>, <span class="hljs-number">U+4??</span>;
5858
<span class="hljs-comment">/* it&#x27;s not 100% clear how url and format should be highlighted universally */</span>
5959
<span class="hljs-comment">/* src: url(&quot;/fonts/OpenSans-Regular-webfont.woff2&quot;) format(&quot;woff2&quot;),
6060
url(&quot;/fonts/OpenSans-Regular-webfont.woff&quot;) format(&quot;woff&quot;); */</span>

test/markup/scss/css_consistency.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ a[href*="example"] {}
5454
font-variant: no-common-ligatures proportional-nums;
5555
font-feature-settings: "liga" 0;
5656
font-variation-settings: "xhgt" 0.7;
57-
/* unicode-range: U+0025-00FF, U+4??; */
57+
unicode-range: U+0025-00FF, U+4??;
5858
/* it's not 100% clear how url and format should be highlighted universally */
5959
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
6060
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */

test/markup/stylus/css_consistency.expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<span class="hljs-attribute">font-variant</span>: no-common-ligatures proportional-nums;
5555
<span class="hljs-attribute">font-feature-settings</span>: <span class="hljs-string">&quot;liga&quot;</span> <span class="hljs-number">0</span>;
5656
<span class="hljs-attribute">font-variation-settings</span>: <span class="hljs-string">&quot;xhgt&quot;</span> <span class="hljs-number">0.7</span>;
57-
<span class="hljs-comment">/* unicode-range: U+0025-00FF, U+4??; */</span>
57+
<span class="hljs-attribute">unicode-range</span>: U+<span class="hljs-number">0025</span>-<span class="hljs-number">00</span>FF, U+<span class="hljs-number">4</span>??;
5858
<span class="hljs-comment">/* it&#x27;s not 100% clear how url and format should be highlighted universally */</span>
5959
<span class="hljs-comment">/* src: url(&quot;/fonts/OpenSans-Regular-webfont.woff2&quot;) format(&quot;woff2&quot;),
6060
url(&quot;/fonts/OpenSans-Regular-webfont.woff&quot;) format(&quot;woff&quot;); */</span>

test/markup/stylus/css_consistency.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ a[href*="example"] {}
5454
font-variant: no-common-ligatures proportional-nums;
5555
font-feature-settings: "liga" 0;
5656
font-variation-settings: "xhgt" 0.7;
57-
/* unicode-range: U+0025-00FF, U+4??; */
57+
unicode-range: U+0025-00FF, U+4??;
5858
/* it's not 100% clear how url and format should be highlighted universally */
5959
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
6060
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */

0 commit comments

Comments
 (0)