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