@salesforcedevs/docs-components 0.0.4 → 0.0.5-edit

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 (140) hide show
  1. package/lwc.config.json +25 -2
  2. package/package.json +18 -7
  3. package/src/modules/README.md +41 -0
  4. package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
  5. package/src/modules/doc/amfReference/amfReference.css +25 -0
  6. package/src/modules/doc/amfReference/amfReference.html +60 -0
  7. package/src/modules/doc/amfReference/amfReference.ts +1494 -0
  8. package/src/modules/doc/amfReference/constants.ts +76 -0
  9. package/src/modules/doc/amfReference/types.ts +125 -0
  10. package/src/modules/doc/amfTopic/amfTopic.css +21 -0
  11. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  12. package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
  13. package/src/modules/doc/amfTopic/types.ts +56 -0
  14. package/src/modules/doc/amfTopic/utils.ts +136 -0
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
  16. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
  17. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +71 -0
  18. package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
  19. package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
  20. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
  21. package/src/modules/doc/chat/README.md +179 -0
  22. package/src/modules/doc/chat/chat.css +821 -0
  23. package/src/modules/doc/chat/chat.html +241 -0
  24. package/src/modules/doc/chat/chat.ts +586 -0
  25. package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
  26. package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
  27. package/src/modules/doc/componentPlayground/componentPlayground.ts +29 -0
  28. package/src/modules/doc/content/content.css +382 -6
  29. package/src/modules/doc/content/content.html +3 -2
  30. package/src/modules/doc/content/content.ts +287 -110
  31. package/src/modules/doc/contentCallout/contentCallout.css +25 -26
  32. package/src/modules/doc/contentCallout/contentCallout.html +13 -4
  33. package/src/modules/doc/contentCallout/contentCallout.ts +22 -11
  34. package/src/modules/doc/contentLayout/contentLayout.css +13 -0
  35. package/src/modules/doc/contentLayout/contentLayout.html +73 -0
  36. package/src/modules/doc/contentLayout/contentLayout.ts +531 -0
  37. package/src/modules/doc/contentMedia/contentMedia.css +49 -0
  38. package/src/modules/doc/contentMedia/contentMedia.html +23 -0
  39. package/src/modules/doc/contentMedia/contentMedia.ts +34 -0
  40. package/src/modules/doc/doDont/doDont.css +47 -0
  41. package/src/modules/doc/doDont/doDont.html +27 -0
  42. package/src/modules/doc/doDont/doDont.ts +17 -0
  43. package/src/modules/doc/editFile/editFile.css +505 -0
  44. package/src/modules/doc/editFile/editFile.html +164 -0
  45. package/src/modules/doc/editFile/editFile.ts +213 -0
  46. package/src/modules/doc/header/header.css +132 -0
  47. package/src/modules/doc/header/header.html +55 -0
  48. package/src/modules/doc/header/header.ts +120 -0
  49. package/src/modules/doc/heading/heading.css +33 -0
  50. package/src/modules/doc/heading/heading.html +14 -0
  51. package/src/modules/doc/heading/heading.ts +67 -0
  52. package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
  53. package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
  54. package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
  55. package/src/modules/doc/headingContent/headingContent.css +53 -0
  56. package/src/modules/doc/headingContent/headingContent.html +13 -0
  57. package/src/modules/doc/headingContent/headingContent.ts +30 -0
  58. package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
  59. package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
  60. package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +168 -0
  61. package/src/modules/doc/nav/nav.css +4 -2
  62. package/src/modules/doc/nav/nav.html +8 -13
  63. package/src/modules/doc/nav/nav.ts +1 -1
  64. package/src/modules/doc/overview/overview.css +40 -0
  65. package/src/modules/doc/overview/overview.html +34 -0
  66. package/src/modules/doc/overview/overview.ts +12 -0
  67. package/src/modules/doc/phase/phase.css +70 -0
  68. package/src/modules/doc/phase/phase.html +38 -0
  69. package/src/modules/doc/phase/phase.ts +93 -0
  70. package/src/modules/doc/specificationContent/specificationContent.css +36 -0
  71. package/src/modules/doc/specificationContent/specificationContent.html +171 -0
  72. package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
  73. package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
  74. package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
  75. package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
  76. package/src/modules/doc/toc/toc.html +11 -6
  77. package/src/modules/doc/toc/toc.ts +2 -6
  78. package/src/modules/doc/toolbar/toolbar.html +8 -1
  79. package/src/modules/doc/toolbar/toolbar.ts +1 -1
  80. package/src/modules/doc/versionPicker/versionPicker.css +64 -0
  81. package/src/modules/doc/versionPicker/versionPicker.html +38 -0
  82. package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
  83. package/src/modules/doc/xmlContent/types.ts +120 -0
  84. package/src/modules/doc/xmlContent/utils.ts +163 -0
  85. package/src/modules/doc/xmlContent/xmlContent.css +54 -0
  86. package/src/modules/doc/xmlContent/xmlContent.html +52 -0
  87. package/src/modules/doc/xmlContent/xmlContent.ts +792 -0
  88. package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
  89. package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
  90. package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
  91. package/src/modules/docHelpers/status/status.css +22 -0
  92. package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -0
  93. package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
  94. package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
  95. package/src/modules/docUtils/utils/utils.ts +32 -0
  96. package/src/modules/doc/container/__benchmarks__/container.benchmark.js +0 -43
  97. package/src/modules/doc/container/__mocks__/mockAvailableLanguages.js +0 -8
  98. package/src/modules/doc/container/__mocks__/mockAvailableVersions.js +0 -122
  99. package/src/modules/doc/container/__mocks__/mockContentFetchResponse.json +0 -5
  100. package/src/modules/doc/container/__mocks__/mockDocContent.js +0 -29
  101. package/src/modules/doc/container/__mocks__/mockNavigationFetchResponse.json +0 -4061
  102. package/src/modules/doc/container/__mocks__/mockPageReference.js +0 -8
  103. package/src/modules/doc/container/__mocks__/mockPdfUrl.js +0 -1
  104. package/src/modules/doc/container/__mocks__/mockSelectedLanguage.js +0 -8
  105. package/src/modules/doc/container/__mocks__/mockSelectedVersion.js +0 -8
  106. package/src/modules/doc/container/__mocks__/mockToc.js +0 -146
  107. package/src/modules/doc/container/__tests__/container.test.ts +0 -82
  108. package/src/modules/doc/container/container.css +0 -33
  109. package/src/modules/doc/container/container.html +0 -23
  110. package/src/modules/doc/container/container.stories.ts +0 -18
  111. package/src/modules/doc/container/container.ts +0 -360
  112. package/src/modules/doc/content/__tests__/content.test.ts +0 -30
  113. package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -29
  114. package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
  115. package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
  116. package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
  117. package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
  118. package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
  119. package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
  120. package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
  121. package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
  122. package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
  123. package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
  124. package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
  125. package/src/modules/doc/nav/__tests__/nav.test.ts +0 -66
  126. package/src/modules/doc/prismcss/prismcss.css +0 -184
  127. package/src/modules/doc/prismjs/prismjs.html +0 -3
  128. package/src/modules/doc/prismjs/prismjs.ts +0 -1842
  129. package/src/modules/doc/search/__tests__/search.test.ts +0 -20
  130. package/src/modules/doc/search/search.html +0 -1
  131. package/src/modules/doc/search/search.ts +0 -3
  132. package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
  133. package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
  134. package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
  135. package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
  136. package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
  137. package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
  138. package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
  139. package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
  140. package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
