@cobaltio/cobalt-js 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.github/workflows/npm-publish.yml +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +10 -0
  4. package/cobalt.js +91 -0
  5. package/cobalt.min.js +1 -0
  6. package/docs/Cobalt.html +686 -0
  7. package/docs/cobalt.js.html +142 -0
  8. package/docs/css/bootstrap.min.css +6 -0
  9. package/docs/css/prism.css +138 -0
  10. package/docs/css/prism.min.css +1 -0
  11. package/docs/css/template.min.css +1 -0
  12. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  13. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  14. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  15. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  16. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  17. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  18. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  19. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  20. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  21. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  22. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  23. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  24. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  25. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  26. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  27. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  28. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  29. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  30. package/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  31. package/docs/fonts/glyphicons-halflings-regular.svg +288 -0
  32. package/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  33. package/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  34. package/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  35. package/docs/global.html +662 -0
  36. package/docs/index.html +74 -0
  37. package/docs/js/bootstrap.min.js +7 -0
  38. package/docs/js/clipboard.min.js +7 -0
  39. package/docs/js/jquery.min.js +2 -0
  40. package/docs/js/lunr-data.js +923 -0
  41. package/docs/js/lunr-data.json +923 -0
  42. package/docs/js/lunr.min.js +6 -0
  43. package/docs/js/prism.js +869 -0
  44. package/docs/js/prism.min.js +1 -0
  45. package/docs/js/template.min.js +1 -0
  46. package/docs/list_class.html +128 -0
  47. package/docs/scripts/linenumber.js +25 -0
  48. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  49. package/docs/scripts/prettify/lang-css.js +2 -0
  50. package/docs/scripts/prettify/prettify.js +28 -0
  51. package/docs/styles/jsdoc-default.css +358 -0
  52. package/docs/styles/prettify-jsdoc.css +111 -0
  53. package/docs/styles/prettify-tomorrow.css +132 -0
  54. package/package.json +38 -0
