1 | (function (Prism) {
|
2 | Prism.languages.crystal = Prism.languages.extend('ruby', {
|
3 | 'keyword': [
|
4 | /\b(?:__DIR__|__END_LINE__|__FILE__|__LINE__|abstract|alias|annotation|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|ptr|require|rescue|return|select|self|sizeof|struct|super|then|type|typeof|undef|uninitialized|union|unless|until|when|while|with|yield)\b/,
|
5 | {
|
6 | pattern: /(\.\s*)(?:is_a|responds_to)\?/,
|
7 | lookbehind: true
|
8 | }
|
9 | ],
|
10 | 'number': /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/,
|
11 | 'operator': [
|
12 | /->/,
|
13 | Prism.languages.ruby.operator,
|
14 | ],
|
15 | 'punctuation': /[(){}[\].,;\\]/,
|
16 | });
|
17 |
|
18 | Prism.languages.insertBefore('crystal', 'string-literal', {
|
19 | 'attribute': {
|
20 | pattern: /@\[.*?\]/,
|
21 | inside: {
|
22 | 'delimiter': {
|
23 | pattern: /^@\[|\]$/,
|
24 | alias: 'punctuation'
|
25 | },
|
26 | 'attribute': {
|
27 | pattern: /^(\s*)\w+/,
|
28 | lookbehind: true,
|
29 | alias: 'class-name'
|
30 | },
|
31 | 'args': {
|
32 | pattern: /\S(?:[\s\S]*\S)?/,
|
33 | inside: Prism.languages.crystal
|
34 | },
|
35 | }
|
36 | },
|
37 | 'expansion': {
|
38 | pattern: /\{(?:\{.*?\}|%.*?%)\}/,
|
39 | inside: {
|
40 | 'content': {
|
41 | pattern: /^(\{.)[\s\S]+(?=.\}$)/,
|
42 | lookbehind: true,
|
43 | inside: Prism.languages.crystal
|
44 | },
|
45 | 'delimiter': {
|
46 | pattern: /^\{[\{%]|[\}%]\}$/,
|
47 | alias: 'operator'
|
48 | }
|
49 | }
|
50 | },
|
51 | 'char': {
|
52 | pattern: /'(?:[^\\\r\n]{1,2}|\\(?:.|u(?:[A-Fa-f0-9]{1,4}|\{[A-Fa-f0-9]{1,6}\})))'/,
|
53 | greedy: true
|
54 | }
|
55 | });
|
56 |
|
57 | }(Prism));
|