1 | Prism.languages.elixir = {
|
---|
2 | 'doc': {
|
---|
3 | pattern: /@(?:doc|moduledoc)\s+(?:("""|''')[\s\S]*?\1|("|')(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2)/,
|
---|
4 | inside: {
|
---|
5 | 'attribute': /^@\w+/,
|
---|
6 | 'string': /['"][\s\S]+/
|
---|
7 | }
|
---|
8 | },
|
---|
9 | 'comment': {
|
---|
10 | pattern: /#.*/,
|
---|
11 | greedy: true
|
---|
12 | },
|
---|
13 | // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
|
---|
14 | 'regex': {
|
---|
15 | pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
|
---|
16 | greedy: true
|
---|
17 | },
|
---|
18 | 'string': [
|
---|
19 | {
|
---|
20 | // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
|
---|
21 | pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|#(?!\{)|[^#\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
|
---|
22 | greedy: true,
|
---|
23 | inside: {
|
---|
24 | // See interpolation below
|
---|
25 | }
|
---|
26 | },
|
---|
27 | {
|
---|
28 | pattern: /("""|''')[\s\S]*?\1/,
|
---|
29 | greedy: true,
|
---|
30 | inside: {
|
---|
31 | // See interpolation below
|
---|
32 | }
|
---|
33 | },
|
---|
34 | {
|
---|
35 | // Multi-line strings are allowed
|
---|
36 | pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
---|
37 | greedy: true,
|
---|
38 | inside: {
|
---|
39 | // See interpolation below
|
---|
40 | }
|
---|
41 | }
|
---|
42 | ],
|
---|
43 | 'atom': {
|
---|
44 | // Look-behind prevents bad highlighting of the :: operator
|
---|
45 | pattern: /(^|[^:]):\w+/,
|
---|
46 | lookbehind: true,
|
---|
47 | alias: 'symbol'
|
---|
48 | },
|
---|
49 | 'module': {
|
---|
50 | pattern: /\b[A-Z]\w*\b/,
|
---|
51 | alias: 'class-name'
|
---|
52 | },
|
---|
53 | // Look-ahead prevents bad highlighting of the :: operator
|
---|
54 | 'attr-name': /\b\w+\??:(?!:)/,
|
---|
55 | 'argument': {
|
---|
56 | // Look-behind prevents bad highlighting of the && operator
|
---|
57 | pattern: /(^|[^&])&\d+/,
|
---|
58 | lookbehind: true,
|
---|
59 | alias: 'variable'
|
---|
60 | },
|
---|
61 | 'attribute': {
|
---|
62 | pattern: /@\w+/,
|
---|
63 | alias: 'variable'
|
---|
64 | },
|
---|
65 | 'function': /\b[_a-zA-Z]\w*[?!]?(?:(?=\s*(?:\.\s*)?\()|(?=\/\d))/,
|
---|
66 | 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
|
---|
67 | 'keyword': /\b(?:after|alias|and|case|catch|cond|def(?:callback|delegate|exception|impl|macro|module|n|np|p|protocol|struct)?|do|else|end|fn|for|if|import|not|or|quote|raise|require|rescue|try|unless|unquote|use|when)\b/,
|
---|
68 | 'boolean': /\b(?:false|nil|true)\b/,
|
---|
69 | 'operator': [
|
---|
70 | /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
|
---|
71 | {
|
---|
72 | // We don't want to match <<
|
---|
73 | pattern: /([^<])<(?!<)/,
|
---|
74 | lookbehind: true
|
---|
75 | },
|
---|
76 | {
|
---|
77 | // We don't want to match >>
|
---|
78 | pattern: /([^>])>(?!>)/,
|
---|
79 | lookbehind: true
|
---|
80 | }
|
---|
81 | ],
|
---|
82 | 'punctuation': /<<|>>|[.,%\[\]{}()]/
|
---|
83 | };
|
---|
84 |
|
---|
85 | Prism.languages.elixir.string.forEach(function (o) {
|
---|
86 | o.inside = {
|
---|
87 | 'interpolation': {
|
---|
88 | pattern: /#\{[^}]+\}/,
|
---|
89 | inside: {
|
---|
90 | 'delimiter': {
|
---|
91 | pattern: /^#\{|\}$/,
|
---|
92 | alias: 'punctuation'
|
---|
93 | },
|
---|
94 | rest: Prism.languages.elixir
|
---|
95 | }
|
---|
96 | }
|
---|
97 | };
|
---|
98 | });
|
---|