@ebrains/react 2.0.0 → 2.1.0

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 (92) hide show
  1. package/clone-dab56639.esm.js +3 -0
  2. package/color-primary-palette_6.entry.esm.js +106 -106
  3. package/components-section.entry.esm.js +1 -1
  4. package/correct-use-of-colors.entry.esm.js +33 -33
  5. package/docs-palettes.entry.esm.js +1 -1
  6. package/docs-tokens.entry.esm.js +1 -1
  7. package/edit-3893a517.esm.js +3 -0
  8. package/eds-accordion_33.entry.esm.js +1123 -0
  9. package/eds-app-root.entry.esm.js +4 -4
  10. package/eds-card-desc_2.entry.esm.js +4 -4
  11. package/eds-card-project.entry.esm.js +10 -10
  12. package/eds-card-tags.entry.esm.js +1 -1
  13. package/eds-card-tool.entry.esm.js +4 -4
  14. package/eds-cookies-preference.entry.esm.js +2 -2
  15. package/eds-feedback.entry.esm.js +5 -5
  16. package/eds-footer.entry.esm.js +20 -14
  17. package/eds-frame.entry.esm.js +4 -4
  18. package/eds-gauge.entry.esm.js +4 -4
  19. package/eds-icon-arrow-diagonal.entry.esm.js +1 -1
  20. package/eds-icon-arrow-right.entry.esm.js +1 -1
  21. package/eds-icon-bin.entry.esm.js +1 -1
  22. package/eds-icon-bluesky.entry.esm.js +1 -1
  23. package/eds-icon-bookmark.entry.esm.js +1 -1
  24. package/eds-icon-chevron-down.entry.esm.js +1 -1
  25. package/eds-icon-chevron-left.entry.esm.js +1 -1
  26. package/eds-icon-chevron-right.entry.esm.js +1 -1
  27. package/eds-icon-chevron-up.entry.esm.js +1 -1
  28. package/eds-icon-clone.entry.esm.js +21 -0
  29. package/eds-icon-close.entry.esm.js +1 -1
  30. package/eds-icon-copy.entry.esm.js +1 -1
  31. package/eds-icon-draft.entry.esm.js +1 -1
  32. package/eds-icon-edit.entry.esm.js +2 -2
  33. package/eds-icon-eu.entry.esm.js +1 -1
  34. package/eds-icon-external.entry.esm.js +1 -1
  35. package/eds-icon-facebook.entry.esm.js +1 -1
  36. package/eds-icon-gitlab.entry.esm.js +1 -1
  37. package/eds-icon-linkedin.entry.esm.js +1 -1
  38. package/eds-icon-loader.entry.esm.js +1 -1
  39. package/eds-icon-mastodon.entry.esm.js +1 -1
  40. package/eds-icon-menu.entry.esm.js +1 -1
  41. package/eds-icon-minus.entry.esm.js +1 -1
  42. package/eds-icon-more.entry.esm.js +1 -1
  43. package/eds-icon-paper.entry.esm.js +1 -1
  44. package/eds-icon-plus.entry.esm.js +1 -1
  45. package/eds-icon-portal.entry.esm.js +1 -1
  46. package/eds-icon-private.entry.esm.js +1 -1
  47. package/eds-icon-public.entry.esm.js +1 -1
  48. package/eds-icon-search.entry.esm.js +1 -1
  49. package/eds-icon-star.entry.esm.js +1 -1
  50. package/eds-icon-start.entry.esm.js +1 -1
  51. package/eds-icon-success.entry.esm.js +1 -1
  52. package/eds-icon-thumbs-down.entry.esm.js +1 -1
  53. package/eds-icon-thumbs-up.entry.esm.js +1 -1
  54. package/eds-icon-tutorial.entry.esm.js +1 -1
  55. package/eds-icon-twitter.entry.esm.js +1 -1
  56. package/eds-icon-unknown.entry.esm.js +1 -1
  57. package/eds-icon-updown.entry.esm.js +1 -1
  58. package/eds-icon-user.entry.esm.js +1 -1
  59. package/eds-icon-view.entry.esm.js +21 -0
  60. package/eds-icon-youtube.entry.esm.js +1 -1
  61. package/eds-modal.entry.esm.js +8 -8
  62. package/eds-progress-bar.entry.esm.js +4 -4
  63. package/eds-section-core_2.entry.esm.js +5 -5
  64. package/eds-social-networks.entry.esm.js +3 -3
  65. package/eds-spinner.entry.esm.js +4 -4
  66. package/eds-timeline.entry.esm.js +4 -4
  67. package/eds-toast-manager.entry.esm.js +1 -1
  68. package/eds-tooltip.entry.esm.js +3 -3
  69. package/eds-trl.entry.esm.js +2 -2
  70. package/incorrect-use-of-colors.entry.esm.js +8 -8
  71. package/index.esm.js +1 -1
  72. package/index.esm2.js +14 -24
  73. package/logo-space.entry.esm.js +9 -9
  74. package/logo-variations-horizontal_2.entry.esm.js +28 -28
  75. package/logo-variations-tabs.entry.esm.js +1 -1
  76. package/logo-wrong-usage.entry.esm.js +25 -25
  77. package/package.json +1 -1
  78. package/src/components.d.ts +1 -0
  79. package/svg-repository.entry.esm.js +8 -4
  80. package/token-list_3.entry.esm.js +5 -5
  81. package/token-ratios.entry.esm.js +3 -3
  82. package/token-spacing.entry.esm.js +26 -26
  83. package/token-typography.entry.esm.js +2 -2
  84. package/view-e900f2d4.esm.js +3 -0
  85. package/edit-1dc8d11b.esm.js +0 -3
  86. package/eds-accordion.entry.esm.js +0 -133
  87. package/eds-alert.entry.esm.js +0 -112
  88. package/eds-avatar_26.entry.esm.js +0 -3409
  89. package/eds-breadcrumb.entry.esm.js +0 -179
  90. package/eds-code-block.entry.esm.js +0 -2290
  91. package/eds-matomo-notice.entry.esm.js +0 -159
  92. package/eds-switch.entry.esm.js +0 -70