@@ -0,0 +1,869 @@
1
+
2
+ /* **********************************************
3
+ Begin prism-core.js
4
+ ********************************************** */
5
+
6
+ var _self = (typeof window !== 'undefined')
7
+ ? window // if in browser
8
+ : (
9
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
10
+ ? self // if in worker
11
+ : {} // if in node js
12
+ );
13
+
14
+ /**
15
+ * Prism: Lightweight, robust, elegant syntax highlighting
16
+ * MIT license http://www.opensource.org/licenses/mit-license.php/
17
+ * @author Lea Verou http://lea.verou.me
18
+ */
19
+
20
+ var Prism = (function(){
21
+
22
+ // Private helper vars
23
+ var lang = /\blang(?:uage)?-([\w-]+)\b/i;
24
+ var uniqueId = 0;
25
+
26
+ var _ = _self.Prism = {
27
+ manual: _self.Prism && _self.Prism.manual,
28
+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
29
+ util: {
30
+ encode: function (tokens) {
31
+ if (tokens instanceof Token) {
32
+ return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
33
+ } else if (_.util.type(tokens) === 'Array') {
34
+ return tokens.map(_.util.encode);
35
+ } else {
36
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
37
+ }
38
+ },
39
+
40
+ type: function (o) {
41
+ return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
42
+ },
43
+
44
+ objId: function (obj) {
45
+ if (!obj['__id']) {
46
+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
47
+ }
48
+ return obj['__id'];
49
+ },
50
+
51
+ // Deep clone a language definition (e.g. to extend it)
52
+ clone: function (o, visited) {
53
+ var type = _.util.type(o);
54
+ visited = visited || {};
55
+
56
+ switch (type) {
57
+ case 'Object':
58
+ if (visited[_.util.objId(o)]) {
59
+ return visited[_.util.objId(o)];
60
+ }
61
+ var clone = {};
62
+ visited[_.util.objId(o)] = clone;
63
+
64
+ for (var key in o) {
65
+ if (o.hasOwnProperty(key)) {
66
+ clone[key] = _.util.clone(o[key], visited);
67
+ }
68
+ }
69
+
70
+ return clone;
71
+
72
+ case 'Array':
73
+ if (visited[_.util.objId(o)]) {
74
+ return visited[_.util.objId(o)];
75
+ }
76
+ var clone = [];
77
+ visited[_.util.objId(o)] = clone;
78
+
79
+ o.forEach(function (v, i) {
80
+ clone[i] = _.util.clone(v, visited);
81
+ });
82
+
83
+ return clone;
84
+ }
85
+
86
+ return o;
87
+ }
88
+ },
89
+
90
+ languages: {
91
+ extend: function (id, redef) {
92
+ var lang = _.util.clone(_.languages[id]);
93
+
94
+ for (var key in redef) {
95
+ lang[key] = redef[key];
96
+ }
97
+
98
+ return lang;
99
+ },
100
+
101
+ /**
102
+ * Insert a token before another token in a language literal
103
+ * As this needs to recreate the object (we cannot actually insert before keys in object literals),
104
+ * we cannot just provide an object, we need anobject and a key.
105
+ * @param inside The key (or language id) of the parent
106
+ * @param before The key to insert before. If not provided, the function appends instead.
107
+ * @param insert Object with the key/value pairs to insert
108
+ * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
109
+ */
110
+ insertBefore: function (inside, before, insert, root) {
111
+ root = root || _.languages;
112
+ var grammar = root[inside];
113
+
114
+ if (arguments.length == 2) {
115
+ insert = arguments[1];
116
+
117
+ for (var newToken in insert) {
118
+ if (insert.hasOwnProperty(newToken)) {
119
+ grammar[newToken] = insert[newToken];
120
+ }
121
+ }
122
+
123
+ return grammar;
124
+ }
125
+
126
+ var ret = {};
127
+
128
+ for (var token in grammar) {
129
+
130
+ if (grammar.hasOwnProperty(token)) {
131
+
132
+ if (token == before) {
133
+
134
+ for (var newToken in insert) {
135
+
136
+ if (insert.hasOwnProperty(newToken)) {
137
+ ret[newToken] = insert[newToken];
138
+ }
139
+ }
140
+ }
141
+
142
+ ret[token] = grammar[token];
143
+ }
144
+ }
145
+
146
+ // Update references in other language definitions
147
+ _.languages.DFS(_.languages, function(key, value) {
148
+ if (value === root[inside] && key != inside) {
149
+ this[key] = ret;
150
+ }
151
+ });
152
+
153
+ return root[inside] = ret;
154
+ },
155
+
156
+ // Traverse a language definition with Depth First Search
157
+ DFS: function(o, callback, type, visited) {
158
+ visited = visited || {};
159
+ for (var i in o) {
160
+ if (o.hasOwnProperty(i)) {
161
+ callback.call(o, i, o[i], type || i);
162
+
163
+ if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
164
+ visited[_.util.objId(o[i])] = true;
165
+ _.languages.DFS(o[i], callback, null, visited);
166
+ }
167
+ else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
168
+ visited[_.util.objId(o[i])] = true;
169
+ _.languages.DFS(o[i], callback, i, visited);
170
+ }
171
+ }
172
+ }
173
+ }
174
+ },
175
+ plugins: {},
176
+
177
+ highlightAll: function(async, callback) {
178
+ _.highlightAllUnder(document, async, callback);
179
+ },
180
+
181
+ highlightAllUnder: function(container, async, callback) {
182
+ var env = {
183
+ callback: callback,
184
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
185
+ };
186
+
187
+ _.hooks.run("before-highlightall", env);
188
+
189
+ var elements = env.elements || container.querySelectorAll(env.selector);
190
+
191
+ for (var i=0, element; element = elements[i++];) {
192
+ _.highlightElement(element, async === true, env.callback);
193
+ }
194
+ },
195
+
196
+ highlightElement: function(element, async, callback) {
197
+ // Find language
198
+ var language, grammar, parent = element;
199
+
200
+ while (parent && !lang.test(parent.className)) {
201
+ parent = parent.parentNode;
202
+ }
203
+
204
+ if (parent) {
205
+ language = (parent.className.match(lang) || [,''])[1].toLowerCase();
206
+ grammar = _.languages[language];
207
+ }
208
+
209
+ // Set language on the element, if not present
210
+ element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
211
+
212
+ if (element.parentNode) {
213
+ // Set language on the parent, for styling
214
+ parent = element.parentNode;
215
+
216
+ if (/pre/i.test(parent.nodeName)) {
217
+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
218
+ }
219
+ }
220
+
221
+ var code = element.textContent;
222
+
223
+ var env = {
224
+ element: element,
225
+ language: language,
226
+ grammar: grammar,
227
+ code: code
228
+ };
229
+
230
+ _.hooks.run('before-sanity-check', env);
231
+
232
+ if (!env.code || !env.grammar) {
233
+ if (env.code) {
234
+ _.hooks.run('before-highlight', env);
235
+ env.element.textContent = env.code;
236
+ _.hooks.run('after-highlight', env);
237
+ }
238
+ _.hooks.run('complete', env);
239
+ return;
240
+ }
241
+
242
+ _.hooks.run('before-highlight', env);
243
+
244
+ if (async && _self.Worker) {
245
+ var worker = new Worker(_.filename);
246
+
247
+ worker.onmessage = function(evt) {
248
+ env.highlightedCode = evt.data;
249
+
250
+ _.hooks.run('before-insert', env);
251
+
252
+ env.element.innerHTML = env.highlightedCode;
253
+
254
+ callback && callback.call(env.element);
255
+ _.hooks.run('after-highlight', env);
256
+ _.hooks.run('complete', env);
257
+ };
258
+
259
+ worker.postMessage(JSON.stringify({
260
+ language: env.language,
261
+ code: env.code,
262
+ immediateClose: true
263
+ }));
264
+ }
265
+ else {
266
+ env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
267
+
268
+ _.hooks.run('before-insert', env);
269
+
270
+ env.element.innerHTML = env.highlightedCode;
271
+
272
+ callback && callback.call(element);
273
+
274
+ _.hooks.run('after-highlight', env);
275
+ _.hooks.run('complete', env);
276
+ }
277
+ },
278
+
279
+ highlight: function (text, grammar, language) {
280
+ var env = {
281
+ code: text,
282
+ grammar: grammar,
283
+ language: language
284
+ };
285
+ _.hooks.run('before-tokenize', env);
286
+ env.tokens = _.tokenize(env.code, env.grammar);
287
+ _.hooks.run('after-tokenize', env);
288
+ return Token.stringify(_.util.encode(env.tokens), env.language);
289
+ },
290
+
291
+ matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
292
+ var Token = _.Token;
293
+
294
+ for (var token in grammar) {
295
+ if(!grammar.hasOwnProperty(token) || !grammar[token]) {
296
+ continue;
297
+ }
298
+
299
+ if (token == target) {
300
+ return;
301
+ }
302
+
303
+ var patterns = grammar[token];
304
+ patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
305
+
306
+ for (var j = 0; j < patterns.length; ++j) {
307
+ var pattern = patterns[j],
308
+ inside = pattern.inside,
309
+ lookbehind = !!pattern.lookbehind,
310
+ greedy = !!pattern.greedy,
311
+ lookbehindLength = 0,
312
+ alias = pattern.alias;
313
+
314
+ if (greedy && !pattern.pattern.global) {
315
+ // Without the global flag, lastIndex won't work
316
+ var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
317
+ pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
318
+ }
319
+
320
+ pattern = pattern.pattern || pattern;
321
+
322
+ // Don’t cache length as it changes during the loop
323
+ for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
324
+
325
+ var str = strarr[i];
326
+
327
+ if (strarr.length > text.length) {
328
+ // Something went terribly wrong, ABORT, ABORT!
329
+ return;
330
+ }
331
+
332
+ if (str instanceof Token) {
333
+ continue;
334
+ }
335
+
336
+ if (greedy && i != strarr.length - 1) {
337
+ pattern.lastIndex = pos;
338
+ var match = pattern.exec(text);
339
+ if (!match) {
340
+ break;
341
+ }
342
+
343
+ var from = match.index + (lookbehind ? match[1].length : 0),
344
+ to = match.index + match[0].length,
345
+ k = i,
346
+ p = pos;
347
+
348
+ for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
349
+ p += strarr[k].length;
350
+ // Move the index i to the element in strarr that is closest to from
351
+ if (from >= p) {
352
+ ++i;
353
+ pos = p;
354
+ }
355
+ }
356
+
357
+ // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
358
+ if (strarr[i] instanceof Token) {
359
+ continue;
360
+ }
361
+
362
+ // Number of tokens to delete and replace with the new match
363
+ delNum = k - i;
364
+ str = text.slice(pos, p);
365
+ match.index -= pos;
366
+ } else {
367
+ pattern.lastIndex = 0;
368
+
369
+ var match = pattern.exec(str),
370
+ delNum = 1;
371
+ }
372
+
373
+ if (!match) {
374
+ if (oneshot) {
375
+ break;
376
+ }
377
+
378
+ continue;
379
+ }
380
+
381
+ if(lookbehind) {
382
+ lookbehindLength = match[1] ? match[1].length : 0;
383
+ }
384
+
385
+ var from = match.index + lookbehindLength,
386
+ match = match[0].slice(lookbehindLength),
387
+ to = from + match.length,
388
+ before = str.slice(0, from),
389
+ after = str.slice(to);
390
+
391
+ var args = [i, delNum];
392
+
393
+ if (before) {
394
+ ++i;
395
+ pos += before.length;
396
+ args.push(before);
397
+ }
398
+
399
+ var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
400
+
401
+ args.push(wrapped);
402
+
403
+ if (after) {
404
+ args.push(after);
405
+ }
406
+
407
+ Array.prototype.splice.apply(strarr, args);
408
+
409
+ if (delNum != 1)
410
+ _.matchGrammar(text, strarr, grammar, i, pos, true, token);
411
+
412
+ if (oneshot)
413
+ break;
414
+ }
415
+ }
416
+ }
417
+ },
418
+
419
+ tokenize: function(text, grammar, language) {
420
+ var strarr = [text];
421
+
422
+ var rest = grammar.rest;
423
+
424
+ if (rest) {
425
+ for (var token in rest) {
426
+ grammar[token] = rest[token];
427
+ }
428
+
429
+ delete grammar.rest;
430
+ }
431
+
432
+ _.matchGrammar(text, strarr, grammar, 0, 0, false);
433
+
434
+ return strarr;
435
+ },
436
+
437
+ hooks: {
438
+ all: {},
439
+
440
+ add: function (name, callback) {
441
+ var hooks = _.hooks.all;
442
+
443
+ hooks[name] = hooks[name] || [];
444
+
445
+ hooks[name].push(callback);
446
+ },
447
+
448
+ run: function (name, env) {
449
+ var callbacks = _.hooks.all[name];
450
+
451
+ if (!callbacks || !callbacks.length) {
452
+ return;
453
+ }
454
+
455
+ for (var i=0, callback; callback = callbacks[i++];) {
456
+ callback(env);
457
+ }
458
+ }
459
+ }
460
+ };
461
+
462
+ var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
463
+ this.type = type;
464
+ this.content = content;
465
+ this.alias = alias;
466
+ // Copy of the full string this token was created from
467
+ this.length = (matchedStr || "").length|0;
468
+ this.greedy = !!greedy;
469
+ };
470
+
471
+ Token.stringify = function(o, language, parent) {
472
+ if (typeof o == 'string') {
473
+ return o;
474
+ }
475
+
476
+ if (_.util.type(o) === 'Array') {
477
+ return o.map(function(element) {
478
+ return Token.stringify(element, language, o);
479
+ }).join('');
480
+ }
481
+
482
+ var env = {
483
+ type: o.type,
484
+ content: Token.stringify(o.content, language, parent),
485
+ tag: 'span',
486
+ classes: ['token', o.type],
487
+ attributes: {},
488
+ language: language,
489
+ parent: parent
490
+ };
491
+
492
+ if (o.alias) {
493
+ var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
494
+ Array.prototype.push.apply(env.classes, aliases);
495
+ }
496
+
497
+ _.hooks.run('wrap', env);
498
+
499
+ var attributes = Object.keys(env.attributes).map(function(name) {
500
+ return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
501
+ }).join(' ');
502
+
503
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
504
+
505
+ };
506
+
507
+ if (!_self.document) {
508
+ if (!_self.addEventListener) {
509
+ // in Node.js
510
+ return _self.Prism;
511
+ }
512
+
513
+ if (!_.disableWorkerMessageHandler) {
514
+ // In worker
515
+ _self.addEventListener('message', function (evt) {
516
+ var message = JSON.parse(evt.data),
517
+ lang = message.language,
518
+ code = message.code,
519
+ immediateClose = message.immediateClose;
520
+
521
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
522
+ if (immediateClose) {
523
+ _self.close();
524
+ }
525
+ }, false);
526
+ }
527
+
528
+ return _self.Prism;
529
+ }
530
+
531
+ //Get current script and highlight
532
+ var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
533
+
534
+ if (script) {
535
+ _.filename = script.src;
536
+
537
+ if (!_.manual && !script.hasAttribute('data-manual')) {
538
+ if(document.readyState !== "loading") {
539
+ if (window.requestAnimationFrame) {
540
+ window.requestAnimationFrame(_.highlightAll);
541
+ } else {
542
+ window.setTimeout(_.highlightAll, 16);
543
+ }
544
+ }
545
+ else {
546
+ document.addEventListener('DOMContentLoaded', _.highlightAll);
547
+ }
548
+ }
549
+ }
550
+
551
+ return _self.Prism;
552
+
553
+ })();
554
+
555
+ if (typeof module !== 'undefined' && module.exports) {
556
+ module.exports = Prism;
557
+ }
558
+
559
+ // hack for components to work correctly in node.js
560
+ if (typeof global !== 'undefined') {
561
+ global.Prism = Prism;
562
+ }
563
+
564
+
565
+ /* **********************************************
566
+ Begin prism-markup.js
567
+ ********************************************** */
568
+
569
+ Prism.languages.markup = {
570
+ 'comment': /<!--[\s\S]*?-->/,
571
+ 'prolog': /<\?[\s\S]+?\?>/,
572
+ 'doctype': /<!DOCTYPE[\s\S]+?>/i,
573
+ 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
574
+ 'tag': {
575
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
576
+ greedy: true,
577
+ inside: {
578
+ 'tag': {
579
+ pattern: /^<\/?[^\s>\/]+/i,
580
+ inside: {
581
+ 'punctuation': /^<\/?/,
582
+ 'namespace': /^[^\s>\/:]+:/
583
+ }
584
+ },
585
+ 'attr-value': {
586
+ pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,
587
+ inside: {
588
+ 'punctuation': [
589
+ /^=/,
590
+ {
591
+ pattern: /(^|[^\\])["']/,
592
+ lookbehind: true
593
+ }
594
+ ]
595
+ }
596
+ },
597
+ 'punctuation': /\/?>/,
598
+ 'attr-name': {
599
+ pattern: /[^\s>\/]+/,
600
+ inside: {
601
+ 'namespace': /^[^\s>\/:]+:/
602
+ }
603
+ }
604
+
605
+ }
606
+ },
607
+ 'entity': /&#?[\da-z]{1,8};/i
608
+ };
609
+
610
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
611
+ Prism.languages.markup['entity'];
612
+
613
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
614
+ Prism.hooks.add('wrap', function(env) {
615
+
616
+ if (env.type === 'entity') {
617
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
618
+ }
619
+ });
620
+
621
+ Prism.languages.xml = Prism.languages.markup;
622
+ Prism.languages.html = Prism.languages.markup;
623
+ Prism.languages.mathml = Prism.languages.markup;
624
+ Prism.languages.svg = Prism.languages.markup;
625
+
626
+
627
+ /* **********************************************
628
+ Begin prism-css.js
629
+ ********************************************** */
630
+
631
+ Prism.languages.css = {
632
+ 'comment': /\/\*[\s\S]*?\*\//,
633
+ 'atrule': {
634
+ pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i,
635
+ inside: {
636
+ 'rule': /@[\w-]+/
637
+ // See rest below
638
+ }
639
+ },
640
+ 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
641
+ 'selector': /[^{}\s][^{};]*?(?=\s*\{)/,
642
+ 'string': {
643
+ pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
644
+ greedy: true
645
+ },
646
+ 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
647
+ 'important': /\B!important\b/i,
648
+ 'function': /[-a-z0-9]+(?=\()/i,
649
+ 'punctuation': /[(){};:]/
650
+ };
651
+
652
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
653
+
654
+ if (Prism.languages.markup) {
655
+ Prism.languages.insertBefore('markup', 'tag', {
656
+ 'style': {
657
+ pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
658
+ lookbehind: true,
659
+ inside: Prism.languages.css,
660
+ alias: 'language-css',
661
+ greedy: true
662
+ }
663
+ });
664
+
665
+ Prism.languages.insertBefore('inside', 'attr-value', {
666
+ 'style-attr': {
667
+ pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
668
+ inside: {
669
+ 'attr-name': {
670
+ pattern: /^\s*style/i,
671
+ inside: Prism.languages.markup.tag.inside
672
+ },
673
+ 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
674
+ 'attr-value': {
675
+ pattern: /.+/i,
676
+ inside: Prism.languages.css
677
+ }
678
+ },
679
+ alias: 'language-css'
680
+ }
681
+ }, Prism.languages.markup.tag);
682
+ }
683
+
684
+ /* **********************************************
685
+ Begin prism-clike.js
686
+ ********************************************** */
687
+
688
+ Prism.languages.clike = {
689
+ 'comment': [
690
+ {
691
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
692
+ lookbehind: true
693
+ },
694
+ {
695
+ pattern: /(^|[^\\:])\/\/.*/,
696
+ lookbehind: true,
697
+ greedy: true
698
+ }
699
+ ],
700
+ 'string': {
701
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
702
+ greedy: true
703
+ },
704
+ 'class-name': {
705
+ pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
706
+ lookbehind: true,
707
+ inside: {
708
+ punctuation: /[.\\]/
709
+ }
710
+ },
711
+ 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
712
+ 'boolean': /\b(?:true|false)\b/,
713
+ 'function': /[a-z0-9_]+(?=\()/i,
714
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
715
+ 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
716
+ 'punctuation': /[{}[\];(),.:]/
717
+ };
718
+
719
+
720
+ /* **********************************************
721
+ Begin prism-javascript.js
722
+ ********************************************** */
723
+
724
+ Prism.languages.javascript = Prism.languages.extend('clike', {
725
+ 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
726
+ 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
727
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
728
+ 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,
729
+ 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
730
+ });
731
+
732
+ Prism.languages.insertBefore('javascript', 'keyword', {
733
+ 'regex': {
734
+ pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
735
+ lookbehind: true,
736
+ greedy: true
737
+ },
738
+ // This must be declared before keyword because we use "function" inside the look-forward
739
+ 'function-variable': {
740
+ pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,
741
+ alias: 'function'
742
+ },
743
+ 'constant': /\b[A-Z][A-Z\d_]*\b/
744
+ });
745
+
746
+ Prism.languages.insertBefore('javascript', 'string', {
747
+ 'template-string': {
748
+ pattern: /`(?:\\[\s\S]|[^\\`])*`/,
749
+ greedy: true,
750
+ inside: {
751
+ 'interpolation': {
752
+ pattern: /\$\{[^}]+\}/,
753
+ inside: {
754
+ 'interpolation-punctuation': {
755
+ pattern: /^\$\{|\}$/,
756
+ alias: 'punctuation'
757
+ },
758
+ rest: Prism.languages.javascript
759
+ }
760
+ },
761
+ 'string': /[\s\S]+/
762
+ }
763
+ }
764
+ });
765
+
766
+ if (Prism.languages.markup) {
767
+ Prism.languages.insertBefore('markup', 'tag', {
768
+ 'script': {
769
+ pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
770
+ lookbehind: true,
771
+ inside: Prism.languages.javascript,
772
+ alias: 'language-javascript',
773
+ greedy: true
774
+ }
775
+ });
776
+ }
777
+
778
+ Prism.languages.js = Prism.languages.javascript;
779
+
780
+
781
+ /* **********************************************
782
+ Begin prism-file-highlight.js
783
+ ********************************************** */
784
+
785
+ (function () {
786
+ if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
787
+ return;
788
+ }
789
+
790
+ self.Prism.fileHighlight = function() {
791
+
792
+ var Extensions = {
793
+ 'js': 'javascript',
794
+ 'py': 'python',
795
+ 'rb': 'ruby',
796
+ 'ps1': 'powershell',
797
+ 'psm1': 'powershell',
798
+ 'sh': 'bash',
799
+ 'bat': 'batch',
800
+ 'h': 'c',
801
+ 'tex': 'latex'
802
+ };
803
+
804
+ Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
805
+ var src = pre.getAttribute('data-src');
806
+
807
+ var language, parent = pre;
808
+ var lang = /\blang(?:uage)?-(?!\*)([\w-]+)\b/i;
809
+ while (parent && !lang.test(parent.className)) {
810
+ parent = parent.parentNode;
811
+ }
812
+
813
+ if (parent) {
814
+ language = (pre.className.match(lang) || [, ''])[1];
815
+ }
816
+
817
+ if (!language) {
818
+ var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
819
+ language = Extensions[extension] || extension;
820
+ }
821
+
822
+ var code = document.createElement('code');
823
+ code.className = 'language-' + language;
824
+
825
+ pre.textContent = '';
826
+
827
+ code.textContent = 'Loading…';
828
+
829
+ pre.appendChild(code);
830
+
831
+ var xhr = new XMLHttpRequest();
832
+
833
+ xhr.open('GET', src, true);
834
+
835
+ xhr.onreadystatechange = function () {
836
+ if (xhr.readyState == 4) {
837
+
838
+ if (xhr.status < 400 && xhr.responseText) {
839
+ code.textContent = xhr.responseText;
840
+
841
+ Prism.highlightElement(code);
842
+ }
843
+ else if (xhr.status >= 400) {
844
+ code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
845
+ }
846
+ else {
847
+ code.textContent = '✖ Error: File does not exist or is empty';
848
+ }
849
+ }
850
+ };
851
+
852
+ if (pre.hasAttribute('data-download-link') && Prism.plugins.toolbar) {
853
+ Prism.plugins.toolbar.registerButton('download-file', function () {
854
+ var a = document.createElement('a');
855
+ a.textContent = pre.getAttribute('data-download-link-label') || 'Download';
856
+ a.setAttribute('download', '');
857
+ a.href = src;
858
+ return a;
859
+ });
860
+ }
861
+
862
+ xhr.send(null);
863
+ });
864
+
865
+ };
866
+
867
+ document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight);
868
+
869
+ })();