Skip to content

Commit a667cde

Browse files
authored
fix(rust) emoji supported in single quote strings (#4156)
1 parent 55b0deb commit a667cde

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CAVEATS / POTENTIALLY BREAKING CHANGES
77

88
Core Grammars:
99

10+
- fix(rust) - adds emoji support in single quote strings [joshgoebel][]
1011
- fix(apache) - support line continuation via `\` [Josh Goebel][]
1112
- fix(makefile) - allow strings inside `$()` expressions [aneesh98][]
1213
- enh(arcade) updated to ArcGIS Arcade version 1.29 [Kristian Ekenes][]

src/languages/rust.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,19 @@ export default function(hljs) {
199199
illegal: null
200200
}),
201201
{
202-
className: 'string',
202+
scope: 'string',
203203
variants: [
204204
{ begin: /b?r(#*)"(.|\n)*?"\1(?!#)/ },
205-
{ begin: /b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/ }
205+
{
206+
begin: /b?'/,
207+
end: /'/,
208+
contains: [
209+
{
210+
scope: "char.escape",
211+
match: /\\(\w|x\w{2}|u\w{4}|U\w{8})/
212+
}
213+
]
214+
}
206215
]
207216
},
208217
{

test/markup/rust/strings.expect.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<span class="hljs-string">&#x27;a&#x27;</span>;
2-
<span class="hljs-string">&#x27;\n&#x27;</span>;
3-
<span class="hljs-string">&#x27;\x1A&#x27;</span>;
4-
<span class="hljs-string">&#x27;\u12AS&#x27;</span>;
5-
<span class="hljs-string">&#x27;\U1234ASDF&#x27;</span>;
2+
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\n</span>&#x27;</span>;
3+
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\x</span>1A&#x27;</span>;
4+
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\u</span>12AS&#x27;</span>;
5+
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\U</span>1234ASDF&#x27;</span>;
66
<span class="hljs-string">b&#x27;a&#x27;</span>;
77

88
<span class="hljs-string">&quot;hello&quot;</span>;

0 commit comments

Comments
 (0)