Skip to content

Commit 2db4c16

Browse files
committed
fix(rust) prevent symbol from gobbling strings
1 parent 93e6358 commit 2db4c16

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/languages/rust.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ export default function(hljs) {
200200
}),
201201
{
202202
className: 'symbol',
203-
begin: /'[a-zA-Z_][a-zA-Z0-9_]*/
203+
// negative lookahead to avoid matching `'`
204+
begin: /'[a-zA-Z_][a-zA-Z0-9_]*(?!')/
204205
},
205206
{
206207
scope: 'string',

test/markup/rust/strings.expect.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\x</span>1A&#x27;</span>;
44
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\u</span>12AS&#x27;</span>;
55
<span class="hljs-string">&#x27;<span class="hljs-char escape_">\U</span>1234ASDF&#x27;</span>;
6+
<span class="hljs-string">&#x27;😭&#x27;</span>;
67
<span class="hljs-string">b&#x27;a&#x27;</span>;
78

89
<span class="hljs-string">&quot;hello&quot;</span>;
@@ -12,6 +13,7 @@
1213
<span class="hljs-string">r###&quot;world&quot;###</span>;
1314
<span class="hljs-string">r##&quot; &quot;###
1415
&quot;# &quot;##</span>;
16+
<span class="hljs-string">&quot;😭😭😭😭&quot;</span>;
1517

1618
<span class="hljs-string">br&quot; &quot;</span>;
1719
<span class="hljs-string">br#&quot;hello&quot;#</span>;

test/markup/rust/strings.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'\x1A';
44
'\u12AS';
55
'\U1234ASDF';
6+
'😭';
67
b'a';
78

89
"hello";
@@ -12,6 +13,7 @@ r"hello";
1213
r###"world"###;
1314
r##" "###
1415
"# "##;
16+
"😭😭😭😭";
1517

1618
br" ";
1719
br#"hello"#;

0 commit comments

Comments
 (0)