Skip to content

Commit

Permalink
fix(rust) emoji supported in single quote strings (#4156)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel authored Dec 14, 2024
1 parent 55b0deb commit a667cde
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CAVEATS / POTENTIALLY BREAKING CHANGES

Core Grammars:

- fix(rust) - adds emoji support in single quote strings [joshgoebel][]
- fix(apache) - support line continuation via `\` [Josh Goebel][]
- fix(makefile) - allow strings inside `$()` expressions [aneesh98][]
- enh(arcade) updated to ArcGIS Arcade version 1.29 [Kristian Ekenes][]
Expand Down
13 changes: 11 additions & 2 deletions src/languages/rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,19 @@ export default function(hljs) {
illegal: null
}),
{
className: 'string',
scope: 'string',
variants: [
{ begin: /b?r(#*)"(.|\n)*?"\1(?!#)/ },
{ begin: /b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/ }
{
begin: /b?'/,
end: /'/,
contains: [
{
scope: "char.escape",
match: /\\(\w|x\w{2}|u\w{4}|U\w{8})/
}
]
}
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions test/markup/rust/strings.expect.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<span class="hljs-string">&#x27;a&#x27;</span>;
<span class="hljs-string">&#x27;\n&#x27;</span>;
<span class="hljs-string">&#x27;\x1A&#x27;</span>;
<span class="hljs-string">&#x27;\u12AS&#x27;</span>;
<span class="hljs-string">&#x27;\U1234ASDF&#x27;</span>;
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\n</span>&#x27;</span>;
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\x</span>1A&#x27;</span>;
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\u</span>12AS&#x27;</span>;
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\U</span>1234ASDF&#x27;</span>;
<span class="hljs-string">b&#x27;a&#x27;</span>;

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

0 comments on commit a667cde

Please sign in to comment.