cassandra-web 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,475 @@
1
+ /* http://prismjs.com/download.html?themes=prism-okaidia&languages=css+scss+sql */
2
+ self = (typeof window !== 'undefined')
3
+ ? window // if in browser
4
+ : (
5
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
6
+ ? self // if in worker
7
+ : {} // if in node js
8
+ );
9
+
10
+ /**
11
+ * Prism: Lightweight, robust, elegant syntax highlighting
12
+ * MIT license http://www.opensource.org/licenses/mit-license.php/
13
+ * @author Lea Verou http://lea.verou.me
14
+ */
15
+
16
+ var Prism = (function(){
17
+
18
+ // Private helper vars
19
+ var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
20
+
21
+ var _ = self.Prism = {
22
+ util: {
23
+ encode: function (tokens) {
24
+ if (tokens instanceof Token) {
25
+ return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
26
+ } else if (_.util.type(tokens) === 'Array') {
27
+ return tokens.map(_.util.encode);
28
+ } else {
29
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
30
+ }
31
+ },
32
+
33
+ type: function (o) {
34
+ return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
35
+ },
36
+
37
+ // Deep clone a language definition (e.g. to extend it)
38
+ clone: function (o) {
39
+ var type = _.util.type(o);
40
+
41
+ switch (type) {
42
+ case 'Object':
43
+ var clone = {};
44
+
45
+ for (var key in o) {
46
+ if (o.hasOwnProperty(key)) {
47
+ clone[key] = _.util.clone(o[key]);
48
+ }
49
+ }
50
+
51
+ return clone;
52
+
53
+ case 'Array':
54
+ return o.slice();
55
+ }
56
+
57
+ return o;
58
+ }
59
+ },
60
+
61
+ languages: {
62
+ extend: function (id, redef) {
63
+ var lang = _.util.clone(_.languages[id]);
64
+
65
+ for (var key in redef) {
66
+ lang[key] = redef[key];
67
+ }
68
+
69
+ return lang;
70
+ },
71
+
72
+ // Insert a token before another token in a language literal
73
+ insertBefore: function (inside, before, insert, root) {
74
+ root = root || _.languages;
75
+ var grammar = root[inside];
76
+ var ret = {};
77
+
78
+ for (var token in grammar) {
79
+
80
+ if (grammar.hasOwnProperty(token)) {
81
+
82
+ if (token == before) {
83
+
84
+ for (var newToken in insert) {
85
+
86
+ if (insert.hasOwnProperty(newToken)) {
87
+ ret[newToken] = insert[newToken];
88
+ }
89
+ }
90
+ }
91
+
92
+ ret[token] = grammar[token];
93
+ }
94
+ }
95
+
96
+ return root[inside] = ret;
97
+ },
98
+
99
+ // Traverse a language definition with Depth First Search
100
+ DFS: function(o, callback) {
101
+ for (var i in o) {
102
+ callback.call(o, i, o[i]);
103
+
104
+ if (_.util.type(o) === 'Object') {
105
+ _.languages.DFS(o[i], callback);
106
+ }
107
+ }
108
+ }
109
+ },
110
+
111
+ highlightAll: function(async, callback) {
112
+ var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
113
+
114
+ for (var i=0, element; element = elements[i++];) {
115
+ _.highlightElement(element, async === true, callback);
116
+ }
117
+ },
118
+
119
+ highlightElement: function(element, async, callback) {
120
+ // Find language
121
+ var language, grammar, parent = element;
122
+
123
+ while (parent && !lang.test(parent.className)) {
124
+ parent = parent.parentNode;
125
+ }
126
+
127
+ if (parent) {
128
+ language = (parent.className.match(lang) || [,''])[1];
129
+ grammar = _.languages[language];
130
+ }
131
+
132
+ if (!grammar) {
133
+ return;
134
+ }
135
+
136
+ // Set language on the element, if not present
137
+ element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
138
+
139
+ // Set language on the parent, for styling
140
+ parent = element.parentNode;
141
+
142
+ if (/pre/i.test(parent.nodeName)) {
143
+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
144
+ }
145
+
146
+ var code = element.textContent;
147
+
148
+ if(!code) {
149
+ return;
150
+ }
151
+
152
+ var env = {
153
+ element: element,
154
+ language: language,
155
+ grammar: grammar,
156
+ code: code
157
+ };
158
+
159
+ _.hooks.run('before-highlight', env);
160
+
161
+ if (async && self.Worker) {
162
+ var worker = new Worker(_.filename);
163
+
164
+ worker.onmessage = function(evt) {
165
+ env.highlightedCode = Token.stringify(JSON.parse(evt.data), language);
166
+
167
+ _.hooks.run('before-insert', env);
168
+
169
+ env.element.innerHTML = env.highlightedCode;
170
+
171
+ callback && callback.call(env.element);
172
+ _.hooks.run('after-highlight', env);
173
+ };
174
+
175
+ worker.postMessage(JSON.stringify({
176
+ language: env.language,
177
+ code: env.code
178
+ }));
179
+ }
180
+ else {
181
+ env.highlightedCode = _.highlight(env.code, env.grammar, env.language)
182
+
183
+ _.hooks.run('before-insert', env);
184
+
185
+ env.element.innerHTML = env.highlightedCode;
186
+
187
+ callback && callback.call(element);
188
+
189
+ _.hooks.run('after-highlight', env);
190
+ }
191
+ },
192
+
193
+ highlight: function (text, grammar, language) {
194
+ var tokens = _.tokenize(text, grammar);
195
+ return Token.stringify(_.util.encode(tokens), language);
196
+ },
197
+
198
+ tokenize: function(text, grammar, language) {
199
+ var Token = _.Token;
200
+
201
+ var strarr = [text];
202
+
203
+ var rest = grammar.rest;
204
+
205
+ if (rest) {
206
+ for (var token in rest) {
207
+ grammar[token] = rest[token];
208
+ }
209
+
210
+ delete grammar.rest;
211
+ }
212
+
213
+ tokenloop: for (var token in grammar) {
214
+ if(!grammar.hasOwnProperty(token) || !grammar[token]) {
215
+ continue;
216
+ }
217
+
218
+ var patterns = grammar[token];
219
+ patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
220
+
221
+ for (var j = 0; j < patterns.length; ++j) {
222
+ var pattern = patterns[j],
223
+ inside = pattern.inside,
224
+ lookbehind = !!pattern.lookbehind,
225
+ lookbehindLength = 0,
226
+ alias = pattern.alias;
227
+
228
+ pattern = pattern.pattern || pattern;
229
+
230
+ for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop
231
+
232
+ var str = strarr[i];
233
+
234
+ if (strarr.length > text.length) {
235
+ // Something went terribly wrong, ABORT, ABORT!
236
+ break tokenloop;
237
+ }
238
+
239
+ if (str instanceof Token) {
240
+ continue;
241
+ }
242
+
243
+ pattern.lastIndex = 0;
244
+
245
+ var match = pattern.exec(str);
246
+
247
+ if (match) {
248
+ if(lookbehind) {
249
+ lookbehindLength = match[1].length;
250
+ }
251
+
252
+ var from = match.index - 1 + lookbehindLength,
253
+ match = match[0].slice(lookbehindLength),
254
+ len = match.length,
255
+ to = from + len,
256
+ before = str.slice(0, from + 1),
257
+ after = str.slice(to + 1);
258
+
259
+ var args = [i, 1];
260
+
261
+ if (before) {
262
+ args.push(before);
263
+ }
264
+
265
+ var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias);
266
+
267
+ args.push(wrapped);
268
+
269
+ if (after) {
270
+ args.push(after);
271
+ }
272
+
273
+ Array.prototype.splice.apply(strarr, args);
274
+ }
275
+ }
276
+ }
277
+ }
278
+
279
+ return strarr;
280
+ },
281
+
282
+ hooks: {
283
+ all: {},
284
+
285
+ add: function (name, callback) {
286
+ var hooks = _.hooks.all;
287
+
288
+ hooks[name] = hooks[name] || [];
289
+
290
+ hooks[name].push(callback);
291
+ },
292
+
293
+ run: function (name, env) {
294
+ var callbacks = _.hooks.all[name];
295
+
296
+ if (!callbacks || !callbacks.length) {
297
+ return;
298
+ }
299
+
300
+ for (var i=0, callback; callback = callbacks[i++];) {
301
+ callback(env);
302
+ }
303
+ }
304
+ }
305
+ };
306
+
307
+ var Token = _.Token = function(type, content, alias) {
308
+ this.type = type;
309
+ this.content = content;
310
+ this.alias = alias;
311
+ };
312
+
313
+ Token.stringify = function(o, language, parent) {
314
+ if (typeof o == 'string') {
315
+ return o;
316
+ }
317
+
318
+ if (Object.prototype.toString.call(o) == '[object Array]') {
319
+ return o.map(function(element) {
320
+ return Token.stringify(element, language, o);
321
+ }).join('');
322
+ }
323
+
324
+ var env = {
325
+ type: o.type,
326
+ content: Token.stringify(o.content, language, parent),
327
+ tag: 'span',
328
+ classes: ['token', o.type],
329
+ attributes: {},
330
+ language: language,
331
+ parent: parent
332
+ };
333
+
334
+ if (env.type == 'comment') {
335
+ env.attributes['spellcheck'] = 'true';
336
+ }
337
+
338
+ if (o.alias) {
339
+ var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
340
+ Array.prototype.push.apply(env.classes, aliases);
341
+ }
342
+
343
+ _.hooks.run('wrap', env);
344
+
345
+ var attributes = '';
346
+
347
+ for (var name in env.attributes) {
348
+ attributes += name + '="' + (env.attributes[name] || '') + '"';
349
+ }
350
+
351
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
352
+
353
+ };
354
+
355
+ if (!self.document) {
356
+ if (!self.addEventListener) {
357
+ // in Node.js
358
+ return self.Prism;
359
+ }
360
+ // In worker
361
+ self.addEventListener('message', function(evt) {
362
+ var message = JSON.parse(evt.data),
363
+ lang = message.language,
364
+ code = message.code;
365
+
366
+ self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang]))));
367
+ self.close();
368
+ }, false);
369
+
370
+ return self.Prism;
371
+ }
372
+
373
+ // Get current script and highlight
374
+ var script = document.getElementsByTagName('script');
375
+
376
+ script = script[script.length - 1];
377
+
378
+ if (script) {
379
+ _.filename = script.src;
380
+
381
+ if (document.addEventListener && !script.hasAttribute('data-manual')) {
382
+ document.addEventListener('DOMContentLoaded', _.highlightAll);
383
+ }
384
+ }
385
+
386
+ return self.Prism;
387
+
388
+ })();
389
+
390
+ if (typeof module !== 'undefined' && module.exports) {
391
+ module.exports = Prism;
392
+ }
393
+ ;
394
+ Prism.languages.css = {
395
+ 'comment': /\/\*[\w\W]*?\*\//g,
396
+ 'atrule': {
397
+ pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi,
398
+ inside: {
399
+ 'punctuation': /[;:]/g
400
+ }
401
+ },
402
+ 'url': /url\((["']?).*?\1\)/gi,
403
+ 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/g,
404
+ 'property': /(\b|\B)[\w-]+(?=\s*:)/ig,
405
+ 'string': /("|')(\\?.)*?\1/g,
406
+ 'important': /\B!important\b/gi,
407
+ 'punctuation': /[\{\};:]/g,
408
+ 'function': /[-a-z0-9]+(?=\()/ig
409
+ };
410
+
411
+ if (Prism.languages.markup) {
412
+ Prism.languages.insertBefore('markup', 'tag', {
413
+ 'style': {
414
+ pattern: /<style[\w\W]*?>[\w\W]*?<\/style>/ig,
415
+ inside: {
416
+ 'tag': {
417
+ pattern: /<style[\w\W]*?>|<\/style>/ig,
418
+ inside: Prism.languages.markup.tag.inside
419
+ },
420
+ rest: Prism.languages.css
421
+ }
422
+ }
423
+ });
424
+ };
425
+ Prism.languages.scss = Prism.languages.extend('css', {
426
+ 'comment': {
427
+ pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,
428
+ lookbehind: true
429
+ },
430
+ // aturle is just the @***, not the entire rule (to highlight var & stuffs)
431
+ // + add ability to highlight number & unit for media queries
432
+ 'atrule': /@[\w-]+(?=\s+(\(|\{|;))/gi,
433
+ // url, compassified
434
+ 'url': /([-a-z]+-)*url(?=\()/gi,
435
+ // CSS selector regex is not appropriate for Sass
436
+ // since there can be lot more things (var, @ directive, nesting..)
437
+ // a selector must start at the end of a property or after a brace (end of other rules or nesting)
438
+ // it can contain some caracters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
439
+ // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
440
+ // can "pass" as a selector- e.g: proper#{$erty})
441
+ // this one was ard to do, so please be careful if you edit this one :)
442
+ 'selector': /([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|\#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/gm
443
+ });
444
+
445
+ Prism.languages.insertBefore('scss', 'atrule', {
446
+ 'keyword': /@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i
447
+ });
448
+
449
+ Prism.languages.insertBefore('scss', 'property', {
450
+ // var and interpolated vars
451
+ 'variable': /((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i
452
+ });
453
+
454
+ Prism.languages.insertBefore('scss', 'ignore', {
455
+ 'placeholder': /%[-_\w]+/i,
456
+ 'statement': /\B!(default|optional)\b/gi,
457
+ 'boolean': /\b(true|false)\b/g,
458
+ 'null': /\b(null)\b/g,
459
+ 'operator': /\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|\%)\s+/g
460
+ });
461
+ ;
462
+ Prism.languages.cql= {
463
+ 'comment': {
464
+ pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|((--)|(\/\/)|#).*?(\r?\n|$))/g,
465
+ lookbehind: true
466
+ },
467
+ 'string' : /("|')(\\?[\s\S])*?\1/g,
468
+ 'keyword' : /\b(ADD|ALL|ALTER|AND|ANY|APPLY|AS|ASC|AUTHORIZE|BATCH|BEGIN|BY|CLUSTERING|COLUMNFAMILY|COMPACT|CONSISTENCY|CONTAINS|COUNT|CREATE|CUSTOM|DELETE|DESC|DROP|DISTINCT|EXISTS|FROM|GRANT|IF|IN|INDEX|INSERT|INTO|KEY|KEYSPACE|LEVEL|LIMIT|MODIFY|NORECURSIVE|NOSUPERUSER|NOT|OF|ON|ORDER|PERMISSION|PERMISSIONS|PRIMARY|REVOKE|SCHEMA|SELECT|STATIC|STORAGE|SUPERUSER|TABLE|TOKEN|TRIGGER|TRUNCATE|TTL|TYPE|UPDATE|USE|USER|USERS|USING|VALUES|WHERE|WITH|WRITETIME|ASCII|BIGINT|BLOB|BOOLEAN|COUNTER|DECIMAL|DOUBLE|FLOAT|INET|INT|TEXT|TIMESTAMP|TIMEUUID|UUID|VARCHAR|VARINT|LIST|SET|MAP|NAN|INFINITY)\b/gi,
469
+ 'boolean' : /\b(TRUE|FALSE|NULL)\b/gi,
470
+ 'number' : /\b-?(0x)?\d*\.?[\da-f]+\b/g,
471
+ 'operator' : /[-+]{1}|!|=?&lt;|=?&gt;|={1}|(&amp;){1,2}|\|?\||\?|\*|\//gi,
472
+ 'ignore' : /&(lt|gt|amp);/gi,
473
+ 'punctuation' : /[;[\]{}:()`,.]/g
474
+ };
475
+ ;