diff --git a/CHANGES.md b/CHANGES.md
index 69d6f1fc39..1981ae91b8 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -21,6 +21,7 @@ Core Grammars:
- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][]
- enh(php) support single line and hash comments in attributes, constructor and functions [Antoine Musso][]
- enh(json) add json5 support [Kerry Shetline][]
+- fix(css) `unicode-range` parsing, issue #4253 [Kerry Shetline][]
Documentation:
@@ -39,15 +40,14 @@ CONTRIBUTORS
[Chris Wilson]: https://github.com/sushicw
[Antoine Musso]: https://github.com/hashar
[Chester Moses]: https://github.com/Chester-Moses-HCL
+[Kerry Shetline]: https://github.com/kshetline
[SungHyun Kim]: https://github.com/witch-factory
[Adam Lui]: https://github.com/adamlui
[Sebastiaan Speck]: https://github.com/sebastiaanspeck
[Filip Hoffmann]: https://github.com/folospior
-[Kerry Shetline]: https://github.com/kshetline
[Twineee1]: https://github.com/Twineee1
[hbgl]: https://github.com/hbgl
-
## Version 11.11.1
- Fixes regression with Rust grammar.
diff --git a/src/languages/css.js b/src/languages/css.js
index e76259c266..9ae5d86e5e 100644
--- a/src/languages/css.js
+++ b/src/languages/css.js
@@ -73,9 +73,10 @@ export default function(hljs) {
modes.HEXCOLOR,
modes.IMPORTANT,
modes.CSS_NUMBER_MODE,
+ modes.UNICODE_RANGE,
...STRINGS,
// needed to highlight these as strings and to avoid issues with
- // illegal characters that might be inside urls that would tigger the
+ // illegal characters that might be inside urls that would trigger the
// languages illegal stack
{
begin: /(url|data-uri)\(/,
diff --git a/src/languages/less.js b/src/languages/less.js
index c6a17ad79c..31d0ec79d8 100644
--- a/src/languages/less.js
+++ b/src/languages/less.js
@@ -67,6 +67,7 @@ export default function(hljs) {
excludeEnd: true
}
},
+ modes.UNICODE_RANGE,
modes.HEXCOLOR,
PARENS_MODE,
IDENT_MODE('variable', '@@?' + IDENT_RE, 10),
@@ -177,7 +178,7 @@ export default function(hljs) {
MIXIN_GUARD_MODE,
IDENT_MODE('keyword', 'all\\b'),
IDENT_MODE('variable', '@\\{' + IDENT_RE + '\\}'), // otherwise it’s identified as tag
-
+
{
begin: '\\b(' + css.TAGS.join('|') + ')\\b',
className: 'selector-tag'
diff --git a/src/languages/lib/css-shared.js b/src/languages/lib/css-shared.js
index 3193ae3d26..381d984d1e 100644
--- a/src/languages/lib/css-shared.js
+++ b/src/languages/lib/css-shared.js
@@ -9,6 +9,10 @@ export const MODES = (hljs) => {
scope: 'number',
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
},
+ UNICODE_RANGE: {
+ scope: 'number',
+ begin: /\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,4}(-[0-9A-Fa-f][0-9A-Fa-f]{0,4})?/
+ },
FUNCTION_DISPATCH: {
className: "built_in",
begin: /[\w-]+(?=\()/
@@ -777,6 +781,7 @@ export const ATTRIBUTES = [
'transition-timing-function',
'translate',
'unicode-bidi',
+ 'unicode-range',
'user-modify',
'user-select',
'vector-effect',
diff --git a/src/languages/scss.js b/src/languages/scss.js
index 0eaf922955..5c16c4dff1 100644
--- a/src/languages/scss.js
+++ b/src/languages/scss.js
@@ -79,6 +79,7 @@ export default function(hljs) {
VARIABLE,
modes.HEXCOLOR,
modes.CSS_NUMBER_MODE,
+ modes.UNICODE_RANGE,
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE,
modes.IMPORTANT,
diff --git a/src/languages/stylus.js b/src/languages/stylus.js
index f680f90c7d..34747708f1 100644
--- a/src/languages/stylus.js
+++ b/src/languages/stylus.js
@@ -148,6 +148,7 @@ export default function(hljs) {
VARIABLE,
hljs.APOS_STRING_MODE,
modes.CSS_NUMBER_MODE,
+ modes.UNICODE_RANGE,
hljs.QUOTE_STRING_MODE
]
}
diff --git a/test/markup/css/css_consistency.expect.txt b/test/markup/css/css_consistency.expect.txt
index 93690630c5..2475b9b8ad 100644
--- a/test/markup/css/css_consistency.expect.txt
+++ b/test/markup/css/css_consistency.expect.txt
@@ -54,7 +54,7 @@
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
-
+ unicode-range: U+0025-00FF, U+4??;
diff --git a/test/markup/css/css_consistency.txt b/test/markup/css/css_consistency.txt
index fdf6529313..5d086f5b5c 100644
--- a/test/markup/css/css_consistency.txt
+++ b/test/markup/css/css_consistency.txt
@@ -54,7 +54,7 @@ a[href*="example"] {}
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
- /* unicode-range: U+0025-00FF, U+4??; */
+ unicode-range: U+0025-00FF, U+4??;
/* it's not 100% clear how url and format should be highlighted universally */
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */
diff --git a/test/markup/less/css_consistency.expect.txt b/test/markup/less/css_consistency.expect.txt
index 93690630c5..2475b9b8ad 100644
--- a/test/markup/less/css_consistency.expect.txt
+++ b/test/markup/less/css_consistency.expect.txt
@@ -54,7 +54,7 @@
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
-
+ unicode-range: U+0025-00FF, U+4??;
diff --git a/test/markup/less/css_consistency.txt b/test/markup/less/css_consistency.txt
index fdf6529313..5d086f5b5c 100644
--- a/test/markup/less/css_consistency.txt
+++ b/test/markup/less/css_consistency.txt
@@ -54,7 +54,7 @@ a[href*="example"] {}
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
- /* unicode-range: U+0025-00FF, U+4??; */
+ unicode-range: U+0025-00FF, U+4??;
/* it's not 100% clear how url and format should be highlighted universally */
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */
diff --git a/test/markup/scss/css_consistency.expect.txt b/test/markup/scss/css_consistency.expect.txt
index ccbab101d1..aba76711e5 100644
--- a/test/markup/scss/css_consistency.expect.txt
+++ b/test/markup/scss/css_consistency.expect.txt
@@ -54,7 +54,7 @@
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
-
+ unicode-range: U+0025-00FF, U+4??;
diff --git a/test/markup/scss/css_consistency.txt b/test/markup/scss/css_consistency.txt
index fdf6529313..5d086f5b5c 100644
--- a/test/markup/scss/css_consistency.txt
+++ b/test/markup/scss/css_consistency.txt
@@ -54,7 +54,7 @@ a[href*="example"] {}
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
- /* unicode-range: U+0025-00FF, U+4??; */
+ unicode-range: U+0025-00FF, U+4??;
/* it's not 100% clear how url and format should be highlighted universally */
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */
diff --git a/test/markup/stylus/css_consistency.expect.txt b/test/markup/stylus/css_consistency.expect.txt
index ccbab101d1..5c9b4378d1 100644
--- a/test/markup/stylus/css_consistency.expect.txt
+++ b/test/markup/stylus/css_consistency.expect.txt
@@ -54,7 +54,7 @@
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
-
+ unicode-range: U+0025-00FF, U+4??;
diff --git a/test/markup/stylus/css_consistency.txt b/test/markup/stylus/css_consistency.txt
index fdf6529313..5d086f5b5c 100644
--- a/test/markup/stylus/css_consistency.txt
+++ b/test/markup/stylus/css_consistency.txt
@@ -54,7 +54,7 @@ a[href*="example"] {}
font-variant: no-common-ligatures proportional-nums;
font-feature-settings: "liga" 0;
font-variation-settings: "xhgt" 0.7;
- /* unicode-range: U+0025-00FF, U+4??; */
+ unicode-range: U+0025-00FF, U+4??;
/* it's not 100% clear how url and format should be highlighted universally */
/* src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff"); */