@@ -1,1842 +0,0 @@
1
- var commonjsGlobal =
2
- typeof globalThis !== "undefined"
3
- ? globalThis
4
- : typeof window !== "undefined"
5
- ? window
6
- : typeof global !== "undefined"
7
- ? global
8
- : typeof self !== "undefined"
9
- ? self
10
- : {};
11
-
12
- function createCommonjsModule(fn, basedir, module) {
13
- return (
14
- (module = {
15
- path: basedir,
16
- exports: {},
17
- require: function (path, base) {
18
- return commonjsRequire(
19
- path,
20
- base === undefined || base === null ? module.path : base
21
- );
22
- }
23
- }),
24
- fn(module, module.exports),
25
- module.exports
26
- );
27
- }
28
-
29
- function commonjsRequire() {
30
- throw new Error(
31
- "Dynamic requires are not currently supported by @rollup/plugin-commonjs"
32
- );
33
- }
34
-
35
- var prism = createCommonjsModule(function (module) {
36
- /* **********************************************
37
- Begin prism-core.js
38
- ********************************************** */
39
-
40
- /// <reference lib="WebWorker"/>
41
-
42
- var _self =
43
- typeof window !== "undefined"
44
- ? window // if in browser
45
- : typeof WorkerGlobalScope !== "undefined" &&
46
- self instanceof WorkerGlobalScope
47
- ? self // if in worker
48
- : {}; // if in node js
49
-
50
- /**
51
- * Prism: Lightweight, robust, elegant syntax highlighting
52
- *
53
- * @license MIT <https://opensource.org/licenses/MIT>
54
- * @author Lea Verou <https://lea.verou.me>
55
- * @namespace
56
- * @public
57
- */
58
- var Prism = (function (_self) {
59
- // Private helper vars
60
- var lang = /\blang(?:uage)?-([\w-]+)\b/i;
61
- var uniqueId = 0;
62
-
63
- var _ = {
64
- /**
65
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
66
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
67
- * additional languages or plugins yourself.
68
- *
69
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
70
- *
71
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
72
- * empty Prism object into the global scope before loading the Prism script like this:
73
- *
74
- * ```js
75
- * window.Prism = window.Prism || {};
76
- * Prism.manual = true;
77
- * // add a new <script> to load Prism's script
78
- * ```
79
- *
80
- * @default false
81
- * @type {boolean}
82
- * @memberof Prism
83
- * @public
84
- */
85
- manual: _self.Prism && _self.Prism.manual,
86
- disableWorkerMessageHandler:
87
- _self.Prism && _self.Prism.disableWorkerMessageHandler,
88
-
89
- /**
90
- * A namespace for utility methods.
91
- *
92
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
93
- * change or disappear at any time.
94
- *
95
- * @namespace
96
- * @memberof Prism
97
- */
98
- util: {
99
- encode: function encode(tokens) {
100
- if (tokens instanceof Token) {
101
- return new Token(
102
- tokens.type,
103
- encode(tokens.content),
104
- tokens.alias
105
- );
106
- } else if (Array.isArray(tokens)) {
107
- return tokens.map(encode);
108
- } else {
109
- return tokens
110
- .replace(/&/g, "&amp;")
111
- .replace(/</g, "&lt;")
112
- .replace(/\u00a0/g, " ");
113
- }
114
- },
115
-
116
- /**
117
- * Returns the name of the type of the given value.
118
- *
119
- * @param {any} o
120
- * @returns {string}
121
- * @example
122
- * type(null) === 'Null'
123
- * type(undefined) === 'Undefined'
124
- * type(123) === 'Number'
125
- * type('foo') === 'String'
126
- * type(true) === 'Boolean'
127
- * type([1, 2]) === 'Array'
128
- * type({}) === 'Object'
129
- * type(String) === 'Function'
130
- * type(/abc+/) === 'RegExp'
131
- */
132
- type: function (o) {
133
- return Object.prototype.toString.call(o).slice(8, -1);
134
- },
135
-
136
- /**
137
- * Returns a unique number for the given object. Later calls will still return the same number.
138
- *
139
- * @param {Object} obj
140
- * @returns {number}
141
- */
142
- objId: function (obj) {
143
- if (!obj["__id"]) {
144
- Object.defineProperty(obj, "__id", {
145
- value: ++uniqueId
146
- });
147
- }
148
- return obj["__id"];
149
- },
150
-
151
- /**
152
- * Creates a deep clone of the given object.
153
- *
154
- * The main intended use of this function is to clone language definitions.
155
- *
156
- * @param {T} o
157
- * @param {Record<number, any>} [visited]
158
- * @returns {T}
159
- * @template T
160
- */
161
- clone: function deepClone(o, visited) {
162
- visited = visited || {};
163
-
164
- var clone, id;
165
- switch (_.util.type(o)) {
166
- case "Object":
167
- id = _.util.objId(o);
168
- if (visited[id]) {
169
- return visited[id];
170
- }
171
- clone = /** @type {Record<string, any>} */ {};
172
- visited[id] = clone;
173
-
174
- for (var key in o) {
175
- if (o.hasOwnProperty(key)) {
176
- clone[key] = deepClone(o[key], visited);
177
- }
178
- }
179
-
180
- return /** @type {any} */ clone;
181
-
182
- case "Array":
183
- id = _.util.objId(o);
184
- if (visited[id]) {
185
- return visited[id];
186
- }
187
- clone = [];
188
- visited[id] = clone;
189
-
190
- /** @type {Array} */ o
191
- /** @type {any} */ .forEach(function (v, i) {
192
- clone[i] = deepClone(v, visited);
193
- });
194
-
195
- return /** @type {any} */ clone;
196
-
197
- default:
198
- return o;
199
- }
200
- },
201
-
202
- /**
203
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
204
- *
205
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
206
- *
207
- * @param {Element} element
208
- * @returns {string}
209
- */
210
- getLanguage: function (element) {
211
- while (element && !lang.test(element.className)) {
212
- element = element.parentElement;
213
- }
214
- if (element) {
215
- return (element.className.match(lang) || [
216
- ,
217
- "none"
218
- ])[1].toLowerCase();
219
- }
220
- return "none";
221
- },
222
-
223
- /**
224
- * Returns the script element that is currently executing.
225
- *
226
- * This does __not__ work for line script element.
227
- *
228
- * @returns {HTMLScriptElement | null}
229
- */
230
- currentScript: function () {
231
- if (typeof document === "undefined") {
232
- return null;
233
- }
234
- if (
235
- "currentScript" in document &&
236
- 1 < 2 /* hack to trip TS' flow analysis */
237
- ) {
238
- return /** @type {any} */ document.currentScript;
239
- }
240
-
241
- // IE11 workaround
242
- // we'll get the src of the current script by parsing IE11's error stack trace
243
- // this will not work for inline scripts
244
- try {
245
- throw new Error();
246
- } catch (err) {
247
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
248
- // A stack will look like this:
249
- //
250
- // Error
251
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
252
- // at Global code (http://localhost/components/prism-core.js:606:1)
253
-
254
- var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(
255
- err.stack
256
- ) || [])[1];
257
- if (src) {
258
- var scripts = document.getElementsByTagName(
259
- "script"
260
- );
261
- for (var i in scripts) {
262
- if (scripts[i].src == src) {
263
- return scripts[i];
264
- }
265
- }
266
- }
267
- return null;
268
- }
269
- },
270
-
271
- /**
272
- * Returns whether a given class is active for `element`.
273
- *
274
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
275
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
276
- * given class is just the given class with a `no-` prefix.
277
- *
278
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
279
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
280
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
281
- *
282
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
283
- * version of it, the class is considered active.
284
- *
285
- * @param {Element} element
286
- * @param {string} className
287
- * @param {boolean} [defaultActivation=false]
288
- * @returns {boolean}
289
- */
290
- isActive: function (element, className, defaultActivation) {
291
- var no = "no-" + className;
292
-
293
- while (element) {
294
- var classList = element.classList;
295
- if (classList.contains(className)) {
296
- return true;
297
- }
298
- if (classList.contains(no)) {
299
- return false;
300
- }
301
- element = element.parentElement;
302
- }
303
- return !!defaultActivation;
304
- }
305
- },
306
-
307
- /**
308
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
309
- *
310
- * @namespace
311
- * @memberof Prism
312
- * @public
313
- */
314
- languages: {
315
- /**
316
- * Creates a deep copy of the language with the given id and appends the given tokens.
317
- *
318
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
319
- * will be overwritten at its original position.
320
- *
321
- * ## Best practices
322
- *
323
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
324
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
325
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
326
- *
327
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
328
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
329
- *
330
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
331
- * @param {Grammar} redef The new tokens to append.
332
- * @returns {Grammar} The new language created.
333
- * @public
334
- * @example
335
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
336
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
337
- * // at its original position
338
- * 'comment': { ... },
339
- * // CSS doesn't have a 'color' token, so this token will be appended
340
- * 'color': /\b(?:red|green|blue)\b/
341
- * });
342
- */
343
- extend: function (id, redef) {
344
- var lang = _.util.clone(_.languages[id]);
345
-
346
- for (var key in redef) {
347
- lang[key] = redef[key];
348
- }
349
-
350
- return lang;
351
- },
352
-
353
- /**
354
- * Inserts tokens _before_ another token in a language definition or any other grammar.
355
- *
356
- * ## Usage
357
- *
358
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
359
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
360
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
361
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
362
- * this:
363
- *
364
- * ```js
365
- * Prism.languages.markup.style = {
366
- * // token
367
- * };
368
- * ```
369
- *
370
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
371
- * before existing tokens. For the CSS example above, you would use it like this:
372
- *
373
- * ```js
374
- * Prism.languages.insertBefore('markup', 'cdata', {
375
- * 'style': {
376
- * // token
377
- * }
378
- * });
379
- * ```
380
- *
381
- * ## Special cases
382
- *
383
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
384
- * will be ignored.
385
- *
386
- * This behavior can be used to insert tokens after `before`:
387
- *
388
- * ```js
389
- * Prism.languages.insertBefore('markup', 'comment', {
390
- * 'comment': Prism.languages.markup.comment,
391
- * // tokens after 'comment'
392
- * });
393
- * ```
394
- *
395
- * ## Limitations
396
- *
397
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
398
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
399
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
400
- * deleting properties which is necessary to insert at arbitrary positions.
401
- *
402
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
403
- * Instead, it will create a new object and replace all references to the target object with the new one. This
404
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
405
- *
406
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
407
- * you hold the target object in a variable, then the value of the variable will not change.
408
- *
409
- * ```js
410
- * var oldMarkup = Prism.languages.markup;
411
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
412
- *
413
- * assert(oldMarkup !== Prism.languages.markup);
414
- * assert(newMarkup === Prism.languages.markup);
415
- * ```
416
- *
417
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
418
- * object to be modified.
419
- * @param {string} before The key to insert before.
420
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
421
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
422
- * object to be modified.
423
- *
424
- * Defaults to `Prism.languages`.
425
- * @returns {Grammar} The new grammar object.
426
- * @public
427
- */
428
- insertBefore: function (inside, before, insert, root) {
429
- root = root || /** @type {any} */ _.languages;
430
- var grammar = root[inside];
431
- /** @type {Grammar} */
432
- var ret = {};
433
-
434
- for (var token in grammar) {
435
- if (grammar.hasOwnProperty(token)) {
436
- if (token == before) {
437
- for (var newToken in insert) {
438
- if (insert.hasOwnProperty(newToken)) {
439
- ret[newToken] = insert[newToken];
440
- }
441
- }
442
- }
443
-
444
- // Do not insert token which also occur in insert. See #1525
445
- if (!insert.hasOwnProperty(token)) {
446
- ret[token] = grammar[token];
447
- }
448
- }
449
- }
450
-
451
- var old = root[inside];
452
- root[inside] = ret;
453
-
454
- // Update references in other language definitions
455
- _.languages.DFS(_.languages, function (key, value) {
456
- if (value === old && key != inside) {
457
- this[key] = ret;
458
- }
459
- });
460
-
461
- return ret;
462
- },
463
-
464
- // Traverse a language definition with Depth First Search
465
- DFS: function DFS(o, callback, type, visited) {
466
- visited = visited || {};
467
-
468
- var objId = _.util.objId;
469
-
470
- for (var i in o) {
471
- if (o.hasOwnProperty(i)) {
472
- callback.call(o, i, o[i], type || i);
473
-
474
- var property = o[i],
475
- propertyType = _.util.type(property);
476
-
477
- if (
478
- propertyType === "Object" &&
479
- !visited[objId(property)]
480
- ) {
481
- visited[objId(property)] = true;
482
- DFS(property, callback, null, visited);
483
- } else if (
484
- propertyType === "Array" &&
485
- !visited[objId(property)]
486
- ) {
487
- visited[objId(property)] = true;
488
- DFS(property, callback, i, visited);
489
- }
490
- }
491
- }
492
- }
493
- },
494
-
495
- plugins: {},
496
-
497
- /**
498
- * This is the most high-level function in Prism’s API.
499
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
500
- * each one of them.
501
- *
502
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
503
- *
504
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
505
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
506
- * @memberof Prism
507
- * @public
508
- */
509
- highlightAll: function (async, callback) {
510
- _.highlightAllUnder(document, async, callback);
511
- },
512
-
513
- /**
514
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
515
- * {@link Prism.highlightElement} on each one of them.
516
- *
517
- * The following hooks will be run:
518
- * 1. `before-highlightall`
519
- * 2. All hooks of {@link Prism.highlightElement} for each element.
520
- *
521
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
522
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
523
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
524
- * @memberof Prism
525
- * @public
526
- */
527
- highlightAllUnder: function (container, async, callback) {
528
- var env = {
529
- callback: callback,
530
- container: container,
531
- selector:
532
- 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
533
- };
534
-
535
- _.hooks.run("before-highlightall", env);
536
-
537
- env.elements = Array.prototype.slice.apply(
538
- env.container.querySelectorAll(env.selector)
539
- );
540
-
541
- _.hooks.run("before-all-elements-highlight", env);
542
-
543
- for (var i = 0, element; (element = env.elements[i++]); ) {
544
- _.highlightElement(element, async === true, env.callback);
545
- }
546
- },
547
-
548
- /**
549
- * Highlights the code inside a single element.
550
- *
551
- * The following hooks will be run:
552
- * 1. `before-sanity-check`
553
- * 2. `before-highlight`
554
- * 3. All hooks of {@link Prism.highlight}. These hooks will only be run by the current worker if `async` is `true`.
555
- * 4. `before-insert`
556
- * 5. `after-highlight`
557
- * 6. `complete`
558
- *
559
- * @param {Element} element The element containing the code.
560
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
561
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
562
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
563
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
564
- *
565
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
566
- * asynchronous highlighting to work. You can build your own bundle on the
567
- * [Download page](https://prismjs.com/download.html).
568
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
569
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
570
- * @memberof Prism
571
- * @public
572
- */
573
- highlightElement: function (element, async, callback) {
574
- // Find language
575
- var language = _.util.getLanguage(element);
576
- var grammar = _.languages[language];
577
-
578
- // Set language on the element, if not present
579
- element.className =
580
- element.className.replace(lang, "").replace(/\s+/g, " ") +
581
- " language-" +
582
- language;
583
-
584
- // Set language on the parent, for styling
585
- var parent = element.parentElement;
586
- if (parent && parent.nodeName.toLowerCase() === "pre") {
587
- parent.className =
588
- parent.className
589
- .replace(lang, "")
590
- .replace(/\s+/g, " ") +
591
- " language-" +
592
- language;
593
- }
594
-
595
- var code = element.textContent;
596
-
597
- var env = {
598
- element: element,
599
- language: language,
600
- grammar: grammar,
601
- code: code
602
- };
603
-
604
- function insertHighlightedCode(highlightedCode) {
605
- env.highlightedCode = highlightedCode;
606
-
607
- _.hooks.run("before-insert", env);
608
-
609
- env.element.innerHTML = env.highlightedCode;
610
-
611
- _.hooks.run("after-highlight", env);
612
- _.hooks.run("complete", env);
613
- callback && callback.call(env.element);
614
- }
615
-
616
- _.hooks.run("before-sanity-check", env);
617
-
618
- if (!env.code) {
619
- _.hooks.run("complete", env);
620
- callback && callback.call(env.element);
621
- return;
622
- }
623
-
624
- _.hooks.run("before-highlight", env);
625
-
626
- if (!env.grammar) {
627
- insertHighlightedCode(_.util.encode(env.code));
628
- return;
629
- }
630
-
631
- if (async && _self.Worker) {
632
- var worker = new Worker(_.filename);
633
-
634
- worker.onmessage = function (evt) {
635
- insertHighlightedCode(evt.data);
636
- };
637
-
638
- worker.postMessage(
639
- JSON.stringify({
640
- language: env.language,
641
- code: env.code,
642
- immediateClose: true
643
- })
644
- );
645
- } else {
646
- insertHighlightedCode(
647
- _.highlight(env.code, env.grammar, env.language)
648
- );
649
- }
650
- },
651
-
652
- /**
653
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
654
- * and the language definitions to use, and returns a string with the HTML produced.
655
- *
656
- * The following hooks will be run:
657
- * 1. `before-tokenize`
658
- * 2. `after-tokenize`
659
- * 3. `wrap`: On each {@link Token}.
660
- *
661
- * @param {string} text A string with the code to be highlighted.
662
- * @param {Grammar} grammar An object containing the tokens to use.
663
- *
664
- * Usually a language definition like `Prism.languages.markup`.
665
- * @param {string} language The name of the language definition passed to `grammar`.
666
- * @returns {string} The highlighted HTML.
667
- * @memberof Prism
668
- * @public
669
- * @example
670
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
671
- */
672
- highlight: function (text, grammar, language) {
673
- var env = {
674
- code: text,
675
- grammar: grammar,
676
- language: language
677
- };
678
- _.hooks.run("before-tokenize", env);
679
- env.tokens = _.tokenize(env.code, env.grammar);
680
- _.hooks.run("after-tokenize", env);
681
- return Token.stringify(_.util.encode(env.tokens), env.language);
682
- },
683
-
684
- /**
685
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
686
- * and the language definitions to use, and returns an array with the tokenized code.
687
- *
688
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
689
- *
690
- * This method could be useful in other contexts as well, as a very crude parser.
691
- *
692
- * @param {string} text A string with the code to be highlighted.
693
- * @param {Grammar} grammar An object containing the tokens to use.
694
- *
695
- * Usually a language definition like `Prism.languages.markup`.
696
- * @returns {TokenStream} An array of strings and tokens, a token stream.
697
- * @memberof Prism
698
- * @public
699
- * @example
700
- * let code = `var foo = 0;`;
701
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
702
- * tokens.forEach(token => {
703
- * if (token instanceof Prism.Token && token.type === 'number') {
704
- * console.log(`Found numeric literal: ${token.content}`);
705
- * }
706
- * });
707
- */
708
- tokenize: function (text, grammar) {
709
- var rest = grammar.rest;
710
- if (rest) {
711
- for (var token in rest) {
712
- grammar[token] = rest[token];
713
- }
714
-
715
- delete grammar.rest;
716
- }
717
-
718
- var tokenList = new LinkedList();
719
- addAfter(tokenList, tokenList.head, text);
720
-
721
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
722
-
723
- return toArray(tokenList);
724
- },
725
-
726
- /**
727
- * @namespace
728
- * @memberof Prism
729
- * @public
730
- */
731
- hooks: {
732
- all: {},
733
-
734
- /**
735
- * Adds the given callback to the list of callbacks for the given hook.
736
- *
737
- * The callback will be invoked when the hook it is registered for is run.
738
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
739
- *
740
- * One callback function can be registered to multiple hooks and the same hook multiple times.
741
- *
742
- * @param {string} name The name of the hook.
743
- * @param {HookCallback} callback The callback function which is given environment variables.
744
- * @public
745
- */
746
- add: function (name, callback) {
747
- var hooks = _.hooks.all;
748
-
749
- hooks[name] = hooks[name] || [];
750
-
751
- hooks[name].push(callback);
752
- },
753
-
754
- /**
755
- * Runs a hook invoking all registered callbacks with the given environment variables.
756
- *
757
- * Callbacks will be invoked synchronously and in the order in which they were registered.
758
- *
759
- * @param {string} name The name of the hook.
760
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
761
- * @public
762
- */
763
- run: function (name, env) {
764
- var callbacks = _.hooks.all[name];
765
-
766
- if (!callbacks || !callbacks.length) {
767
- return;
768
- }
769
-
770
- for (var i = 0, callback; (callback = callbacks[i++]); ) {
771
- callback(env);
772
- }
773
- }
774
- },
775
-
776
- Token: Token
777
- };
778
- _self.Prism = _;
779
-
780
- // Typescript note:
781
- // The following can be used to import the Token type in JSDoc:
782
- //
783
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
784
-
785
- /**
786
- * Creates a new token.
787
- *
788
- * @param {string} type See {@link Token#type type}
789
- * @param {string | TokenStream} content See {@link Token#content content}
790
- * @param {string|string[]} [alias] The alias(es) of the token.
791
- * @param {string} [matchedStr=""] A copy of the full string this token was created from.
792
- * @class
793
- * @global
794
- * @public
795
- */
796
- function Token(type, content, alias, matchedStr) {
797
- /**
798
- * The type of the token.
799
- *
800
- * This is usually the key of a pattern in a {@link Grammar}.
801
- *
802
- * @type {string}
803
- * @see GrammarToken
804
- * @public
805
- */
806
- this.type = type;
807
- /**
808
- * The strings or tokens contained by this token.
809
- *
810
- * This will be a token stream if the pattern matched also defined an `inside` grammar.
811
- *
812
- * @type {string | TokenStream}
813
- * @public
814
- */
815
- this.content = content;
816
- /**
817
- * The alias(es) of the token.
818
- *
819
- * @type {string|string[]}
820
- * @see GrammarToken
821
- * @public
822
- */
823
- this.alias = alias;
824
- // Copy of the full string this token was created from
825
- this.length = (matchedStr || "").length | 0;
826
- }
827
-
828
- /**
829
- * A token stream is an array of strings and {@link Token Token} objects.
830
- *
831
- * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
832
- * them.
833
- *
834
- * 1. No adjacent strings.
835
- * 2. No empty strings.
836
- *
837
- * The only exception here is the token stream that only contains the empty string and nothing else.
838
- *
839
- * @typedef {Array<string | Token>} TokenStream
840
- * @global
841
- * @public
842
- */
843
-
844
- /**
845
- * Converts the given token or token stream to an HTML representation.
846
- *
847
- * The following hooks will be run:
848
- * 1. `wrap`: On each {@link Token}.
849
- *
850
- * @param {string | Token | TokenStream} o The token or token stream to be converted.
851
- * @param {string} language The name of current language.
852
- * @returns {string} The HTML representation of the token or token stream.
853
- * @memberof Token
854
- * @static
855
- */
856
- Token.stringify = function stringify(o, language) {
857
- if (typeof o == "string") {
858
- return o;
859
- }
860
- if (Array.isArray(o)) {
861
- var s = "";
862
- o.forEach(function (e) {
863
- s += stringify(e, language);
864
- });
865
- return s;
866
- }
867
-
868
- var env = {
869
- type: o.type,
870
- content: stringify(o.content, language),
871
- tag: "span",
872
- classes: ["token", o.type],
873
- attributes: {},
874
- language: language
875
- };
876
-
877
- var aliases = o.alias;
878
- if (aliases) {
879
- if (Array.isArray(aliases)) {
880
- Array.prototype.push.apply(env.classes, aliases);
881
- } else {
882
- env.classes.push(aliases);
883
- }
884
- }
885
-
886
- _.hooks.run("wrap", env);
887
-
888
- var attributes = "";
889
- for (var name in env.attributes) {
890
- attributes +=
891
- " " +
892
- name +
893
- '="' +
894
- (env.attributes[name] || "").replace(/"/g, "&quot;") +
895
- '"';
896
- }
897
-
898
- return (
899
- "<" +
900
- env.tag +
901
- ' class="' +
902
- env.classes.join(" ") +
903
- '"' +
904
- attributes +
905
- ">" +
906
- env.content +
907
- "</" +
908
- env.tag +
909
- ">"
910
- );
911
- };
912
-
913
- /**
914
- * @param {string} text
915
- * @param {LinkedList<string | Token>} tokenList
916
- * @param {any} grammar
917
- * @param {LinkedListNode<string | Token>} startNode
918
- * @param {number} startPos
919
- * @param {RematchOptions} [rematch]
920
- * @returns {void}
921
- * @private
922
- *
923
- * @typedef RematchOptions
924
- * @property {string} cause
925
- * @property {number} reach
926
- */
927
- function matchGrammar(
928
- text,
929
- tokenList,
930
- grammar,
931
- startNode,
932
- startPos,
933
- rematch
934
- ) {
935
- for (var token in grammar) {
936
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
937
- continue;
938
- }
939
-
940
- var patterns = grammar[token];
941
- patterns = Array.isArray(patterns) ? patterns : [patterns];
942
-
943
- for (var j = 0; j < patterns.length; ++j) {
944
- if (rematch && rematch.cause == token + "," + j) {
945
- return;
946
- }
947
-
948
- var patternObj = patterns[j],
949
- inside = patternObj.inside,
950
- lookbehind = !!patternObj.lookbehind,
951
- greedy = !!patternObj.greedy,
952
- lookbehindLength = 0,
953
- alias = patternObj.alias;
954
-
955
- if (greedy && !patternObj.pattern.global) {
956
- // Without the global flag, lastIndex won't work
957
- var flags = patternObj.pattern
958
- .toString()
959
- .match(/[imsuy]*$/)[0];
960
- patternObj.pattern = RegExp(
961
- patternObj.pattern.source,
962
- flags + "g"
963
- );
964
- }
965
-
966
- /** @type {RegExp} */
967
- var pattern = patternObj.pattern || patternObj;
968
-
969
- for (
970
- // iterate the token list and keep track of the current token/string position
971
- var currentNode = startNode.next, pos = startPos;
972
- currentNode !== tokenList.tail;
973
- pos += currentNode.value.length,
974
- currentNode = currentNode.next
975
- ) {
976
- if (rematch && pos >= rematch.reach) {
977
- break;
978
- }
979
-
980
- var str = currentNode.value;
981
-
982
- if (tokenList.length > text.length) {
983
- // Something went terribly wrong, ABORT, ABORT!
984
- return;
985
- }
986
-
987
- if (str instanceof Token) {
988
- continue;
989
- }
990
-
991
- var removeCount = 1; // this is the to parameter of removeBetween
992
-
993
- if (greedy && currentNode != tokenList.tail.prev) {
994
- pattern.lastIndex = pos;
995
- var match = pattern.exec(text);
996
- if (!match) {
997
- break;
998
- }
999
-
1000
- var from =
1001
- match.index +
1002
- (lookbehind && match[1] ? match[1].length : 0);
1003
- var to = match.index + match[0].length;
1004
- var p = pos;
1005
-
1006
- // find the node that contains the match
1007
- p += currentNode.value.length;
1008
- while (from >= p) {
1009
- currentNode = currentNode.next;
1010
- p += currentNode.value.length;
1011
- }
1012
- // adjust pos (and p)
1013
- p -= currentNode.value.length;
1014
- pos = p;
1015
-
1016
- // the current node is a Token, then the match starts inside another Token, which is invalid
1017
- if (currentNode.value instanceof Token) {
1018
- continue;
1019
- }
1020
-
1021
- // find the last node which is affected by this match
1022
- for (
1023
- var k = currentNode;
1024
- k !== tokenList.tail &&
1025
- (p < to || typeof k.value === "string");
1026
- k = k.next
1027
- ) {
1028
- removeCount++;
1029
- p += k.value.length;
1030
- }
1031
- removeCount--;
1032
-
1033
- // replace with the new match
1034
- str = text.slice(pos, p);
1035
- match.index -= pos;
1036
- } else {
1037
- pattern.lastIndex = 0;
1038
-
1039
- var match = pattern.exec(str);
1040
- }
1041
-
1042
- if (!match) {
1043
- continue;
1044
- }
1045
-
1046
- if (lookbehind) {
1047
- lookbehindLength = match[1] ? match[1].length : 0;
1048
- }
1049
-
1050
- var from = match.index + lookbehindLength,
1051
- matchStr = match[0].slice(lookbehindLength),
1052
- to = from + matchStr.length,
1053
- before = str.slice(0, from),
1054
- after = str.slice(to);
1055
-
1056
- var reach = pos + str.length;
1057
- if (rematch && reach > rematch.reach) {
1058
- rematch.reach = reach;
1059
- }
1060
-
1061
- var removeFrom = currentNode.prev;
1062
-
1063
- if (before) {
1064
- removeFrom = addAfter(
1065
- tokenList,
1066
- removeFrom,
1067
- before
1068
- );
1069
- pos += before.length;
1070
- }
1071
-
1072
- removeRange(tokenList, removeFrom, removeCount);
1073
-
1074
- var wrapped = new Token(
1075
- token,
1076
- inside ? _.tokenize(matchStr, inside) : matchStr,
1077
- alias,
1078
- matchStr
1079
- );
1080
- currentNode = addAfter(tokenList, removeFrom, wrapped);
1081
-
1082
- if (after) {
1083
- addAfter(tokenList, currentNode, after);
1084
- }
1085
-
1086
- if (removeCount > 1) {
1087
- // at least one Token object was removed, so we have to do some rematching
1088
- // this can only happen if the current pattern is greedy
1089
- matchGrammar(
1090
- text,
1091
- tokenList,
1092
- grammar,
1093
- currentNode.prev,
1094
- pos,
1095
- {
1096
- cause: token + "," + j,
1097
- reach: reach
1098
- }
1099
- );
1100
- }
1101
- }
1102
- }
1103
- }
1104
- }
1105
-
1106
- /**
1107
- * @typedef LinkedListNode
1108
- * @property {T} value
1109
- * @property {LinkedListNode<T> | null} prev The previous node.
1110
- * @property {LinkedListNode<T> | null} next The next node.
1111
- * @template T
1112
- * @private
1113
- */
1114
-
1115
- /**
1116
- * @template T
1117
- * @private
1118
- */
1119
- function LinkedList() {
1120
- /** @type {LinkedListNode<T>} */
1121
- var head = { value: null, prev: null, next: null };
1122
- /** @type {LinkedListNode<T>} */
1123
- var tail = { value: null, prev: head, next: null };
1124
- head.next = tail;
1125
-
1126
- /** @type {LinkedListNode<T>} */
1127
- this.head = head;
1128
- /** @type {LinkedListNode<T>} */
1129
- this.tail = tail;
1130
- this.length = 0;
1131
- }
1132
-
1133
- /**
1134
- * Adds a new node with the given value to the list.
1135
- * @param {LinkedList<T>} list
1136
- * @param {LinkedListNode<T>} node
1137
- * @param {T} value
1138
- * @returns {LinkedListNode<T>} The added node.
1139
- * @template T
1140
- */
1141
- function addAfter(list, node, value) {
1142
- // assumes that node != list.tail && values.length >= 0
1143
- var next = node.next;
1144
-
1145
- var newNode = { value: value, prev: node, next: next };
1146
- node.next = newNode;
1147
- next.prev = newNode;
1148
- list.length++;
1149
-
1150
- return newNode;
1151
- }
1152
- /**
1153
- * Removes `count` nodes after the given node. The given node will not be removed.
1154
- * @param {LinkedList<T>} list
1155
- * @param {LinkedListNode<T>} node
1156
- * @param {number} count
1157
- * @template T
1158
- */
1159
- function removeRange(list, node, count) {
1160
- var next = node.next;
1161
- for (var i = 0; i < count && next !== list.tail; i++) {
1162
- next = next.next;
1163
- }
1164
- node.next = next;
1165
- next.prev = node;
1166
- list.length -= i;
1167
- }
1168
- /**
1169
- * @param {LinkedList<T>} list
1170
- * @returns {T[]}
1171
- * @template T
1172
- */
1173
- function toArray(list) {
1174
- var array = [];
1175
- var node = list.head.next;
1176
- while (node !== list.tail) {
1177
- array.push(node.value);
1178
- node = node.next;
1179
- }
1180
- return array;
1181
- }
1182
-
1183
- if (!_self.document) {
1184
- if (!_self.addEventListener) {
1185
- // in Node.js
1186
- return _;
1187
- }
1188
-
1189
- if (!_.disableWorkerMessageHandler) {
1190
- // In worker
1191
- _self.addEventListener(
1192
- "message",
1193
- function (evt) {
1194
- var message = JSON.parse(evt.data),
1195
- lang = message.language,
1196
- code = message.code,
1197
- immediateClose = message.immediateClose;
1198
-
1199
- _self.postMessage(
1200
- _.highlight(code, _.languages[lang], lang)
1201
- );
1202
- if (immediateClose) {
1203
- _self.close();
1204
- }
1205
- },
1206
- false
1207
- );
1208
- }
1209
-
1210
- return _;
1211
- }
1212
-
1213
- // Get current script and highlight
1214
- var script = _.util.currentScript();
1215
-
1216
- if (script) {
1217
- _.filename = script.src;
1218
-
1219
- if (script.hasAttribute("data-manual")) {
1220
- _.manual = true;
1221
- }
1222
- }
1223
-
1224
- function highlightAutomaticallyCallback() {
1225
- if (!_.manual) {
1226
- _.highlightAll();
1227
- }
1228
- }
1229
-
1230
- if (!_.manual) {
1231
- // If the document state is "loading", then we'll use DOMContentLoaded.
1232
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1233
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1234
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
1235
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1236
- // See https://github.com/PrismJS/prism/issues/2102
1237
- var readyState = document.readyState;
1238
- if (
1239
- readyState === "loading" ||
1240
- (readyState === "interactive" && script && script.defer)
1241
- ) {
1242
- document.addEventListener(
1243
- "DOMContentLoaded",
1244
- highlightAutomaticallyCallback
1245
- );
1246
- } else {
1247
- if (window.requestAnimationFrame) {
1248
- window.requestAnimationFrame(
1249
- highlightAutomaticallyCallback
1250
- );
1251
- } else {
1252
- window.setTimeout(highlightAutomaticallyCallback, 16);
1253
- }
1254
- }
1255
- }
1256
-
1257
- return _;
1258
- })(_self);
1259
-
1260
- if (module.exports) {
1261
- module.exports = Prism;
1262
- }
1263
-
1264
- // hack for components to work correctly in node.js
1265
- if (typeof commonjsGlobal !== "undefined") {
1266
- commonjsGlobal.Prism = Prism;
1267
- }
1268
-
1269
- // some additional documentation/types
1270
-
1271
- /**
1272
- * The expansion of a simple `RegExp` literal to support additional properties.
1273
- *
1274
- * @typedef GrammarToken
1275
- * @property {RegExp} pattern The regular expression of the token.
1276
- * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1277
- * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1278
- * @property {boolean} [greedy=false] Whether the token is greedy.
1279
- * @property {string|string[]} [alias] An optional alias or list of aliases.
1280
- * @property {Grammar} [inside] The nested grammar of this token.
1281
- *
1282
- * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1283
- *
1284
- * This can be used to make nested and even recursive language definitions.
1285
- *
1286
- * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1287
- * each another.
1288
- * @global
1289
- * @public
1290
- */
1291
-
1292
- /**
1293
- * @typedef Grammar
1294
- * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1295
- * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1296
- * @global
1297
- * @public
1298
- */
1299
-
1300
- /**
1301
- * A function which will invoked after an element was successfully highlighted.
1302
- *
1303
- * @callback HighlightCallback
1304
- * @param {Element} element The element successfully highlighted.
1305
- * @returns {void}
1306
- * @global
1307
- * @public
1308
- */
1309
-
1310
- /**
1311
- * @callback HookCallback
1312
- * @param {Object<string, any>} env The environment variables of the hook.
1313
- * @returns {void}
1314
- * @global
1315
- * @public
1316
- */
1317
-
1318
- /* **********************************************
1319
- Begin prism-markup.js
1320
- ********************************************** */
1321
-
1322
- Prism.languages.markup = {
1323
- comment: /<!--[\s\S]*?-->/,
1324
- prolog: /<\?[\s\S]+?\?>/,
1325
- doctype: {
1326
- // https://www.w3.org/TR/xml/#NT-doctypedecl
1327
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1328
- greedy: true,
1329
- inside: {
1330
- "internal-subset": {
1331
- pattern: /(\[)[\s\S]+(?=\]>$)/,
1332
- lookbehind: true,
1333
- greedy: true,
1334
- inside: null // see below
1335
- },
1336
- string: {
1337
- pattern: /"[^"]*"|'[^']*'/,
1338
- greedy: true
1339
- },
1340
- punctuation: /^<!|>$|[[\]]/,
1341
- "doctype-tag": /^DOCTYPE/,
1342
- name: /[^\s<>'"]+/
1343
- }
1344
- },
1345
- cdata: /<!\[CDATA\[[\s\S]*?]]>/i,
1346
- tag: {
1347
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1348
- greedy: true,
1349
- inside: {
1350
- tag: {
1351
- pattern: /^<\/?[^\s>\/]+/,
1352
- inside: {
1353
- punctuation: /^<\/?/,
1354
- namespace: /^[^\s>\/:]+:/
1355
- }
1356
- },
1357
- "attr-value": {
1358
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1359
- inside: {
1360
- punctuation: [
1361
- {
1362
- pattern: /^=/,
1363
- alias: "attr-equals"
1364
- },
1365
- /"|'/
1366
- ]
1367
- }
1368
- },
1369
- punctuation: /\/?>/,
1370
- "attr-name": {
1371
- pattern: /[^\s>\/]+/,
1372
- inside: {
1373
- namespace: /^[^\s>\/:]+:/
1374
- }
1375
- }
1376
- }
1377
- },
1378
- entity: [
1379
- {
1380
- pattern: /&[\da-z]{1,8};/i,
1381
- alias: "named-entity"
1382
- },
1383
- /&#x?[\da-f]{1,8};/i
1384
- ]
1385
- };
1386
-
1387
- Prism.languages.markup["tag"].inside["attr-value"].inside["entity"] =
1388
- Prism.languages.markup["entity"];
1389
- Prism.languages.markup["doctype"].inside["internal-subset"].inside =
1390
- Prism.languages.markup;
1391
-
1392
- // Plugin to make entity title show the real entity, idea by Roman Komarov
1393
- Prism.hooks.add("wrap", function (env) {
1394
- if (env.type === "entity") {
1395
- env.attributes["title"] = env.content.replace(/&amp;/, "&");
1396
- }
1397
- });
1398
-
1399
- Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
1400
- /**
1401
- * Adds an inlined language to markup.
1402
- *
1403
- * An example of an inlined language is CSS with `<style>` tags.
1404
- *
1405
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1406
- * case insensitive.
1407
- * @param {string} lang The language key.
1408
- * @example
1409
- * addInlined('style', 'css');
1410
- */
1411
- value: function addInlined(tagName, lang) {
1412
- var includedCdataInside = {};
1413
- includedCdataInside["language-" + lang] = {
1414
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1415
- lookbehind: true,
1416
- inside: Prism.languages[lang]
1417
- };
1418
- includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
1419
-
1420
- var inside = {
1421
- "included-cdata": {
1422
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1423
- inside: includedCdataInside
1424
- }
1425
- };
1426
- inside["language-" + lang] = {
1427
- pattern: /[\s\S]+/,
1428
- inside: Prism.languages[lang]
1429
- };
1430
-
1431
- var def = {};
1432
- def[tagName] = {
1433
- pattern: RegExp(
1434
- /(<__[\s\S]*?>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(
1435
- /__/g,
1436
- function () {
1437
- return tagName;
1438
- }
1439
- ),
1440
- "i"
1441
- ),
1442
- lookbehind: true,
1443
- greedy: true,
1444
- inside: inside
1445
- };
1446
-
1447
- Prism.languages.insertBefore("markup", "cdata", def);
1448
- }
1449
- });
1450
-
1451
- Prism.languages.html = Prism.languages.markup;
1452
- Prism.languages.mathml = Prism.languages.markup;
1453
- Prism.languages.svg = Prism.languages.markup;
1454
-
1455
- Prism.languages.xml = Prism.languages.extend("markup", {});
1456
- Prism.languages.ssml = Prism.languages.xml;
1457
- Prism.languages.atom = Prism.languages.xml;
1458
- Prism.languages.rss = Prism.languages.xml;
1459
-
1460
- /* **********************************************
1461
- Begin prism-css.js
1462
- ********************************************** */
1463
-
1464
- (function (Prism) {
1465
- var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
1466
-
1467
- Prism.languages.css = {
1468
- comment: /\/\*[\s\S]*?\*\//,
1469
- atrule: {
1470
- pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
1471
- inside: {
1472
- rule: /^@[\w-]+/,
1473
- "selector-function-argument": {
1474
- pattern: /(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,
1475
- lookbehind: true,
1476
- alias: "selector"
1477
- },
1478
- keyword: {
1479
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1480
- lookbehind: true
1481
- }
1482
- // See rest below
1483
- }
1484
- },
1485
- url: {
1486
- // https://drafts.csswg.org/css-values-3/#urls
1487
- pattern: RegExp(
1488
- "\\burl\\((?:" +
1489
- string.source +
1490
- "|" +
1491
- /(?:[^\\\r\n()"']|\\[\s\S])*/.source +
1492
- ")\\)",
1493
- "i"
1494
- ),
1495
- greedy: true,
1496
- inside: {
1497
- function: /^url/i,
1498
- punctuation: /^\(|\)$/,
1499
- string: {
1500
- pattern: RegExp("^" + string.source + "$"),
1501
- alias: "url"
1502
- }
1503
- }
1504
- },
1505
- selector: RegExp(
1506
- "[^{}\\s](?:[^{};\"']|" + string.source + ")*?(?=\\s*\\{)"
1507
- ),
1508
- string: {
1509
- pattern: string,
1510
- greedy: true
1511
- },
1512
- property: /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
1513
- important: /!important\b/i,
1514
- function: /[-a-z0-9]+(?=\()/i,
1515
- punctuation: /[(){};:,]/
1516
- };
1517
-
1518
- Prism.languages.css["atrule"].inside.rest = Prism.languages.css;
1519
-
1520
- var markup = Prism.languages.markup;
1521
- if (markup) {
1522
- markup.tag.addInlined("style", "css");
1523
-
1524
- Prism.languages.insertBefore(
1525
- "inside",
1526
- "attr-value",
1527
- {
1528
- "style-attr": {
1529
- pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
1530
- inside: {
1531
- "attr-name": {
1532
- pattern: /^\s*style/i,
1533
- inside: markup.tag.inside
1534
- },
1535
- punctuation: /^\s*=\s*['"]|['"]\s*$/,
1536
- "attr-value": {
1537
- pattern: /.+/i,
1538
- inside: Prism.languages.css
1539
- }
1540
- },
1541
- alias: "language-css"
1542
- }
1543
- },
1544
- markup.tag
1545
- );
1546
- }
1547
- })(Prism);
1548
-
1549
- /* **********************************************
1550
- Begin prism-clike.js
1551
- ********************************************** */
1552
-
1553
- Prism.languages.clike = {
1554
- comment: [
1555
- {
1556
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1557
- lookbehind: true
1558
- },
1559
- {
1560
- pattern: /(^|[^\\:])\/\/.*/,
1561
- lookbehind: true,
1562
- greedy: true
1563
- }
1564
- ],
1565
- string: {
1566
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1567
- greedy: true
1568
- },
1569
- "class-name": {
1570
- pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
1571
- lookbehind: true,
1572
- inside: {
1573
- punctuation: /[.\\]/
1574
- }
1575
- },
1576
- keyword: /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
1577
- boolean: /\b(?:true|false)\b/,
1578
- function: /\w+(?=\()/,
1579
- number: /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
1580
- operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1581
- punctuation: /[{}[\];(),.:]/
1582
- };
1583
-
1584
- /* **********************************************
1585
- Begin prism-javascript.js
1586
- ********************************************** */
1587
-
1588
- Prism.languages.javascript = Prism.languages.extend("clike", {
1589
- "class-name": [
1590
- Prism.languages.clike["class-name"],
1591
- {
1592
- pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
1593
- lookbehind: true
1594
- }
1595
- ],
1596
- keyword: [
1597
- {
1598
- pattern: /((?:^|})\s*)(?:catch|finally)\b/,
1599
- lookbehind: true
1600
- },
1601
- {
1602
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|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/,
1603
- lookbehind: true
1604
- }
1605
- ],
1606
- number: /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
1607
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1608
- function: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1609
- operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1610
- });
1611
-
1612
- Prism.languages.javascript[
1613
- "class-name"
1614
- ][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
1615
-
1616
- Prism.languages.insertBefore("javascript", "keyword", {
1617
- regex: {
1618
- pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
1619
- lookbehind: true,
1620
- greedy: true
1621
- },
1622
- // This must be declared before keyword because we use "function" inside the look-forward
1623
- "function-variable": {
1624
- pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
1625
- alias: "function"
1626
- },
1627
- parameter: [
1628
- {
1629
- pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
1630
- lookbehind: true,
1631
- inside: Prism.languages.javascript
1632
- },
1633
- {
1634
- pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
1635
- inside: Prism.languages.javascript
1636
- },
1637
- {
1638
- pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
1639
- lookbehind: true,
1640
- inside: Prism.languages.javascript
1641
- },
1642
- {
1643
- 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]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
1644
- lookbehind: true,
1645
- inside: Prism.languages.javascript
1646
- }
1647
- ],
1648
- constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1649
- });
1650
-
1651
- Prism.languages.insertBefore("javascript", "string", {
1652
- "template-string": {
1653
- pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
1654
- greedy: true,
1655
- inside: {
1656
- "template-punctuation": {
1657
- pattern: /^`|`$/,
1658
- alias: "string"
1659
- },
1660
- interpolation: {
1661
- pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
1662
- lookbehind: true,
1663
- inside: {
1664
- "interpolation-punctuation": {
1665
- pattern: /^\${|}$/,
1666
- alias: "punctuation"
1667
- },
1668
- rest: Prism.languages.javascript
1669
- }
1670
- },
1671
- string: /[\s\S]+/
1672
- }
1673
- }
1674
- });
1675
-
1676
- if (Prism.languages.markup) {
1677
- Prism.languages.markup.tag.addInlined("script", "javascript");
1678
- }
1679
-
1680
- Prism.languages.js = Prism.languages.javascript;
1681
-
1682
- /* **********************************************
1683
- Begin prism-file-highlight.js
1684
- ********************************************** */
1685
-
1686
- (function () {
1687
- if (typeof self === "undefined" || !self.Prism || !self.document) {
1688
- return;
1689
- }
1690
-
1691
- var Prism = window.Prism;
1692
-
1693
- var LOADING_MESSAGE = "Loading…";
1694
- var FAILURE_MESSAGE = function (status, message) {
1695
- return "✖ Error " + status + " while fetching file: " + message;
1696
- };
1697
- var FAILURE_EMPTY_MESSAGE = "✖ Error: File does not exist or is empty";
1698
-
1699
- var EXTENSIONS = {
1700
- js: "javascript",
1701
- py: "python",
1702
- rb: "ruby",
1703
- ps1: "powershell",
1704
- psm1: "powershell",
1705
- sh: "bash",
1706
- bat: "batch",
1707
- h: "c",
1708
- tex: "latex"
1709
- };
1710
-
1711
- var STATUS_ATTR = "data-src-status";
1712
- var STATUS_LOADING = "loading";
1713
- var STATUS_LOADED = "loaded";
1714
- var STATUS_FAILED = "failed";
1715
-
1716
- var SELECTOR =
1717
- "pre[data-src]:not([" +
1718
- STATUS_ATTR +
1719
- '="' +
1720
- STATUS_LOADED +
1721
- '"])' +
1722
- ":not([" +
1723
- STATUS_ATTR +
1724
- '="' +
1725
- STATUS_LOADING +
1726
- '"])';
1727
-
1728
- var lang = /\blang(?:uage)?-([\w-]+)\b/i;
1729
-
1730
- /**
1731
- * Sets the Prism `language-xxxx` or `lang-xxxx` class to the given language.
1732
- *
1733
- * @param {HTMLElement} element
1734
- * @param {string} language
1735
- * @returns {void}
1736
- */
1737
- function setLanguageClass(element, language) {
1738
- var className = element.className;
1739
- className = className.replace(lang, " ") + " language-" + language;
1740
- element.className = className.replace(/\s+/g, " ").trim();
1741
- }
1742
-
1743
- Prism.hooks.add("before-highlightall", function (env) {
1744
- env.selector += ", " + SELECTOR;
1745
- });
1746
-
1747
- Prism.hooks.add("before-sanity-check", function (env) {
1748
- var pre = /** @type {HTMLPreElement} */ env.element;
1749
- if (pre.matches(SELECTOR)) {
1750
- env.code = ""; // fast-path the whole thing and go to complete
1751
-
1752
- pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
1753
-
1754
- // add code element with loading message
1755
- var code = pre.appendChild(document.createElement("CODE"));
1756
- code.textContent = LOADING_MESSAGE;
1757
-
1758
- var src = pre.getAttribute("data-src");
1759
-
1760
- var language = env.language;
1761
- if (language === "none") {
1762
- // the language might be 'none' because there is no language set;
1763
- // in this case, we want to use the extension as the language
1764
- var extension = (/\.(\w+)$/.exec(src) || [, "none"])[1];
1765
- language = EXTENSIONS[extension] || extension;
1766
- }
1767
-
1768
- // set language classes
1769
- setLanguageClass(code, language);
1770
- setLanguageClass(pre, language);
1771
-
1772
- // preload the language
1773
- var autoloader = Prism.plugins.autoloader;
1774
- if (autoloader) {
1775
- autoloader.loadLanguages(language);
1776
- }
1777
-
1778
- // load file
1779
- var xhr = new XMLHttpRequest();
1780
- xhr.open("GET", src, true);
1781
- xhr.onreadystatechange = function () {
1782
- if (xhr.readyState == 4) {
1783
- if (xhr.status < 400 && xhr.responseText) {
1784
- // mark as loaded
1785
- pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
1786
-
1787
- // highlight code
1788
- code.textContent = xhr.responseText;
1789
- Prism.highlightElement(code);
1790
- } else {
1791
- // mark as failed
1792
- pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
1793
-
1794
- if (xhr.status >= 400) {
1795
- code.textContent = FAILURE_MESSAGE(
1796
- xhr.status,
1797
- xhr.statusText
1798
- );
1799
- } else {
1800
- code.textContent = FAILURE_EMPTY_MESSAGE;
1801
- }
1802
- }
1803
- }
1804
- };
1805
- xhr.send(null);
1806
- }
1807
- });
1808
-
1809
- Prism.plugins.fileHighlight = {
1810
- /**
1811
- * Executes the File Highlight plugin for all matching `pre` elements under the given container.
1812
- *
1813
- * Note: Elements which are already loaded or currently loading will not be touched by this method.
1814
- *
1815
- * @param {ParentNode} [container=document]
1816
- */
1817
- highlight: function highlight(container) {
1818
- var elements = (container || document).querySelectorAll(
1819
- SELECTOR
1820
- );
1821
-
1822
- for (var i = 0, element; (element = elements[i++]); ) {
1823
- Prism.highlightElement(element);
1824
- }
1825
- }
1826
- };
1827
-
1828
- var logged = false;
1829
- /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
1830
- Prism.fileHighlight = function () {
1831
- if (!logged) {
1832
- console.warn(
1833
- "Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."
1834
- );
1835
- logged = true;
1836
- }
1837
- Prism.plugins.fileHighlight.highlight.apply(this, arguments);
1838
- };
1839
- })();
1840
- });
1841
-
1842
- export default prism;