1 | Prism.languages.livescript = {
|
---|
2 | 'comment': [
|
---|
3 | {
|
---|
4 | pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
|
---|
5 | lookbehind: true
|
---|
6 | },
|
---|
7 | {
|
---|
8 | pattern: /(^|[^\\])#.*/,
|
---|
9 | lookbehind: true
|
---|
10 | }
|
---|
11 | ],
|
---|
12 | 'interpolated-string': {
|
---|
13 | /* Look-behind and look-ahead prevents wrong behavior of the greedy pattern
|
---|
14 | * forcing it to match """-quoted string when it would otherwise match "-quoted first. */
|
---|
15 | pattern: /(^|[^"])("""|")(?:\\[\s\S]|(?!\2)[^\\])*\2(?!")/,
|
---|
16 | lookbehind: true,
|
---|
17 | greedy: true,
|
---|
18 | inside: {
|
---|
19 | 'variable': {
|
---|
20 | pattern: /(^|[^\\])#[a-z_](?:-?[a-z]|[\d_])*/m,
|
---|
21 | lookbehind: true
|
---|
22 | },
|
---|
23 | 'interpolation': {
|
---|
24 | pattern: /(^|[^\\])#\{[^}]+\}/m,
|
---|
25 | lookbehind: true,
|
---|
26 | inside: {
|
---|
27 | 'interpolation-punctuation': {
|
---|
28 | pattern: /^#\{|\}$/,
|
---|
29 | alias: 'variable'
|
---|
30 | }
|
---|
31 | // See rest below
|
---|
32 | }
|
---|
33 | },
|
---|
34 | 'string': /[\s\S]+/
|
---|
35 | }
|
---|
36 | },
|
---|
37 | 'string': [
|
---|
38 | {
|
---|
39 | pattern: /('''|')(?:\\[\s\S]|(?!\1)[^\\])*\1/,
|
---|
40 | greedy: true
|
---|
41 | },
|
---|
42 | {
|
---|
43 | pattern: /<\[[\s\S]*?\]>/,
|
---|
44 | greedy: true
|
---|
45 | },
|
---|
46 | /\\[^\s,;\])}]+/
|
---|
47 | ],
|
---|
48 | 'regex': [
|
---|
49 | {
|
---|
50 | pattern: /\/\/(?:\[[^\r\n\]]*\]|\\.|(?!\/\/)[^\\\[])+\/\/[gimyu]{0,5}/,
|
---|
51 | greedy: true,
|
---|
52 | inside: {
|
---|
53 | 'comment': {
|
---|
54 | pattern: /(^|[^\\])#.*/,
|
---|
55 | lookbehind: true
|
---|
56 | }
|
---|
57 | }
|
---|
58 | },
|
---|
59 | {
|
---|
60 | pattern: /\/(?:\[[^\r\n\]]*\]|\\.|[^/\\\r\n\[])+\/[gimyu]{0,5}/,
|
---|
61 | greedy: true
|
---|
62 | }
|
---|
63 | ],
|
---|
64 | 'keyword': {
|
---|
65 | pattern: /(^|(?!-).)\b(?:break|case|catch|class|const|continue|default|do|else|extends|fallthrough|finally|for(?: ever)?|function|if|implements|it|let|loop|new|null|otherwise|own|return|super|switch|that|then|this|throw|try|unless|until|var|void|when|while|yield)(?!-)\b/m,
|
---|
66 | lookbehind: true
|
---|
67 | },
|
---|
68 | 'keyword-operator': {
|
---|
69 | pattern: /(^|[^-])\b(?:(?:delete|require|typeof)!|(?:and|by|delete|export|from|import(?: all)?|in|instanceof|is(?: not|nt)?|not|of|or|til|to|typeof|with|xor)(?!-)\b)/m,
|
---|
70 | lookbehind: true,
|
---|
71 | alias: 'operator'
|
---|
72 | },
|
---|
73 | 'boolean': {
|
---|
74 | pattern: /(^|[^-])\b(?:false|no|off|on|true|yes)(?!-)\b/m,
|
---|
75 | lookbehind: true
|
---|
76 | },
|
---|
77 | 'argument': {
|
---|
78 | // Don't match .&. nor &&
|
---|
79 | pattern: /(^|(?!\.&\.)[^&])&(?!&)\d*/m,
|
---|
80 | lookbehind: true,
|
---|
81 | alias: 'variable'
|
---|
82 | },
|
---|
83 | 'number': /\b(?:\d+~[\da-z]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[a-z]\w*)?)/i,
|
---|
84 | 'identifier': /[a-z_](?:-?[a-z]|[\d_])*/i,
|
---|
85 | 'operator': [
|
---|
86 | // Spaced .
|
---|
87 | {
|
---|
88 | pattern: /( )\.(?= )/,
|
---|
89 | lookbehind: true
|
---|
90 | },
|
---|
91 | // Full list, in order:
|
---|
92 | // .= .~ .. ...
|
---|
93 | // .&. .^. .<<. .>>. .>>>.
|
---|
94 | // := :: ::=
|
---|
95 | // &&
|
---|
96 | // || |>
|
---|
97 | // < << <<< <<<<
|
---|
98 | // <- <-- <-! <--!
|
---|
99 | // <~ <~~ <~! <~~!
|
---|
100 | // <| <= <?
|
---|
101 | // > >> >= >?
|
---|
102 | // - -- -> -->
|
---|
103 | // + ++
|
---|
104 | // @ @@
|
---|
105 | // % %%
|
---|
106 | // * **
|
---|
107 | // ! != !~=
|
---|
108 | // !~> !~~>
|
---|
109 | // !-> !-->
|
---|
110 | // ~ ~> ~~> ~=
|
---|
111 | // = ==
|
---|
112 | // ^ ^^
|
---|
113 | // / ?
|
---|
114 | /\.(?:[=~]|\.\.?)|\.(?:[&|^]|<<|>>>?)\.|:(?:=|:=?)|&&|\|[|>]|<(?:<<?<?|--?!?|~~?!?|[|=?])?|>[>=?]?|-(?:->?|>)?|\+\+?|@@?|%%?|\*\*?|!(?:~?=|--?>|~?~>)?|~(?:~?>|=)?|==?|\^\^?|[\/?]/
|
---|
115 | ],
|
---|
116 | 'punctuation': /[(){}\[\]|.,:;`]/
|
---|
117 | };
|
---|
118 |
|
---|
119 | Prism.languages.livescript['interpolated-string'].inside['interpolation'].inside.rest = Prism.languages.livescript;
|
---|