@@ -1,2290 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index.esm2.js';
2
- import 'react';
3
- import 'react/jsx-runtime';
4
- import 'react-dom';
5
-
6
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7
- var prism = {
8
- exports: {}
9
- };
10
- (function (module) {
11
- /* **********************************************
12
- Begin prism-core.js
13
- ********************************************** */
14
-
15
- /// <reference lib="WebWorker"/>
16
-
17
- var _self = typeof window !== 'undefined' ? window // if in browser
18
- : typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self // if in worker
19
- : {} // if in node js
20
- ;
21
-
22
- /**
23
- * Prism: Lightweight, robust, elegant syntax highlighting
24
- *
25
- * @license MIT <https://opensource.org/licenses/MIT>
26
- * @author Lea Verou <https://lea.verou.me>
27
- * @namespace
28
- * @public
29
- */
30
- var Prism = function (_self) {
31
- // Private helper vars
32
- var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
33
- var uniqueId = 0;
34
-
35
- // The grammar object for plaintext
36
- var plainTextGrammar = {};
37
- var _ = {
38
- /**
39
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
40
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
41
- * additional languages or plugins yourself.
42
- *
43
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
44
- *
45
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
46
- * empty Prism object into the global scope before loading the Prism script like this:
47
- *
48
- * ```js
49
- * window.Prism = window.Prism || {};
50
- * Prism.manual = true;
51
- * // add a new <script> to load Prism's script
52
- * ```
53
- *
54
- * @default false
55
- * @type {boolean}
56
- * @memberof Prism
57
- * @public
58
- */
59
- manual: _self.Prism && _self.Prism.manual,
60
- /**
61
- * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
62
- * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
63
- * own worker, you don't want it to do this.
64
- *
65
- * By setting this value to `true`, Prism will not add its own listeners to the worker.
66
- *
67
- * You obviously have to change this value before Prism executes. To do this, you can add an
68
- * empty Prism object into the global scope before loading the Prism script like this:
69
- *
70
- * ```js
71
- * window.Prism = window.Prism || {};
72
- * Prism.disableWorkerMessageHandler = true;
73
- * // Load Prism's script
74
- * ```
75
- *
76
- * @default false
77
- * @type {boolean}
78
- * @memberof Prism
79
- * @public
80
- */
81
- disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
82
- /**
83
- * A namespace for utility methods.
84
- *
85
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
86
- * change or disappear at any time.
87
- *
88
- * @namespace
89
- * @memberof Prism
90
- */
91
- util: {
92
- encode: function encode(tokens) {
93
- if (tokens instanceof Token) {
94
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
95
- } else if (Array.isArray(tokens)) {
96
- return tokens.map(encode);
97
- } else {
98
- return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
99
- }
100
- },
101
- /**
102
- * Returns the name of the type of the given value.
103
- *
104
- * @param {any} o
105
- * @returns {string}
106
- * @example
107
- * type(null) === 'Null'
108
- * type(undefined) === 'Undefined'
109
- * type(123) === 'Number'
110
- * type('foo') === 'String'
111
- * type(true) === 'Boolean'
112
- * type([1, 2]) === 'Array'
113
- * type({}) === 'Object'
114
- * type(String) === 'Function'
115
- * type(/abc+/) === 'RegExp'
116
- */
117
- type: function (o) {
118
- return Object.prototype.toString.call(o).slice(8, -1);
119
- },
120
- /**
121
- * Returns a unique number for the given object. Later calls will still return the same number.
122
- *
123
- * @param {Object} obj
124
- * @returns {number}
125
- */
126
- objId: function (obj) {
127
- if (!obj['__id']) {
128
- Object.defineProperty(obj, '__id', {
129
- value: ++uniqueId
130
- });
131
- }
132
- return obj['__id'];
133
- },
134
- /**
135
- * Creates a deep clone of the given object.
136
- *
137
- * The main intended use of this function is to clone language definitions.
138
- *
139
- * @param {T} o
140
- * @param {Record<number, any>} [visited]
141
- * @returns {T}
142
- * @template T
143
- */
144
- clone: function deepClone(o, visited) {
145
- visited = visited || {};
146
- var clone;
147
- var id;
148
- switch (_.util.type(o)) {
149
- case 'Object':
150
- id = _.util.objId(o);
151
- if (visited[id]) {
152
- return visited[id];
153
- }
154
- clone = /** @type {Record<string, any>} */{};
155
- visited[id] = clone;
156
- for (var key in o) {
157
- if (o.hasOwnProperty(key)) {
158
- clone[key] = deepClone(o[key], visited);
159
- }
160
- }
161
- return /** @type {any} */clone;
162
- case 'Array':
163
- id = _.util.objId(o);
164
- if (visited[id]) {
165
- return visited[id];
166
- }
167
- clone = [];
168
- visited[id] = clone;
169
- (/** @type {Array} */ /** @type {any} */o).forEach(function (v, i) {
170
- clone[i] = deepClone(v, visited);
171
- });
172
- return /** @type {any} */clone;
173
- default:
174
- return o;
175
- }
176
- },
177
- /**
178
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
179
- *
180
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
181
- *
182
- * @param {Element} element
183
- * @returns {string}
184
- */
185
- getLanguage: function (element) {
186
- while (element) {
187
- var m = lang.exec(element.className);
188
- if (m) {
189
- return m[1].toLowerCase();
190
- }
191
- element = element.parentElement;
192
- }
193
- return 'none';
194
- },
195
- /**
196
- * Sets the Prism `language-xxxx` class of the given element.
197
- *
198
- * @param {Element} element
199
- * @param {string} language
200
- * @returns {void}
201
- */
202
- setLanguage: function (element, language) {
203
- // remove all `language-xxxx` classes
204
- // (this might leave behind a leading space)
205
- element.className = element.className.replace(RegExp(lang, 'gi'), '');
206
-
207
- // add the new `language-xxxx` class
208
- // (using `classList` will automatically clean up spaces for us)
209
- element.classList.add('language-' + language);
210
- },
211
- /**
212
- * Returns the script element that is currently executing.
213
- *
214
- * This does __not__ work for line script element.
215
- *
216
- * @returns {HTMLScriptElement | null}
217
- */
218
- currentScript: function () {
219
- if (typeof document === 'undefined') {
220
- return null;
221
- }
222
- if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
223
- return /** @type {any} */document.currentScript;
224
- }
225
-
226
- // IE11 workaround
227
- // we'll get the src of the current script by parsing IE11's error stack trace
228
- // this will not work for inline scripts
229
-
230
- try {
231
- throw new Error();
232
- } catch (err) {
233
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
234
- // A stack will look like this:
235
- //
236
- // Error
237
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
238
- // at Global code (http://localhost/components/prism-core.js:606:1)
239
-
240
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
241
- if (src) {
242
- var scripts = document.getElementsByTagName('script');
243
- for (var i in scripts) {
244
- if (scripts[i].src == src) {
245
- return scripts[i];
246
- }
247
- }
248
- }
249
- return null;
250
- }
251
- },
252
- /**
253
- * Returns whether a given class is active for `element`.
254
- *
255
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
256
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
257
- * given class is just the given class with a `no-` prefix.
258
- *
259
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
260
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
261
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
262
- *
263
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
264
- * version of it, the class is considered active.
265
- *
266
- * @param {Element} element
267
- * @param {string} className
268
- * @param {boolean} [defaultActivation=false]
269
- * @returns {boolean}
270
- */
271
- isActive: function (element, className, defaultActivation) {
272
- var no = 'no-' + className;
273
- while (element) {
274
- var classList = element.classList;
275
- if (classList.contains(className)) {
276
- return true;
277
- }
278
- if (classList.contains(no)) {
279
- return false;
280
- }
281
- element = element.parentElement;
282
- }
283
- return !!defaultActivation;
284
- }
285
- },
286
- /**
287
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
288
- *
289
- * @namespace
290
- * @memberof Prism
291
- * @public
292
- */
293
- languages: {
294
- /**
295
- * The grammar for plain, unformatted text.
296
- */
297
- plain: plainTextGrammar,
298
- plaintext: plainTextGrammar,
299
- text: plainTextGrammar,
300
- txt: plainTextGrammar,
301
- /**
302
- * Creates a deep copy of the language with the given id and appends the given tokens.
303
- *
304
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
305
- * will be overwritten at its original position.
306
- *
307
- * ## Best practices
308
- *
309
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
310
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
311
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
312
- *
313
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
314
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
315
- *
316
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
317
- * @param {Grammar} redef The new tokens to append.
318
- * @returns {Grammar} The new language created.
319
- * @public
320
- * @example
321
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
322
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
323
- * // at its original position
324
- * 'comment': { ... },
325
- * // CSS doesn't have a 'color' token, so this token will be appended
326
- * 'color': /\b(?:red|green|blue)\b/
327
- * });
328
- */
329
- extend: function (id, redef) {
330
- var lang = _.util.clone(_.languages[id]);
331
- for (var key in redef) {
332
- lang[key] = redef[key];
333
- }
334
- return lang;
335
- },
336
- /**
337
- * Inserts tokens _before_ another token in a language definition or any other grammar.
338
- *
339
- * ## Usage
340
- *
341
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
342
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
343
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
344
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
345
- * this:
346
- *
347
- * ```js
348
- * Prism.languages.markup.style = {
349
- * // token
350
- * };
351
- * ```
352
- *
353
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
354
- * before existing tokens. For the CSS example above, you would use it like this:
355
- *
356
- * ```js
357
- * Prism.languages.insertBefore('markup', 'cdata', {
358
- * 'style': {
359
- * // token
360
- * }
361
- * });
362
- * ```
363
- *
364
- * ## Special cases
365
- *
366
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
367
- * will be ignored.
368
- *
369
- * This behavior can be used to insert tokens after `before`:
370
- *
371
- * ```js
372
- * Prism.languages.insertBefore('markup', 'comment', {
373
- * 'comment': Prism.languages.markup.comment,
374
- * // tokens after 'comment'
375
- * });
376
- * ```
377
- *
378
- * ## Limitations
379
- *
380
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
381
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
382
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
383
- * deleting properties which is necessary to insert at arbitrary positions.
384
- *
385
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
386
- * Instead, it will create a new object and replace all references to the target object with the new one. This
387
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
388
- *
389
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
390
- * you hold the target object in a variable, then the value of the variable will not change.
391
- *
392
- * ```js
393
- * var oldMarkup = Prism.languages.markup;
394
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
395
- *
396
- * assert(oldMarkup !== Prism.languages.markup);
397
- * assert(newMarkup === Prism.languages.markup);
398
- * ```
399
- *
400
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
401
- * object to be modified.
402
- * @param {string} before The key to insert before.
403
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
404
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
405
- * object to be modified.
406
- *
407
- * Defaults to `Prism.languages`.
408
- * @returns {Grammar} The new grammar object.
409
- * @public
410
- */
411
- insertBefore: function (inside, before, insert, root) {
412
- root = root || (/** @type {any} */_.languages);
413
- var grammar = root[inside];
414
- /** @type {Grammar} */
415
- var ret = {};
416
- for (var token in grammar) {
417
- if (grammar.hasOwnProperty(token)) {
418
- if (token == before) {
419
- for (var newToken in insert) {
420
- if (insert.hasOwnProperty(newToken)) {
421
- ret[newToken] = insert[newToken];
422
- }
423
- }
424
- }
425
-
426
- // Do not insert token which also occur in insert. See #1525
427
- if (!insert.hasOwnProperty(token)) {
428
- ret[token] = grammar[token];
429
- }
430
- }
431
- }
432
- var old = root[inside];
433
- root[inside] = ret;
434
-
435
- // Update references in other language definitions
436
- _.languages.DFS(_.languages, function (key, value) {
437
- if (value === old && key != inside) {
438
- this[key] = ret;
439
- }
440
- });
441
- return ret;
442
- },
443
- // Traverse a language definition with Depth First Search
444
- DFS: function DFS(o, callback, type, visited) {
445
- visited = visited || {};
446
- var objId = _.util.objId;
447
- for (var i in o) {
448
- if (o.hasOwnProperty(i)) {
449
- callback.call(o, i, o[i], type || i);
450
- var property = o[i];
451
- var propertyType = _.util.type(property);
452
- if (propertyType === 'Object' && !visited[objId(property)]) {
453
- visited[objId(property)] = true;
454
- DFS(property, callback, null, visited);
455
- } else if (propertyType === 'Array' && !visited[objId(property)]) {
456
- visited[objId(property)] = true;
457
- DFS(property, callback, i, visited);
458
- }
459
- }
460
- }
461
- }
462
- },
463
- plugins: {},
464
- /**
465
- * This is the most high-level function in Prism’s API.
466
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
467
- * each one of them.
468
- *
469
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
470
- *
471
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
472
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
473
- * @memberof Prism
474
- * @public
475
- */
476
- highlightAll: function (async, callback) {
477
- _.highlightAllUnder(document, async, callback);
478
- },
479
- /**
480
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
481
- * {@link Prism.highlightElement} on each one of them.
482
- *
483
- * The following hooks will be run:
484
- * 1. `before-highlightall`
485
- * 2. `before-all-elements-highlight`
486
- * 3. All hooks of {@link Prism.highlightElement} for each element.
487
- *
488
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
489
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
490
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
491
- * @memberof Prism
492
- * @public
493
- */
494
- highlightAllUnder: function (container, async, callback) {
495
- var env = {
496
- callback: callback,
497
- container: container,
498
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
499
- };
500
- _.hooks.run('before-highlightall', env);
501
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
502
- _.hooks.run('before-all-elements-highlight', env);
503
- for (var i = 0, element; element = env.elements[i++];) {
504
- _.highlightElement(element, async === true, env.callback);
505
- }
506
- },
507
- /**
508
- * Highlights the code inside a single element.
509
- *
510
- * The following hooks will be run:
511
- * 1. `before-sanity-check`
512
- * 2. `before-highlight`
513
- * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
514
- * 4. `before-insert`
515
- * 5. `after-highlight`
516
- * 6. `complete`
517
- *
518
- * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
519
- * the element's language.
520
- *
521
- * @param {Element} element The element containing the code.
522
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
523
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
524
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
525
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
526
- *
527
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
528
- * asynchronous highlighting to work. You can build your own bundle on the
529
- * [Download page](https://prismjs.com/download.html).
530
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
531
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
532
- * @memberof Prism
533
- * @public
534
- */
535
- highlightElement: function (element, async, callback) {
536
- // Find language
537
- var language = _.util.getLanguage(element);
538
- var grammar = _.languages[language];
539
-
540
- // Set language on the element, if not present
541
- _.util.setLanguage(element, language);
542
-
543
- // Set language on the parent, for styling
544
- var parent = element.parentElement;
545
- if (parent && parent.nodeName.toLowerCase() === 'pre') {
546
- _.util.setLanguage(parent, language);
547
- }
548
- var code = element.textContent;
549
- var env = {
550
- element: element,
551
- language: language,
552
- grammar: grammar,
553
- code: code
554
- };
555
- function insertHighlightedCode(highlightedCode) {
556
- env.highlightedCode = highlightedCode;
557
- _.hooks.run('before-insert', env);
558
- env.element.innerHTML = env.highlightedCode;
559
- _.hooks.run('after-highlight', env);
560
- _.hooks.run('complete', env);
561
- callback && callback.call(env.element);
562
- }
563
- _.hooks.run('before-sanity-check', env);
564
-
565
- // plugins may change/add the parent/element
566
- parent = env.element.parentElement;
567
- if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
568
- parent.setAttribute('tabindex', '0');
569
- }
570
- if (!env.code) {
571
- _.hooks.run('complete', env);
572
- callback && callback.call(env.element);
573
- return;
574
- }
575
- _.hooks.run('before-highlight', env);
576
- if (!env.grammar) {
577
- insertHighlightedCode(_.util.encode(env.code));
578
- return;
579
- }
580
- if (async && _self.Worker) {
581
- var worker = new Worker(_.filename);
582
- worker.onmessage = function (evt) {
583
- insertHighlightedCode(evt.data);
584
- };
585
- worker.postMessage(JSON.stringify({
586
- language: env.language,
587
- code: env.code,
588
- immediateClose: true
589
- }));
590
- } else {
591
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
592
- }
593
- },
594
- /**
595
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
596
- * and the language definitions to use, and returns a string with the HTML produced.
597
- *
598
- * The following hooks will be run:
599
- * 1. `before-tokenize`
600
- * 2. `after-tokenize`
601
- * 3. `wrap`: On each {@link Token}.
602
- *
603
- * @param {string} text A string with the code to be highlighted.
604
- * @param {Grammar} grammar An object containing the tokens to use.
605
- *
606
- * Usually a language definition like `Prism.languages.markup`.
607
- * @param {string} language The name of the language definition passed to `grammar`.
608
- * @returns {string} The highlighted HTML.
609
- * @memberof Prism
610
- * @public
611
- * @example
612
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
613
- */
614
- highlight: function (text, grammar, language) {
615
- var env = {
616
- code: text,
617
- grammar: grammar,
618
- language: language
619
- };
620
- _.hooks.run('before-tokenize', env);
621
- if (!env.grammar) {
622
- throw new Error('The language "' + env.language + '" has no grammar.');
623
- }
624
- env.tokens = _.tokenize(env.code, env.grammar);
625
- _.hooks.run('after-tokenize', env);
626
- return Token.stringify(_.util.encode(env.tokens), env.language);
627
- },
628
- /**
629
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
630
- * and the language definitions to use, and returns an array with the tokenized code.
631
- *
632
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
633
- *
634
- * This method could be useful in other contexts as well, as a very crude parser.
635
- *
636
- * @param {string} text A string with the code to be highlighted.
637
- * @param {Grammar} grammar An object containing the tokens to use.
638
- *
639
- * Usually a language definition like `Prism.languages.markup`.
640
- * @returns {TokenStream} An array of strings and tokens, a token stream.
641
- * @memberof Prism
642
- * @public
643
- * @example
644
- * let code = `var foo = 0;`;
645
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
646
- * tokens.forEach(token => {
647
- * if (token instanceof Prism.Token && token.type === 'number') {
648
- * console.log(`Found numeric literal: ${token.content}`);
649
- * }
650
- * });
651
- */
652
- tokenize: function (text, grammar) {
653
- var rest = grammar.rest;
654
- if (rest) {
655
- for (var token in rest) {
656
- grammar[token] = rest[token];
657
- }
658
- delete grammar.rest;
659
- }
660
- var tokenList = new LinkedList();
661
- addAfter(tokenList, tokenList.head, text);
662
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
663
- return toArray(tokenList);
664
- },
665
- /**
666
- * @namespace
667
- * @memberof Prism
668
- * @public
669
- */
670
- hooks: {
671
- all: {},
672
- /**
673
- * Adds the given callback to the list of callbacks for the given hook.
674
- *
675
- * The callback will be invoked when the hook it is registered for is run.
676
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
677
- *
678
- * One callback function can be registered to multiple hooks and the same hook multiple times.
679
- *
680
- * @param {string} name The name of the hook.
681
- * @param {HookCallback} callback The callback function which is given environment variables.
682
- * @public
683
- */
684
- add: function (name, callback) {
685
- var hooks = _.hooks.all;
686
- hooks[name] = hooks[name] || [];
687
- hooks[name].push(callback);
688
- },
689
- /**
690
- * Runs a hook invoking all registered callbacks with the given environment variables.
691
- *
692
- * Callbacks will be invoked synchronously and in the order in which they were registered.
693
- *
694
- * @param {string} name The name of the hook.
695
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
696
- * @public
697
- */
698
- run: function (name, env) {
699
- var callbacks = _.hooks.all[name];
700
- if (!callbacks || !callbacks.length) {
701
- return;
702
- }
703
- for (var i = 0, callback; callback = callbacks[i++];) {
704
- callback(env);
705
- }
706
- }
707
- },
708
- Token: Token
709
- };
710
- _self.Prism = _;
711
-
712
- // Typescript note:
713
- // The following can be used to import the Token type in JSDoc:
714
- //
715
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
716
-
717
- /**
718
- * Creates a new token.
719
- *
720
- * @param {string} type See {@link Token#type type}
721
- * @param {string | TokenStream} content See {@link Token#content content}
722
- * @param {string|string[]} [alias] The alias(es) of the token.
723
- * @param {string} [matchedStr=""] A copy of the full string this token was created from.
724
- * @class
725
- * @global
726
- * @public
727
- */
728
- function Token(type, content, alias, matchedStr) {
729
- /**
730
- * The type of the token.
731
- *
732
- * This is usually the key of a pattern in a {@link Grammar}.
733
- *
734
- * @type {string}
735
- * @see GrammarToken
736
- * @public
737
- */
738
- this.type = type;
739
- /**
740
- * The strings or tokens contained by this token.
741
- *
742
- * This will be a token stream if the pattern matched also defined an `inside` grammar.
743
- *
744
- * @type {string | TokenStream}
745
- * @public
746
- */
747
- this.content = content;
748
- /**
749
- * The alias(es) of the token.
750
- *
751
- * @type {string|string[]}
752
- * @see GrammarToken
753
- * @public
754
- */
755
- this.alias = alias;
756
- // Copy of the full string this token was created from
757
- this.length = (matchedStr || '').length | 0;
758
- }
759
-
760
- /**
761
- * A token stream is an array of strings and {@link Token Token} objects.
762
- *
763
- * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
764
- * them.
765
- *
766
- * 1. No adjacent strings.
767
- * 2. No empty strings.
768
- *
769
- * The only exception here is the token stream that only contains the empty string and nothing else.
770
- *
771
- * @typedef {Array<string | Token>} TokenStream
772
- * @global
773
- * @public
774
- */
775
-
776
- /**
777
- * Converts the given token or token stream to an HTML representation.
778
- *
779
- * The following hooks will be run:
780
- * 1. `wrap`: On each {@link Token}.
781
- *
782
- * @param {string | Token | TokenStream} o The token or token stream to be converted.
783
- * @param {string} language The name of current language.
784
- * @returns {string} The HTML representation of the token or token stream.
785
- * @memberof Token
786
- * @static
787
- */
788
- Token.stringify = function stringify(o, language) {
789
- if (typeof o == 'string') {
790
- return o;
791
- }
792
- if (Array.isArray(o)) {
793
- var s = '';
794
- o.forEach(function (e) {
795
- s += stringify(e, language);
796
- });
797
- return s;
798
- }
799
- var env = {
800
- type: o.type,
801
- content: stringify(o.content, language),
802
- tag: 'span',
803
- classes: ['token', o.type],
804
- attributes: {},
805
- language: language
806
- };
807
- var aliases = o.alias;
808
- if (aliases) {
809
- if (Array.isArray(aliases)) {
810
- Array.prototype.push.apply(env.classes, aliases);
811
- } else {
812
- env.classes.push(aliases);
813
- }
814
- }
815
- _.hooks.run('wrap', env);
816
- var attributes = '';
817
- for (var name in env.attributes) {
818
- attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
819
- }
820
- return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
821
- };
822
-
823
- /**
824
- * @param {RegExp} pattern
825
- * @param {number} pos
826
- * @param {string} text
827
- * @param {boolean} lookbehind
828
- * @returns {RegExpExecArray | null}
829
- */
830
- function matchPattern(pattern, pos, text, lookbehind) {
831
- pattern.lastIndex = pos;
832
- var match = pattern.exec(text);
833
- if (match && lookbehind && match[1]) {
834
- // change the match to remove the text matched by the Prism lookbehind group
835
- var lookbehindLength = match[1].length;
836
- match.index += lookbehindLength;
837
- match[0] = match[0].slice(lookbehindLength);
838
- }
839
- return match;
840
- }
841
-
842
- /**
843
- * @param {string} text
844
- * @param {LinkedList<string | Token>} tokenList
845
- * @param {any} grammar
846
- * @param {LinkedListNode<string | Token>} startNode
847
- * @param {number} startPos
848
- * @param {RematchOptions} [rematch]
849
- * @returns {void}
850
- * @private
851
- *
852
- * @typedef RematchOptions
853
- * @property {string} cause
854
- * @property {number} reach
855
- */
856
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
857
- for (var token in grammar) {
858
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
859
- continue;
860
- }
861
- var patterns = grammar[token];
862
- patterns = Array.isArray(patterns) ? patterns : [patterns];
863
- for (var j = 0; j < patterns.length; ++j) {
864
- if (rematch && rematch.cause == token + ',' + j) {
865
- return;
866
- }
867
- var patternObj = patterns[j];
868
- var inside = patternObj.inside;
869
- var lookbehind = !!patternObj.lookbehind;
870
- var greedy = !!patternObj.greedy;
871
- var alias = patternObj.alias;
872
- if (greedy && !patternObj.pattern.global) {
873
- // Without the global flag, lastIndex won't work
874
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
875
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
876
- }
877
-
878
- /** @type {RegExp} */
879
- var pattern = patternObj.pattern || patternObj;
880
- for (
881
- // iterate the token list and keep track of the current token/string position
882
- var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
883
- if (rematch && pos >= rematch.reach) {
884
- break;
885
- }
886
- var str = currentNode.value;
887
- if (tokenList.length > text.length) {
888
- // Something went terribly wrong, ABORT, ABORT!
889
- return;
890
- }
891
- if (str instanceof Token) {
892
- continue;
893
- }
894
- var removeCount = 1; // this is the to parameter of removeBetween
895
- var match;
896
- if (greedy) {
897
- match = matchPattern(pattern, pos, text, lookbehind);
898
- if (!match || match.index >= text.length) {
899
- break;
900
- }
901
- var from = match.index;
902
- var to = match.index + match[0].length;
903
- var p = pos;
904
-
905
- // find the node that contains the match
906
- p += currentNode.value.length;
907
- while (from >= p) {
908
- currentNode = currentNode.next;
909
- p += currentNode.value.length;
910
- }
911
- // adjust pos (and p)
912
- p -= currentNode.value.length;
913
- pos = p;
914
-
915
- // the current node is a Token, then the match starts inside another Token, which is invalid
916
- if (currentNode.value instanceof Token) {
917
- continue;
918
- }
919
-
920
- // find the last node which is affected by this match
921
- for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === 'string'); k = k.next) {
922
- removeCount++;
923
- p += k.value.length;
924
- }
925
- removeCount--;
926
-
927
- // replace with the new match
928
- str = text.slice(pos, p);
929
- match.index -= pos;
930
- } else {
931
- match = matchPattern(pattern, 0, str, lookbehind);
932
- if (!match) {
933
- continue;
934
- }
935
- }
936
-
937
- // eslint-disable-next-line no-redeclare
938
- var from = match.index;
939
- var matchStr = match[0];
940
- var before = str.slice(0, from);
941
- var after = str.slice(from + matchStr.length);
942
- var reach = pos + str.length;
943
- if (rematch && reach > rematch.reach) {
944
- rematch.reach = reach;
945
- }
946
- var removeFrom = currentNode.prev;
947
- if (before) {
948
- removeFrom = addAfter(tokenList, removeFrom, before);
949
- pos += before.length;
950
- }
951
- removeRange(tokenList, removeFrom, removeCount);
952
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
953
- currentNode = addAfter(tokenList, removeFrom, wrapped);
954
- if (after) {
955
- addAfter(tokenList, currentNode, after);
956
- }
957
- if (removeCount > 1) {
958
- // at least one Token object was removed, so we have to do some rematching
959
- // this can only happen if the current pattern is greedy
960
-
961
- /** @type {RematchOptions} */
962
- var nestedRematch = {
963
- cause: token + ',' + j,
964
- reach: reach
965
- };
966
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
967
-
968
- // the reach might have been extended because of the rematching
969
- if (rematch && nestedRematch.reach > rematch.reach) {
970
- rematch.reach = nestedRematch.reach;
971
- }
972
- }
973
- }
974
- }
975
- }
976
- }
977
-
978
- /**
979
- * @typedef LinkedListNode
980
- * @property {T} value
981
- * @property {LinkedListNode<T> | null} prev The previous node.
982
- * @property {LinkedListNode<T> | null} next The next node.
983
- * @template T
984
- * @private
985
- */
986
-
987
- /**
988
- * @template T
989
- * @private
990
- */
991
- function LinkedList() {
992
- /** @type {LinkedListNode<T>} */
993
- var head = {
994
- value: null,
995
- prev: null,
996
- next: null
997
- };
998
- /** @type {LinkedListNode<T>} */
999
- var tail = {
1000
- value: null,
1001
- prev: head,
1002
- next: null
1003
- };
1004
- head.next = tail;
1005
-
1006
- /** @type {LinkedListNode<T>} */
1007
- this.head = head;
1008
- /** @type {LinkedListNode<T>} */
1009
- this.tail = tail;
1010
- this.length = 0;
1011
- }
1012
-
1013
- /**
1014
- * Adds a new node with the given value to the list.
1015
- *
1016
- * @param {LinkedList<T>} list
1017
- * @param {LinkedListNode<T>} node
1018
- * @param {T} value
1019
- * @returns {LinkedListNode<T>} The added node.
1020
- * @template T
1021
- */
1022
- function addAfter(list, node, value) {
1023
- // assumes that node != list.tail && values.length >= 0
1024
- var next = node.next;
1025
- var newNode = {
1026
- value: value,
1027
- prev: node,
1028
- next: next
1029
- };
1030
- node.next = newNode;
1031
- next.prev = newNode;
1032
- list.length++;
1033
- return newNode;
1034
- }
1035
- /**
1036
- * Removes `count` nodes after the given node. The given node will not be removed.
1037
- *
1038
- * @param {LinkedList<T>} list
1039
- * @param {LinkedListNode<T>} node
1040
- * @param {number} count
1041
- * @template T
1042
- */
1043
- function removeRange(list, node, count) {
1044
- var next = node.next;
1045
- for (var i = 0; i < count && next !== list.tail; i++) {
1046
- next = next.next;
1047
- }
1048
- node.next = next;
1049
- next.prev = node;
1050
- list.length -= i;
1051
- }
1052
- /**
1053
- * @param {LinkedList<T>} list
1054
- * @returns {T[]}
1055
- * @template T
1056
- */
1057
- function toArray(list) {
1058
- var array = [];
1059
- var node = list.head.next;
1060
- while (node !== list.tail) {
1061
- array.push(node.value);
1062
- node = node.next;
1063
- }
1064
- return array;
1065
- }
1066
- if (!_self.document) {
1067
- if (!_self.addEventListener) {
1068
- // in Node.js
1069
- return _;
1070
- }
1071
- if (!_.disableWorkerMessageHandler) {
1072
- // In worker
1073
- _self.addEventListener('message', function (evt) {
1074
- var message = JSON.parse(evt.data);
1075
- var lang = message.language;
1076
- var code = message.code;
1077
- var immediateClose = message.immediateClose;
1078
- _self.postMessage(_.highlight(code, _.languages[lang], lang));
1079
- if (immediateClose) {
1080
- _self.close();
1081
- }
1082
- }, false);
1083
- }
1084
- return _;
1085
- }
1086
-
1087
- // Get current script and highlight
1088
- var script = _.util.currentScript();
1089
- if (script) {
1090
- _.filename = script.src;
1091
- if (script.hasAttribute('data-manual')) {
1092
- _.manual = true;
1093
- }
1094
- }
1095
- function highlightAutomaticallyCallback() {
1096
- if (!_.manual) {
1097
- _.highlightAll();
1098
- }
1099
- }
1100
- if (!_.manual) {
1101
- // If the document state is "loading", then we'll use DOMContentLoaded.
1102
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1103
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1104
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
1105
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1106
- // See https://github.com/PrismJS/prism/issues/2102
1107
- var readyState = document.readyState;
1108
- if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1109
- document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1110
- } else {
1111
- if (window.requestAnimationFrame) {
1112
- window.requestAnimationFrame(highlightAutomaticallyCallback);
1113
- } else {
1114
- window.setTimeout(highlightAutomaticallyCallback, 16);
1115
- }
1116
- }
1117
- }
1118
- return _;
1119
- }(_self);
1120
- if (module.exports) {
1121
- module.exports = Prism;
1122
- }
1123
-
1124
- // hack for components to work correctly in node.js
1125
- if (typeof commonjsGlobal !== 'undefined') {
1126
- commonjsGlobal.Prism = Prism;
1127
- }
1128
-
1129
- // some additional documentation/types
1130
-
1131
- /**
1132
- * The expansion of a simple `RegExp` literal to support additional properties.
1133
- *
1134
- * @typedef GrammarToken
1135
- * @property {RegExp} pattern The regular expression of the token.
1136
- * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1137
- * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1138
- * @property {boolean} [greedy=false] Whether the token is greedy.
1139
- * @property {string|string[]} [alias] An optional alias or list of aliases.
1140
- * @property {Grammar} [inside] The nested grammar of this token.
1141
- *
1142
- * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1143
- *
1144
- * This can be used to make nested and even recursive language definitions.
1145
- *
1146
- * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1147
- * each another.
1148
- * @global
1149
- * @public
1150
- */
1151
-
1152
- /**
1153
- * @typedef Grammar
1154
- * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1155
- * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1156
- * @global
1157
- * @public
1158
- */
1159
-
1160
- /**
1161
- * A function which will invoked after an element was successfully highlighted.
1162
- *
1163
- * @callback HighlightCallback
1164
- * @param {Element} element The element successfully highlighted.
1165
- * @returns {void}
1166
- * @global
1167
- * @public
1168
- */
1169
-
1170
- /**
1171
- * @callback HookCallback
1172
- * @param {Object<string, any>} env The environment variables of the hook.
1173
- * @returns {void}
1174
- * @global
1175
- * @public
1176
- */
1177
-
1178
- /* **********************************************
1179
- Begin prism-markup.js
1180
- ********************************************** */
1181
-
1182
- Prism.languages.markup = {
1183
- 'comment': {
1184
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1185
- greedy: true
1186
- },
1187
- 'prolog': {
1188
- pattern: /<\?[\s\S]+?\?>/,
1189
- greedy: true
1190
- },
1191
- 'doctype': {
1192
- // https://www.w3.org/TR/xml/#NT-doctypedecl
1193
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1194
- greedy: true,
1195
- inside: {
1196
- 'internal-subset': {
1197
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1198
- lookbehind: true,
1199
- greedy: true,
1200
- inside: null // see below
1201
- },
1202
- 'string': {
1203
- pattern: /"[^"]*"|'[^']*'/,
1204
- greedy: true
1205
- },
1206
- 'punctuation': /^<!|>$|[[\]]/,
1207
- 'doctype-tag': /^DOCTYPE/i,
1208
- 'name': /[^\s<>'"]+/
1209
- }
1210
- },
1211
- 'cdata': {
1212
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1213
- greedy: true
1214
- },
1215
- 'tag': {
1216
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1217
- greedy: true,
1218
- inside: {
1219
- 'tag': {
1220
- pattern: /^<\/?[^\s>\/]+/,
1221
- inside: {
1222
- 'punctuation': /^<\/?/,
1223
- 'namespace': /^[^\s>\/:]+:/
1224
- }
1225
- },
1226
- 'special-attr': [],
1227
- 'attr-value': {
1228
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1229
- inside: {
1230
- 'punctuation': [{
1231
- pattern: /^=/,
1232
- alias: 'attr-equals'
1233
- }, {
1234
- pattern: /^(\s*)["']|["']$/,
1235
- lookbehind: true
1236
- }]
1237
- }
1238
- },
1239
- 'punctuation': /\/?>/,
1240
- 'attr-name': {
1241
- pattern: /[^\s>\/]+/,
1242
- inside: {
1243
- 'namespace': /^[^\s>\/:]+:/
1244
- }
1245
- }
1246
- }
1247
- },
1248
- 'entity': [{
1249
- pattern: /&[\da-z]{1,8};/i,
1250
- alias: 'named-entity'
1251
- }, /&#x?[\da-f]{1,8};/i]
1252
- };
1253
- Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = Prism.languages.markup['entity'];
1254
- Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
1255
-
1256
- // Plugin to make entity title show the real entity, idea by Roman Komarov
1257
- Prism.hooks.add('wrap', function (env) {
1258
- if (env.type === 'entity') {
1259
- env.attributes['title'] = env.content.replace(/&amp;/, '&');
1260
- }
1261
- });
1262
- Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1263
- /**
1264
- * Adds an inlined language to markup.
1265
- *
1266
- * An example of an inlined language is CSS with `<style>` tags.
1267
- *
1268
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1269
- * case insensitive.
1270
- * @param {string} lang The language key.
1271
- * @example
1272
- * addInlined('style', 'css');
1273
- */
1274
- value: function addInlined(tagName, lang) {
1275
- var includedCdataInside = {};
1276
- includedCdataInside['language-' + lang] = {
1277
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1278
- lookbehind: true,
1279
- inside: Prism.languages[lang]
1280
- };
1281
- includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1282
- var inside = {
1283
- 'included-cdata': {
1284
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1285
- inside: includedCdataInside
1286
- }
1287
- };
1288
- inside['language-' + lang] = {
1289
- pattern: /[\s\S]+/,
1290
- inside: Prism.languages[lang]
1291
- };
1292
- var def = {};
1293
- def[tagName] = {
1294
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () {
1295
- return tagName;
1296
- }), 'i'),
1297
- lookbehind: true,
1298
- greedy: true,
1299
- inside: inside
1300
- };
1301
- Prism.languages.insertBefore('markup', 'cdata', def);
1302
- }
1303
- });
1304
- Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1305
- /**
1306
- * Adds an pattern to highlight languages embedded in HTML attributes.
1307
- *
1308
- * An example of an inlined language is CSS with `style` attributes.
1309
- *
1310
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1311
- * case insensitive.
1312
- * @param {string} lang The language key.
1313
- * @example
1314
- * addAttribute('style', 'css');
1315
- */
1316
- value: function (attrName, lang) {
1317
- Prism.languages.markup.tag.inside['special-attr'].push({
1318
- pattern: RegExp(/(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 'i'),
1319
- lookbehind: true,
1320
- inside: {
1321
- 'attr-name': /^[^\s=]+/,
1322
- 'attr-value': {
1323
- pattern: /=[\s\S]+/,
1324
- inside: {
1325
- 'value': {
1326
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1327
- lookbehind: true,
1328
- alias: [lang, 'language-' + lang],
1329
- inside: Prism.languages[lang]
1330
- },
1331
- 'punctuation': [{
1332
- pattern: /^=/,
1333
- alias: 'attr-equals'
1334
- }, /"|'/]
1335
- }
1336
- }
1337
- }
1338
- });
1339
- }
1340
- });
1341
- Prism.languages.html = Prism.languages.markup;
1342
- Prism.languages.mathml = Prism.languages.markup;
1343
- Prism.languages.svg = Prism.languages.markup;
1344
- Prism.languages.xml = Prism.languages.extend('markup', {});
1345
- Prism.languages.ssml = Prism.languages.xml;
1346
- Prism.languages.atom = Prism.languages.xml;
1347
- Prism.languages.rss = Prism.languages.xml;
1348
-
1349
- /* **********************************************
1350
- Begin prism-css.js
1351
- ********************************************** */
1352
-
1353
- (function (Prism) {
1354
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1355
- Prism.languages.css = {
1356
- 'comment': /\/\*[\s\S]*?\*\//,
1357
- 'atrule': {
1358
- pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
1359
- inside: {
1360
- 'rule': /^@[\w-]+/,
1361
- 'selector-function-argument': {
1362
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1363
- lookbehind: true,
1364
- alias: 'selector'
1365
- },
1366
- 'keyword': {
1367
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1368
- lookbehind: true
1369
- }
1370
- // See rest below
1371
- }
1372
- },
1373
- 'url': {
1374
- // https://drafts.csswg.org/css-values-3/#urls
1375
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1376
- greedy: true,
1377
- inside: {
1378
- 'function': /^url/i,
1379
- 'punctuation': /^\(|\)$/,
1380
- 'string': {
1381
- pattern: RegExp('^' + string.source + '$'),
1382
- alias: 'url'
1383
- }
1384
- }
1385
- },
1386
- 'selector': {
1387
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1388
- lookbehind: true
1389
- },
1390
- 'string': {
1391
- pattern: string,
1392
- greedy: true
1393
- },
1394
- 'property': {
1395
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1396
- lookbehind: true
1397
- },
1398
- 'important': /!important\b/i,
1399
- 'function': {
1400
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1401
- lookbehind: true
1402
- },
1403
- 'punctuation': /[(){};:,]/
1404
- };
1405
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1406
- var markup = Prism.languages.markup;
1407
- if (markup) {
1408
- markup.tag.addInlined('style', 'css');
1409
- markup.tag.addAttribute('style', 'css');
1410
- }
1411
- })(Prism);
1412
-
1413
- /* **********************************************
1414
- Begin prism-clike.js
1415
- ********************************************** */
1416
-
1417
- Prism.languages.clike = {
1418
- 'comment': [{
1419
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1420
- lookbehind: true,
1421
- greedy: true
1422
- }, {
1423
- pattern: /(^|[^\\:])\/\/.*/,
1424
- lookbehind: true,
1425
- greedy: true
1426
- }],
1427
- 'string': {
1428
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1429
- greedy: true
1430
- },
1431
- 'class-name': {
1432
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1433
- lookbehind: true,
1434
- inside: {
1435
- 'punctuation': /[.\\]/
1436
- }
1437
- },
1438
- 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1439
- 'boolean': /\b(?:false|true)\b/,
1440
- 'function': /\b\w+(?=\()/,
1441
- 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1442
- 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1443
- 'punctuation': /[{}[\];(),.:]/
1444
- };
1445
-
1446
- /* **********************************************
1447
- Begin prism-javascript.js
1448
- ********************************************** */
1449
-
1450
- Prism.languages.javascript = Prism.languages.extend('clike', {
1451
- 'class-name': [Prism.languages.clike['class-name'], {
1452
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1453
- lookbehind: true
1454
- }],
1455
- 'keyword': [{
1456
- pattern: /((?:^|\})\s*)catch\b/,
1457
- lookbehind: true
1458
- }, {
1459
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1460
- lookbehind: true
1461
- }],
1462
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1463
- 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1464
- 'number': {
1465
- pattern: RegExp(/(^|[^\w$])/.source + '(?:' + (
1466
- // constant
1467
- /NaN|Infinity/.source + '|' +
1468
- // binary integer
1469
- /0[bB][01]+(?:_[01]+)*n?/.source + '|' +
1470
- // octal integer
1471
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source + '|' +
1472
- // hexadecimal integer
1473
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + '|' +
1474
- // decimal bigint
1475
- /\d+(?:_\d+)*n/.source + '|' +
1476
- // decimal number (integer or float) but no bigint
1477
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ')' + /(?![\w$])/.source),
1478
- lookbehind: true
1479
- },
1480
- 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1481
- });
1482
- Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1483
- Prism.languages.insertBefore('javascript', 'keyword', {
1484
- 'regex': {
1485
- pattern: RegExp(
1486
- // lookbehind
1487
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
1488
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
1489
- // Regex pattern:
1490
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1491
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1492
- // with the only syntax, so we have to define 2 different regex patterns.
1493
- /\//.source + '(?:' + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + '|' +
1494
- // `v` flag syntax. This supports 3 levels of nested character classes.
1495
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ')' +
1496
- // lookahead
1497
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),
1498
- lookbehind: true,
1499
- greedy: true,
1500
- inside: {
1501
- 'regex-source': {
1502
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1503
- lookbehind: true,
1504
- alias: 'language-regex',
1505
- inside: Prism.languages.regex
1506
- },
1507
- 'regex-delimiter': /^\/|\/$/,
1508
- 'regex-flags': /^[a-z]+$/
1509
- }
1510
- },
1511
- // This must be declared before keyword because we use "function" inside the look-forward
1512
- 'function-variable': {
1513
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
1514
- alias: 'function'
1515
- },
1516
- 'parameter': [{
1517
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1518
- lookbehind: true,
1519
- inside: Prism.languages.javascript
1520
- }, {
1521
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1522
- lookbehind: true,
1523
- inside: Prism.languages.javascript
1524
- }, {
1525
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1526
- lookbehind: true,
1527
- inside: Prism.languages.javascript
1528
- }, {
1529
- pattern: /((?:\b|\s|^)(?!(?: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|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
1530
- lookbehind: true,
1531
- inside: Prism.languages.javascript
1532
- }],
1533
- 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1534
- });
1535
- Prism.languages.insertBefore('javascript', 'string', {
1536
- 'hashbang': {
1537
- pattern: /^#!.*/,
1538
- greedy: true,
1539
- alias: 'comment'
1540
- },
1541
- 'template-string': {
1542
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1543
- greedy: true,
1544
- inside: {
1545
- 'template-punctuation': {
1546
- pattern: /^`|`$/,
1547
- alias: 'string'
1548
- },
1549
- 'interpolation': {
1550
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1551
- lookbehind: true,
1552
- inside: {
1553
- 'interpolation-punctuation': {
1554
- pattern: /^\$\{|\}$/,
1555
- alias: 'punctuation'
1556
- },
1557
- rest: Prism.languages.javascript
1558
- }
1559
- },
1560
- 'string': /[\s\S]+/
1561
- }
1562
- },
1563
- 'string-property': {
1564
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1565
- lookbehind: true,
1566
- greedy: true,
1567
- alias: 'property'
1568
- }
1569
- });
1570
- Prism.languages.insertBefore('javascript', 'operator', {
1571
- 'literal-property': {
1572
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1573
- lookbehind: true,
1574
- alias: 'property'
1575
- }
1576
- });
1577
- if (Prism.languages.markup) {
1578
- Prism.languages.markup.tag.addInlined('script', 'javascript');
1579
-
1580
- // add attribute support for all DOM events.
1581
- // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1582
- Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 'javascript');
1583
- }
1584
- Prism.languages.js = Prism.languages.javascript;
1585
-
1586
- /* **********************************************
1587
- Begin prism-file-highlight.js
1588
- ********************************************** */
1589
-
1590
- (function () {
1591
- if (typeof Prism === 'undefined' || typeof document === 'undefined') {
1592
- return;
1593
- }
1594
-
1595
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
1596
- if (!Element.prototype.matches) {
1597
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1598
- }
1599
- var LOADING_MESSAGE = 'Loading…';
1600
- var FAILURE_MESSAGE = function (status, message) {
1601
- return '✖ Error ' + status + ' while fetching file: ' + message;
1602
- };
1603
- var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
1604
- var EXTENSIONS = {
1605
- 'js': 'javascript',
1606
- 'py': 'python',
1607
- 'rb': 'ruby',
1608
- 'ps1': 'powershell',
1609
- 'psm1': 'powershell',
1610
- 'sh': 'bash',
1611
- 'bat': 'batch',
1612
- 'h': 'c',
1613
- 'tex': 'latex'
1614
- };
1615
- var STATUS_ATTR = 'data-src-status';
1616
- var STATUS_LOADING = 'loading';
1617
- var STATUS_LOADED = 'loaded';
1618
- var STATUS_FAILED = 'failed';
1619
- var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])' + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
1620
-
1621
- /**
1622
- * Loads the given file.
1623
- *
1624
- * @param {string} src The URL or path of the source file to load.
1625
- * @param {(result: string) => void} success
1626
- * @param {(reason: string) => void} error
1627
- */
1628
- function loadFile(src, success, error) {
1629
- var xhr = new XMLHttpRequest();
1630
- xhr.open('GET', src, true);
1631
- xhr.onreadystatechange = function () {
1632
- if (xhr.readyState == 4) {
1633
- if (xhr.status < 400 && xhr.responseText) {
1634
- success(xhr.responseText);
1635
- } else {
1636
- if (xhr.status >= 400) {
1637
- error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
1638
- } else {
1639
- error(FAILURE_EMPTY_MESSAGE);
1640
- }
1641
- }
1642
- }
1643
- };
1644
- xhr.send(null);
1645
- }
1646
-
1647
- /**
1648
- * Parses the given range.
1649
- *
1650
- * This returns a range with inclusive ends.
1651
- *
1652
- * @param {string | null | undefined} range
1653
- * @returns {[number, number | undefined] | undefined}
1654
- */
1655
- function parseRange(range) {
1656
- var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
1657
- if (m) {
1658
- var start = Number(m[1]);
1659
- var comma = m[2];
1660
- var end = m[3];
1661
- if (!comma) {
1662
- return [start, start];
1663
- }
1664
- if (!end) {
1665
- return [start, undefined];
1666
- }
1667
- return [start, Number(end)];
1668
- }
1669
- return undefined;
1670
- }
1671
- Prism.hooks.add('before-highlightall', function (env) {
1672
- env.selector += ', ' + SELECTOR;
1673
- });
1674
- Prism.hooks.add('before-sanity-check', function (env) {
1675
- var pre = /** @type {HTMLPreElement} */env.element;
1676
- if (pre.matches(SELECTOR)) {
1677
- env.code = ''; // fast-path the whole thing and go to complete
1678
-
1679
- pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
1680
-
1681
- // add code element with loading message
1682
- var code = pre.appendChild(document.createElement('CODE'));
1683
- code.textContent = LOADING_MESSAGE;
1684
- var src = pre.getAttribute('data-src');
1685
- var language = env.language;
1686
- if (language === 'none') {
1687
- // the language might be 'none' because there is no language set;
1688
- // in this case, we want to use the extension as the language
1689
- var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
1690
- language = EXTENSIONS[extension] || extension;
1691
- }
1692
-
1693
- // set language classes
1694
- Prism.util.setLanguage(code, language);
1695
- Prism.util.setLanguage(pre, language);
1696
-
1697
- // preload the language
1698
- var autoloader = Prism.plugins.autoloader;
1699
- if (autoloader) {
1700
- autoloader.loadLanguages(language);
1701
- }
1702
-
1703
- // load file
1704
- loadFile(src, function (text) {
1705
- // mark as loaded
1706
- pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
1707
-
1708
- // handle data-range
1709
- var range = parseRange(pre.getAttribute('data-range'));
1710
- if (range) {
1711
- var lines = text.split(/\r\n?|\n/g);
1712
-
1713
- // the range is one-based and inclusive on both ends
1714
- var start = range[0];
1715
- var end = range[1] == null ? lines.length : range[1];
1716
- if (start < 0) {
1717
- start += lines.length;
1718
- }
1719
- start = Math.max(0, Math.min(start - 1, lines.length));
1720
- if (end < 0) {
1721
- end += lines.length;
1722
- }
1723
- end = Math.max(0, Math.min(end, lines.length));
1724
- text = lines.slice(start, end).join('\n');
1725
-
1726
- // add data-start for line numbers
1727
- if (!pre.hasAttribute('data-start')) {
1728
- pre.setAttribute('data-start', String(start + 1));
1729
- }
1730
- }
1731
-
1732
- // highlight code
1733
- code.textContent = text;
1734
- Prism.highlightElement(code);
1735
- }, function (error) {
1736
- // mark as failed
1737
- pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
1738
- code.textContent = error;
1739
- });
1740
- }
1741
- });
1742
- Prism.plugins.fileHighlight = {
1743
- /**
1744
- * Executes the File Highlight plugin for all matching `pre` elements under the given container.
1745
- *
1746
- * Note: Elements which are already loaded or currently loading will not be touched by this method.
1747
- *
1748
- * @param {ParentNode} [container=document]
1749
- */
1750
- highlight: function highlight(container) {
1751
- var elements = (container || document).querySelectorAll(SELECTOR);
1752
- for (var i = 0, element; element = elements[i++];) {
1753
- Prism.highlightElement(element);
1754
- }
1755
- }
1756
- };
1757
- var logged = false;
1758
- /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
1759
- Prism.fileHighlight = function () {
1760
- if (!logged) {
1761
- console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
1762
- logged = true;
1763
- }
1764
- Prism.plugins.fileHighlight.highlight.apply(this, arguments);
1765
- };
1766
- })();
1767
- })(prism);
1768
- const Prism$1 = prism.exports;
1769
- Prism.languages.python = {
1770
- 'comment': {
1771
- pattern: /(^|[^\\])#.*/,
1772
- lookbehind: true,
1773
- greedy: true
1774
- },
1775
- 'string-interpolation': {
1776
- pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
1777
- greedy: true,
1778
- inside: {
1779
- 'interpolation': {
1780
- // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
1781
- pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
1782
- lookbehind: true,
1783
- inside: {
1784
- 'format-spec': {
1785
- pattern: /(:)[^:(){}]+(?=\}$)/,
1786
- lookbehind: true
1787
- },
1788
- 'conversion-option': {
1789
- pattern: /![sra](?=[:}]$)/,
1790
- alias: 'punctuation'
1791
- },
1792
- rest: null
1793
- }
1794
- },
1795
- 'string': /[\s\S]+/
1796
- }
1797
- },
1798
- 'triple-quoted-string': {
1799
- pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
1800
- greedy: true,
1801
- alias: 'string'
1802
- },
1803
- 'string': {
1804
- pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
1805
- greedy: true
1806
- },
1807
- 'function': {
1808
- pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
1809
- lookbehind: true
1810
- },
1811
- 'class-name': {
1812
- pattern: /(\bclass\s+)\w+/i,
1813
- lookbehind: true
1814
- },
1815
- 'decorator': {
1816
- pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
1817
- lookbehind: true,
1818
- alias: ['annotation', 'punctuation'],
1819
- inside: {
1820
- 'punctuation': /\./
1821
- }
1822
- },
1823
- 'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
1824
- 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
1825
- 'boolean': /\b(?:False|None|True)\b/,
1826
- 'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
1827
- 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
1828
- 'punctuation': /[{}[\];(),.:]/
1829
- };
1830
- Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
1831
- Prism.languages.py = Prism.languages.python;
1832
- (function (Prism) {
1833
- // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
1834
- // + LC_ALL, RANDOM, REPLY, SECONDS.
1835
- // + make sure PS1..4 are here as they are not always set,
1836
- // - some useless things.
1837
- var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
1838
- var commandAfterHeredoc = {
1839
- pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
1840
- lookbehind: true,
1841
- alias: 'punctuation',
1842
- // this looks reasonably well in all themes
1843
- inside: null // see below
1844
- };
1845
- var insideString = {
1846
- 'bash': commandAfterHeredoc,
1847
- 'environment': {
1848
- pattern: RegExp('\\$' + envVars),
1849
- alias: 'constant'
1850
- },
1851
- 'variable': [
1852
- // [0]: Arithmetic Environment
1853
- {
1854
- pattern: /\$?\(\([\s\S]+?\)\)/,
1855
- greedy: true,
1856
- inside: {
1857
- // If there is a $ sign at the beginning highlight $(( and )) as variable
1858
- 'variable': [{
1859
- pattern: /(^\$\(\([\s\S]+)\)\)/,
1860
- lookbehind: true
1861
- }, /^\$\(\(/],
1862
- 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
1863
- // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
1864
- 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
1865
- // If there is no $ sign at the beginning highlight (( and )) as punctuation
1866
- 'punctuation': /\(\(?|\)\)?|,|;/
1867
- }
1868
- },
1869
- // [1]: Command Substitution
1870
- {
1871
- pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
1872
- greedy: true,
1873
- inside: {
1874
- 'variable': /^\$\(|^`|\)$|`$/
1875
- }
1876
- },
1877
- // [2]: Brace expansion
1878
- {
1879
- pattern: /\$\{[^}]+\}/,
1880
- greedy: true,
1881
- inside: {
1882
- 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
1883
- 'punctuation': /[\[\]]/,
1884
- 'environment': {
1885
- pattern: RegExp('(\\{)' + envVars),
1886
- lookbehind: true,
1887
- alias: 'constant'
1888
- }
1889
- }
1890
- }, /\$(?:\w+|[#?*!@$])/],
1891
- // Escape sequences from echo and printf's manuals, and escaped quotes.
1892
- 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
1893
- };
1894
- Prism.languages.bash = {
1895
- 'shebang': {
1896
- pattern: /^#!\s*\/.*/,
1897
- alias: 'important'
1898
- },
1899
- 'comment': {
1900
- pattern: /(^|[^"{\\$])#.*/,
1901
- lookbehind: true
1902
- },
1903
- 'function-name': [
1904
- // a) function foo {
1905
- // b) foo() {
1906
- // c) function foo() {
1907
- // but not “foo {”
1908
- {
1909
- // a) and c)
1910
- pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
1911
- lookbehind: true,
1912
- alias: 'function'
1913
- }, {
1914
- // b)
1915
- pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
1916
- alias: 'function'
1917
- }],
1918
- // Highlight variable names as variables in for and select beginnings.
1919
- 'for-or-select': {
1920
- pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
1921
- alias: 'variable',
1922
- lookbehind: true
1923
- },
1924
- // Highlight variable names as variables in the left-hand part
1925
- // of assignments (“=” and “+=”).
1926
- 'assign-left': {
1927
- pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
1928
- inside: {
1929
- 'environment': {
1930
- pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
1931
- lookbehind: true,
1932
- alias: 'constant'
1933
- }
1934
- },
1935
- alias: 'variable',
1936
- lookbehind: true
1937
- },
1938
- // Highlight parameter names as variables
1939
- 'parameter': {
1940
- pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
1941
- alias: 'variable',
1942
- lookbehind: true
1943
- },
1944
- 'string': [
1945
- // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
1946
- {
1947
- pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
1948
- lookbehind: true,
1949
- greedy: true,
1950
- inside: insideString
1951
- },
1952
- // Here-document with quotes around the tag
1953
- // → No expansion (so no “inside”).
1954
- {
1955
- pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
1956
- lookbehind: true,
1957
- greedy: true,
1958
- inside: {
1959
- 'bash': commandAfterHeredoc
1960
- }
1961
- },
1962
- // “Normal” string
1963
- {
1964
- // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
1965
- pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
1966
- lookbehind: true,
1967
- greedy: true,
1968
- inside: insideString
1969
- }, {
1970
- // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
1971
- pattern: /(^|[^$\\])'[^']*'/,
1972
- lookbehind: true,
1973
- greedy: true
1974
- }, {
1975
- // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
1976
- pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
1977
- greedy: true,
1978
- inside: {
1979
- 'entity': insideString.entity
1980
- }
1981
- }],
1982
- 'environment': {
1983
- pattern: RegExp('\\$?' + envVars),
1984
- alias: 'constant'
1985
- },
1986
- 'variable': insideString.variable,
1987
- 'function': {
1988
- pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1989
- lookbehind: true
1990
- },
1991
- 'keyword': {
1992
- pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
1993
- lookbehind: true
1994
- },
1995
- // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1996
- 'builtin': {
1997
- pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
1998
- lookbehind: true,
1999
- // Alias added to make those easier to distinguish from strings.
2000
- alias: 'class-name'
2001
- },
2002
- 'boolean': {
2003
- pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
2004
- lookbehind: true
2005
- },
2006
- 'file-descriptor': {
2007
- pattern: /\B&\d\b/,
2008
- alias: 'important'
2009
- },
2010
- 'operator': {
2011
- // Lots of redirections here, but not just that.
2012
- pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
2013
- inside: {
2014
- 'file-descriptor': {
2015
- pattern: /^\d/,
2016
- alias: 'important'
2017
- }
2018
- }
2019
- },
2020
- 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
2021
- 'number': {
2022
- pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
2023
- lookbehind: true
2024
- }
2025
- };
2026
- commandAfterHeredoc.inside = Prism.languages.bash;
2027
-
2028
- /* Patterns in command substitution. */
2029
- var toBeCopied = ['comment', 'function-name', 'for-or-select', 'assign-left', 'parameter', 'string', 'environment', 'function', 'keyword', 'builtin', 'boolean', 'file-descriptor', 'operator', 'punctuation', 'number'];
2030
- var inside = insideString.variable[1].inside;
2031
- for (var i = 0; i < toBeCopied.length; i++) {
2032
- inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
2033
- }
2034
- Prism.languages.sh = Prism.languages.bash;
2035
- Prism.languages.shell = Prism.languages.bash;
2036
- })(Prism);
2037
- (function (Prism) {
2038
- // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
2039
- // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
2040
- var anchorOrAlias = /[*&][^\s[\]{},]+/;
2041
- // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
2042
- var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
2043
- // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
2044
- var properties = '(?:' + tag.source + '(?:[ \t]+' + anchorOrAlias.source + ')?|' + anchorOrAlias.source + '(?:[ \t]+' + tag.source + ')?)';
2045
- // https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
2046
- // This is a simplified version that doesn't support "#" and multiline keys
2047
- // All these long scarry character classes are simplified versions of YAML's characters
2048
- var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, function () {
2049
- return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
2050
- });
2051
- var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
2052
-
2053
- /**
2054
- *
2055
- * @param {string} value
2056
- * @param {string} [flags]
2057
- * @returns {RegExp}
2058
- */
2059
- function createValuePattern(value, flags) {
2060
- flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
2061
- var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function () {
2062
- return properties;
2063
- }).replace(/<<value>>/g, function () {
2064
- return value;
2065
- });
2066
- return RegExp(pattern, flags);
2067
- }
2068
- Prism.languages.yaml = {
2069
- 'scalar': {
2070
- pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, function () {
2071
- return properties;
2072
- })),
2073
- lookbehind: true,
2074
- alias: 'string'
2075
- },
2076
- 'comment': /#.*/,
2077
- 'key': {
2078
- pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function () {
2079
- return properties;
2080
- }).replace(/<<key>>/g, function () {
2081
- return '(?:' + plainKey + '|' + string + ')';
2082
- })),
2083
- lookbehind: true,
2084
- greedy: true,
2085
- alias: 'atrule'
2086
- },
2087
- 'directive': {
2088
- pattern: /(^[ \t]*)%.+/m,
2089
- lookbehind: true,
2090
- alias: 'important'
2091
- },
2092
- 'datetime': {
2093
- pattern: createValuePattern(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
2094
- lookbehind: true,
2095
- alias: 'number'
2096
- },
2097
- 'boolean': {
2098
- pattern: createValuePattern(/false|true/.source, 'i'),
2099
- lookbehind: true,
2100
- alias: 'important'
2101
- },
2102
- 'null': {
2103
- pattern: createValuePattern(/null|~/.source, 'i'),
2104
- lookbehind: true,
2105
- alias: 'important'
2106
- },
2107
- 'string': {
2108
- pattern: createValuePattern(string),
2109
- lookbehind: true,
2110
- greedy: true
2111
- },
2112
- 'number': {
2113
- pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, 'i'),
2114
- lookbehind: true
2115
- },
2116
- 'tag': tag,
2117
- 'important': anchorOrAlias,
2118
- 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
2119
- };
2120
- Prism.languages.yml = Prism.languages.yaml;
2121
- })(Prism);
2122
- (function (Prism) {
2123
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
2124
- Prism.languages.css = {
2125
- 'comment': /\/\*[\s\S]*?\*\//,
2126
- 'atrule': {
2127
- pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
2128
- inside: {
2129
- 'rule': /^@[\w-]+/,
2130
- 'selector-function-argument': {
2131
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
2132
- lookbehind: true,
2133
- alias: 'selector'
2134
- },
2135
- 'keyword': {
2136
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
2137
- lookbehind: true
2138
- }
2139
- // See rest below
2140
- }
2141
- },
2142
- 'url': {
2143
- // https://drafts.csswg.org/css-values-3/#urls
2144
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
2145
- greedy: true,
2146
- inside: {
2147
- 'function': /^url/i,
2148
- 'punctuation': /^\(|\)$/,
2149
- 'string': {
2150
- pattern: RegExp('^' + string.source + '$'),
2151
- alias: 'url'
2152
- }
2153
- }
2154
- },
2155
- 'selector': {
2156
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
2157
- lookbehind: true
2158
- },
2159
- 'string': {
2160
- pattern: string,
2161
- greedy: true
2162
- },
2163
- 'property': {
2164
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
2165
- lookbehind: true
2166
- },
2167
- 'important': /!important\b/i,
2168
- 'function': {
2169
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
2170
- lookbehind: true
2171
- },
2172
- 'punctuation': /[(){};:,]/
2173
- };
2174
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2175
- var markup = Prism.languages.markup;
2176
- if (markup) {
2177
- markup.tag.addInlined('style', 'css');
2178
- markup.tag.addAttribute('style', 'css');
2179
- }
2180
- })(Prism);
2181
- const edsCodeBlockCss = ":host{display:block;font-family:var(--font-family, 'Courier New', monospace)}pre[class*=\"language-\"]{white-space:pre-wrap;word-break:break-word;}.language{font-weight:bold;text-transform:uppercase}pre{margin:0;border-radius:8px;color:var(--purple-200);overflow:auto}code{font-family:'Courier New', monospace}.token.keyword{color:var(--purple-500)}.token.string{color:var(--green-500)}.token.function{color:var(--cyan-500)}.token.comment{color:var(--grey-700)}.relative{position:relative}.bg-stronger{background-color:var(--grey-900)}.rounded-sm{border-radius:8px}.rounded-xs{border-radius:4px}.text-inverse{color:var(--white)}.text-light{color:var(--grey-700)}.text-lighter{color:var(--grey-600)}.text-lightest{color:var(--grey-500)}.flex{display:flex}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.p-0{padding:0rem}.p-12{padding:0.75rem}.p-16{padding:1rem}.p-20{padding:1.25rem}.p-6{padding:0.375rem}.p-8{padding:0.5rem}.pl-8{padding-left:0.5rem}.mb-10{margin-bottom:0.625rem}.mb-12{margin-bottom:0.75rem}.mb-28{margin-bottom:1.75rem}.pb-16{padding-bottom:1rem}.pb-20{padding-bottom:1.25rem}.pb-28{padding-bottom:1.75rem}.pb-60{padding-bottom:3.75rem}.pb-8{padding-bottom:0.5rem}.mt-16{margin-top:1rem}.mt-2{margin-top:0.125rem}.mt-20{margin-top:1.25rem}.mt-28{margin-top:1.75rem}.w-20{width:1.25rem}.h-20{height:1.25rem}.f-ui-03{font-family:var(--f-ui-03-fontFamily);font-weight:var(--f-ui-03-fontWeight);font-size:var(--f-ui-03-fontSize);line-height:var(--f-ui-03-lineHeight);letter-spacing:var(--f-ui-03-letterSpacing)}.f-ui-03-light{font-family:var(--f-ui-03-light-fontFamily);font-weight:var(--f-ui-03-light-fontWeight);font-size:var(--f-ui-03-light-fontSize);line-height:var(--f-ui-03-light-lineHeight);letter-spacing:var(--f-ui-03-light-letterSpacing)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}";
2182
- const EdsCodeBlockStyle0 = edsCodeBlockCss;
2183
- const EdsCodeBlock = class {
2184
- constructor(hostRef) {
2185
- registerInstance(this, hostRef);
2186
- this.code = undefined;
2187
- this.language = undefined;
2188
- this.copied = false;
2189
- }
2190
- /**
2191
- * Copies the current code content to the clipboard and sets a temporary copied state.
2192
- *
2193
- * @private
2194
- * @returns {void}
2195
- */
2196
- copyToClipboard() {
2197
- navigator.clipboard.writeText(this.code).then(() => {
2198
- this.copied = true;
2199
- /*const analyticsName = this.createHumanFriendlyAnalyticsName(this.code, this.language);
2200
- sendAnalytics({
2201
- category: 'ui-component',
2202
- parentContext: null,
2203
- tag: this.el.tagName.toLowerCase(),
2204
- name: analyticsName || '',
2205
- action: 'copy'
2206
- });*/
2207
- setTimeout(() => this.copied = false, 2000);
2208
- });
2209
- }
2210
- /**
2211
- * Utility function that creates a human-friendly analytics name based on the code and language.
2212
- * It uses:
2213
- * - The language (in uppercase)
2214
- * - The number of non-empty lines in the code
2215
- * - The first non-empty line of code (truncated to 30 characters, if needed)
2216
- *
2217
- * returns A descriptive analytics name.
2218
- */
2219
- /*private createHumanFriendlyAnalyticsName(code: string, language: string): string {
2220
- // Count non-empty lines
2221
- const lines = code.split('\n').filter(line => line.trim() !== '').length;
2222
-
2223
- // Find the first non-empty line and trim it
2224
- let firstNonEmptyLine = code.split('\n').find(line => line.trim() !== '');
2225
- firstNonEmptyLine = firstNonEmptyLine ? firstNonEmptyLine.trim() : '';
2226
- // Truncate the snippet if it’s too long
2227
- if (firstNonEmptyLine.length > 30) {
2228
- firstNonEmptyLine = firstNonEmptyLine.substring(0, 30) + '...';
2229
- }
2230
- return `CodeBlock:${language.toLowerCase()}|${lines}-line(s)|${firstNonEmptyLine.toLowerCase()}`;
2231
- }*/
2232
- /**
2233
- * Returns the syntax-highlighted HTML for the code.
2234
- * If the provided language is supported by Prism, this method returns the highlighted code.
2235
- * Otherwise, it logs a warning and returns the raw code.
2236
- *
2237
- * @private
2238
- * @returns {string} The highlighted HTML string for the code block.
2239
- */
2240
- getHighlightedCode() {
2241
- if (this.language && Prism$1.languages[this.language]) {
2242
- return Prism$1.highlight(this.code, Prism$1.languages[this.language], this.language);
2243
- }
2244
- // eslint-disable-next-line
2245
- //console.warn(`Unsupported or missing language: ${this.language}`);
2246
- return this.code; // Fallback if language is not provided or unsupported
2247
- }
2248
- render() {
2249
- return h("div", {
2250
- key: '7550f1c5e29a9be39614404d51dfec9a7aa194a9',
2251
- class: "relative bg-stronger rounded-sm"
2252
- }, h("div", {
2253
- key: '8e654051ec6105e051af723e056b4151afc4305c',
2254
- class: "text-inverse flex justify-between items-center p-8"
2255
- }, this.language ? h("span", {
2256
- class: "f-ui-03"
2257
- }, this.language.toUpperCase()) : h("pre", {
2258
- class: "bg-stronger pl-8",
2259
- role: "region",
2260
- "aria-label": "Code block without language"
2261
- }, h("code", {
2262
- innerHTML: this.getHighlightedCode()
2263
- })), h("span", {
2264
- key: '1f558301727adb451524850b352844d7658f33a8',
2265
- "aria-hidden": "true",
2266
- class: "w-20 h-20 mt-8"
2267
- }, h("eds-icon-wrapper", {
2268
- key: '7def1f38f949c32d6138d88a0a7edf9655852491',
2269
- icon: this.copied ? 'success' : 'copy',
2270
- onClick: () => this.copyToClipboard()
2271
- })), h("span", {
2272
- key: '9eabcd54f3bcdc1c4627a7ca7e22fd38e9755ca6',
2273
- class: "sr-only"
2274
- }, "Copy Code")), this.language && h("pre", {
2275
- key: 'd15dce4b1692bf1956e1b3cb3586dde4d9561f1b',
2276
- class: `language-${this.language} bg-stronger pl-8 pb-8`,
2277
- role: "region",
2278
- "aria-label": `Code block in ${this.language}`
2279
- }, h("code", {
2280
- key: 'ad7eb7b40aaab69b6bc929c632ce4736fe3c39a5',
2281
- innerHTML: this.getHighlightedCode()
2282
- })));
2283
- }
2284
- get el() {
2285
- return getElement(this);
2286
- }
2287
- };
2288
- EdsCodeBlock.style = EdsCodeBlockStyle0;
2289
-
2290
- export { EdsCodeBlock as eds_code_block };