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(rust) emoji supported in single quote strings #4156

Merged
merged 4 commits into from
Dec 14, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading