Skip to content

Commit

Permalink
enh(rust) Highlight raw byte string literals correctly (#3173)
Browse files Browse the repository at this point in the history
* Fix highlighting for rust raw byte string literals
* Add tests for rust raw byte string literals
* Update rust/strings.expect.txt
  • Loading branch information
nico-abram committed May 2, 2021
1 parent 02fab27 commit a08a868
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Grammars:
- enh(haskell) add support for NumericUnderscores (#3150) [Martijn Bastiaan][]
- enh(haskell) add support for HexFloatLiterals (#3150) [Martijn Bastiaan][]
- fix(c,cpp) allow declaring multiple functions and (for C++) parenthetical initializers (#3155) [Erik Demaine][]
- enh(rust) highlight raw byte string literals correctly (#3173) [Nico Abram][]

New Languages:

Expand Down Expand Up @@ -120,6 +121,7 @@ Dev Improvements:
[Jared Luboff]: https://github.com/jaredlll08
[NullVoxPopuli]: https://github.com/NullVoxPopuli
[Mike Watling]: https://github.com/Pickysaurus
[Nico Abram]:https://github.com/nico-abram


## Version 10.7.1
Expand Down
2 changes: 1 addition & 1 deletion src/languages/rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default function(hljs) {
className: 'string',
variants: [
{
begin: /r(#*)"(.|\n)*?"\1(?!#)/
begin: /b?r(#*)"(.|\n)*?"\1(?!#)/
},
{
begin: /b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/
Expand Down
4 changes: 4 additions & 0 deletions test/markup/rust/strings.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
<span class="hljs-string">r###&quot;world&quot;###</span>;
<span class="hljs-string">r##&quot; &quot;###
&quot;# &quot;##</span>;

<span class="hljs-string">br&quot; &quot;</span>;
<span class="hljs-string">br#&quot;hello&quot;#</span>;
<span class="hljs-string">br##&quot;foo&quot;##</span>;
4 changes: 4 additions & 0 deletions test/markup/rust/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ r"hello";
r###"world"###;
r##" "###
"# "##;

br" ";
br#"hello"#;
br##"foo"##;

0 comments on commit a08a868

Please sign in to comment.