Skip to content

Commit efd2417

Browse files
committed
Ensure bracket balance within attributes
1 parent 85b2042 commit efd2417

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

src/languages/rust.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,33 @@ export default function(hljs) {
2525
IDENT_RE,
2626
regex.lookahead(/\s*\(/))
2727
};
28+
const META_STRING = {
29+
className: 'string',
30+
begin: /"/,
31+
end: /"/,
32+
contains: [ hljs.BACKSLASH_ESCAPE ]
33+
};
34+
const META_DELIM_TREE = {
35+
relevance: 0,
36+
variants: [
37+
{
38+
begin: /\(/,
39+
end: /\)/,
40+
},
41+
{
42+
begin: /\[/,
43+
end: /\]/,
44+
},
45+
{
46+
begin: /\{/,
47+
end: /\}/,
48+
},
49+
],
50+
contains: [
51+
'self',
52+
META_STRING,
53+
]
54+
};
2855
const NUMBER_SUFFIX = '([ui](8|16|32|64|128|size)|f(32|64))\?';
2956
const KEYWORDS = [
3057
"abstract",
@@ -246,14 +273,8 @@ export default function(hljs) {
246273
begin: '#!?\\[',
247274
end: '\\]',
248275
contains: [
249-
{
250-
className: 'string',
251-
begin: /"/,
252-
end: /"/,
253-
contains: [
254-
hljs.BACKSLASH_ESCAPE
255-
]
256-
}
276+
META_STRING,
277+
META_DELIM_TREE,
257278
]
258279
},
259280
{

0 commit comments

Comments
 (0)