@forsakringskassan/docs-live-example 1.4.0 → 1.4.2

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.
@@ -0,0 +1,2429 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // node_modules/highlight.js/lib/core.js
28
+ var require_core = __commonJS({
29
+ "node_modules/highlight.js/lib/core.js"(exports, module) {
30
+ function deepFreeze(obj) {
31
+ if (obj instanceof Map) {
32
+ obj.clear = obj.delete = obj.set = function() {
33
+ throw new Error("map is read-only");
34
+ };
35
+ } else if (obj instanceof Set) {
36
+ obj.add = obj.clear = obj.delete = function() {
37
+ throw new Error("set is read-only");
38
+ };
39
+ }
40
+ Object.freeze(obj);
41
+ Object.getOwnPropertyNames(obj).forEach((name) => {
42
+ const prop = obj[name];
43
+ const type = typeof prop;
44
+ if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
45
+ deepFreeze(prop);
46
+ }
47
+ });
48
+ return obj;
49
+ }
50
+ var Response = class {
51
+ /**
52
+ * @param {CompiledMode} mode
53
+ */
54
+ constructor(mode) {
55
+ if (mode.data === void 0)
56
+ mode.data = {};
57
+ this.data = mode.data;
58
+ this.isMatchIgnored = false;
59
+ }
60
+ ignoreMatch() {
61
+ this.isMatchIgnored = true;
62
+ }
63
+ };
64
+ function escapeHTML(value) {
65
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
66
+ }
67
+ function inherit$1(original, ...objects) {
68
+ const result = /* @__PURE__ */ Object.create(null);
69
+ for (const key in original) {
70
+ result[key] = original[key];
71
+ }
72
+ objects.forEach(function(obj) {
73
+ for (const key in obj) {
74
+ result[key] = obj[key];
75
+ }
76
+ });
77
+ return (
78
+ /** @type {T} */
79
+ result
80
+ );
81
+ }
82
+ var SPAN_CLOSE = "</span>";
83
+ var emitsWrappingTags = (node) => {
84
+ return !!node.scope;
85
+ };
86
+ var scopeToCSSClass = (name, { prefix }) => {
87
+ if (name.startsWith("language:")) {
88
+ return name.replace("language:", "language-");
89
+ }
90
+ if (name.includes(".")) {
91
+ const pieces = name.split(".");
92
+ return [
93
+ `${prefix}${pieces.shift()}`,
94
+ ...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
95
+ ].join(" ");
96
+ }
97
+ return `${prefix}${name}`;
98
+ };
99
+ var HTMLRenderer = class {
100
+ /**
101
+ * Creates a new HTMLRenderer
102
+ *
103
+ * @param {Tree} parseTree - the parse tree (must support `walk` API)
104
+ * @param {{classPrefix: string}} options
105
+ */
106
+ constructor(parseTree, options) {
107
+ this.buffer = "";
108
+ this.classPrefix = options.classPrefix;
109
+ parseTree.walk(this);
110
+ }
111
+ /**
112
+ * Adds texts to the output stream
113
+ *
114
+ * @param {string} text */
115
+ addText(text) {
116
+ this.buffer += escapeHTML(text);
117
+ }
118
+ /**
119
+ * Adds a node open to the output stream (if needed)
120
+ *
121
+ * @param {Node} node */
122
+ openNode(node) {
123
+ if (!emitsWrappingTags(node))
124
+ return;
125
+ const className = scopeToCSSClass(
126
+ node.scope,
127
+ { prefix: this.classPrefix }
128
+ );
129
+ this.span(className);
130
+ }
131
+ /**
132
+ * Adds a node close to the output stream (if needed)
133
+ *
134
+ * @param {Node} node */
135
+ closeNode(node) {
136
+ if (!emitsWrappingTags(node))
137
+ return;
138
+ this.buffer += SPAN_CLOSE;
139
+ }
140
+ /**
141
+ * returns the accumulated buffer
142
+ */
143
+ value() {
144
+ return this.buffer;
145
+ }
146
+ // helpers
147
+ /**
148
+ * Builds a span element
149
+ *
150
+ * @param {string} className */
151
+ span(className) {
152
+ this.buffer += `<span class="${className}">`;
153
+ }
154
+ };
155
+ var newNode = (opts = {}) => {
156
+ const result = { children: [] };
157
+ Object.assign(result, opts);
158
+ return result;
159
+ };
160
+ var TokenTree = class _TokenTree {
161
+ constructor() {
162
+ this.rootNode = newNode();
163
+ this.stack = [this.rootNode];
164
+ }
165
+ get top() {
166
+ return this.stack[this.stack.length - 1];
167
+ }
168
+ get root() {
169
+ return this.rootNode;
170
+ }
171
+ /** @param {Node} node */
172
+ add(node) {
173
+ this.top.children.push(node);
174
+ }
175
+ /** @param {string} scope */
176
+ openNode(scope) {
177
+ const node = newNode({ scope });
178
+ this.add(node);
179
+ this.stack.push(node);
180
+ }
181
+ closeNode() {
182
+ if (this.stack.length > 1) {
183
+ return this.stack.pop();
184
+ }
185
+ return void 0;
186
+ }
187
+ closeAllNodes() {
188
+ while (this.closeNode())
189
+ ;
190
+ }
191
+ toJSON() {
192
+ return JSON.stringify(this.rootNode, null, 4);
193
+ }
194
+ /**
195
+ * @typedef { import("./html_renderer").Renderer } Renderer
196
+ * @param {Renderer} builder
197
+ */
198
+ walk(builder) {
199
+ return this.constructor._walk(builder, this.rootNode);
200
+ }
201
+ /**
202
+ * @param {Renderer} builder
203
+ * @param {Node} node
204
+ */
205
+ static _walk(builder, node) {
206
+ if (typeof node === "string") {
207
+ builder.addText(node);
208
+ } else if (node.children) {
209
+ builder.openNode(node);
210
+ node.children.forEach((child) => this._walk(builder, child));
211
+ builder.closeNode(node);
212
+ }
213
+ return builder;
214
+ }
215
+ /**
216
+ * @param {Node} node
217
+ */
218
+ static _collapse(node) {
219
+ if (typeof node === "string")
220
+ return;
221
+ if (!node.children)
222
+ return;
223
+ if (node.children.every((el) => typeof el === "string")) {
224
+ node.children = [node.children.join("")];
225
+ } else {
226
+ node.children.forEach((child) => {
227
+ _TokenTree._collapse(child);
228
+ });
229
+ }
230
+ }
231
+ };
232
+ var TokenTreeEmitter = class extends TokenTree {
233
+ /**
234
+ * @param {*} options
235
+ */
236
+ constructor(options) {
237
+ super();
238
+ this.options = options;
239
+ }
240
+ /**
241
+ * @param {string} text
242
+ */
243
+ addText(text) {
244
+ if (text === "") {
245
+ return;
246
+ }
247
+ this.add(text);
248
+ }
249
+ /** @param {string} scope */
250
+ startScope(scope) {
251
+ this.openNode(scope);
252
+ }
253
+ endScope() {
254
+ this.closeNode();
255
+ }
256
+ /**
257
+ * @param {Emitter & {root: DataNode}} emitter
258
+ * @param {string} name
259
+ */
260
+ __addSublanguage(emitter, name) {
261
+ const node = emitter.root;
262
+ if (name)
263
+ node.scope = `language:${name}`;
264
+ this.add(node);
265
+ }
266
+ toHTML() {
267
+ const renderer = new HTMLRenderer(this, this.options);
268
+ return renderer.value();
269
+ }
270
+ finalize() {
271
+ this.closeAllNodes();
272
+ return true;
273
+ }
274
+ };
275
+ function source(re) {
276
+ if (!re)
277
+ return null;
278
+ if (typeof re === "string")
279
+ return re;
280
+ return re.source;
281
+ }
282
+ function lookahead(re) {
283
+ return concat("(?=", re, ")");
284
+ }
285
+ function anyNumberOfTimes(re) {
286
+ return concat("(?:", re, ")*");
287
+ }
288
+ function optional(re) {
289
+ return concat("(?:", re, ")?");
290
+ }
291
+ function concat(...args) {
292
+ const joined = args.map((x) => source(x)).join("");
293
+ return joined;
294
+ }
295
+ function stripOptionsFromArgs(args) {
296
+ const opts = args[args.length - 1];
297
+ if (typeof opts === "object" && opts.constructor === Object) {
298
+ args.splice(args.length - 1, 1);
299
+ return opts;
300
+ } else {
301
+ return {};
302
+ }
303
+ }
304
+ function either(...args) {
305
+ const opts = stripOptionsFromArgs(args);
306
+ const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
307
+ return joined;
308
+ }
309
+ function countMatchGroups(re) {
310
+ return new RegExp(re.toString() + "|").exec("").length - 1;
311
+ }
312
+ function startsWith(re, lexeme) {
313
+ const match = re && re.exec(lexeme);
314
+ return match && match.index === 0;
315
+ }
316
+ var BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
317
+ function _rewriteBackreferences(regexps, { joinWith }) {
318
+ let numCaptures = 0;
319
+ return regexps.map((regex) => {
320
+ numCaptures += 1;
321
+ const offset = numCaptures;
322
+ let re = source(regex);
323
+ let out = "";
324
+ while (re.length > 0) {
325
+ const match = BACKREF_RE.exec(re);
326
+ if (!match) {
327
+ out += re;
328
+ break;
329
+ }
330
+ out += re.substring(0, match.index);
331
+ re = re.substring(match.index + match[0].length);
332
+ if (match[0][0] === "\\" && match[1]) {
333
+ out += "\\" + String(Number(match[1]) + offset);
334
+ } else {
335
+ out += match[0];
336
+ if (match[0] === "(") {
337
+ numCaptures++;
338
+ }
339
+ }
340
+ }
341
+ return out;
342
+ }).map((re) => `(${re})`).join(joinWith);
343
+ }
344
+ var MATCH_NOTHING_RE = /\b\B/;
345
+ var IDENT_RE = "[a-zA-Z]\\w*";
346
+ var UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
347
+ var NUMBER_RE = "\\b\\d+(\\.\\d+)?";
348
+ var C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
349
+ var BINARY_NUMBER_RE = "\\b(0b[01]+)";
350
+ var RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
351
+ var SHEBANG = (opts = {}) => {
352
+ const beginShebang = /^#![ ]*\//;
353
+ if (opts.binary) {
354
+ opts.begin = concat(
355
+ beginShebang,
356
+ /.*\b/,
357
+ opts.binary,
358
+ /\b.*/
359
+ );
360
+ }
361
+ return inherit$1({
362
+ scope: "meta",
363
+ begin: beginShebang,
364
+ end: /$/,
365
+ relevance: 0,
366
+ /** @type {ModeCallback} */
367
+ "on:begin": (m, resp) => {
368
+ if (m.index !== 0)
369
+ resp.ignoreMatch();
370
+ }
371
+ }, opts);
372
+ };
373
+ var BACKSLASH_ESCAPE = {
374
+ begin: "\\\\[\\s\\S]",
375
+ relevance: 0
376
+ };
377
+ var APOS_STRING_MODE = {
378
+ scope: "string",
379
+ begin: "'",
380
+ end: "'",
381
+ illegal: "\\n",
382
+ contains: [BACKSLASH_ESCAPE]
383
+ };
384
+ var QUOTE_STRING_MODE = {
385
+ scope: "string",
386
+ begin: '"',
387
+ end: '"',
388
+ illegal: "\\n",
389
+ contains: [BACKSLASH_ESCAPE]
390
+ };
391
+ var PHRASAL_WORDS_MODE = {
392
+ begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
393
+ };
394
+ var COMMENT = function(begin, end, modeOptions = {}) {
395
+ const mode = inherit$1(
396
+ {
397
+ scope: "comment",
398
+ begin,
399
+ end,
400
+ contains: []
401
+ },
402
+ modeOptions
403
+ );
404
+ mode.contains.push({
405
+ scope: "doctag",
406
+ // hack to avoid the space from being included. the space is necessary to
407
+ // match here to prevent the plain text rule below from gobbling up doctags
408
+ begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
409
+ end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
410
+ excludeBegin: true,
411
+ relevance: 0
412
+ });
413
+ const ENGLISH_WORD = either(
414
+ // list of common 1 and 2 letter words in English
415
+ "I",
416
+ "a",
417
+ "is",
418
+ "so",
419
+ "us",
420
+ "to",
421
+ "at",
422
+ "if",
423
+ "in",
424
+ "it",
425
+ "on",
426
+ // note: this is not an exhaustive list of contractions, just popular ones
427
+ /[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
428
+ // contractions - can't we'd they're let's, etc
429
+ /[A-Za-z]+[-][a-z]+/,
430
+ // `no-way`, etc.
431
+ /[A-Za-z][a-z]{2,}/
432
+ // allow capitalized words at beginning of sentences
433
+ );
434
+ mode.contains.push(
435
+ {
436
+ // TODO: how to include ", (, ) without breaking grammars that use these for
437
+ // comment delimiters?
438
+ // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
439
+ // ---
440
+ // this tries to find sequences of 3 english words in a row (without any
441
+ // "programming" type syntax) this gives us a strong signal that we've
442
+ // TRULY found a comment - vs perhaps scanning with the wrong language.
443
+ // It's possible to find something that LOOKS like the start of the
444
+ // comment - but then if there is no readable text - good chance it is a
445
+ // false match and not a comment.
446
+ //
447
+ // for a visual example please see:
448
+ // https://github.com/highlightjs/highlight.js/issues/2827
449
+ begin: concat(
450
+ /[ ]+/,
451
+ // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
452
+ "(",
453
+ ENGLISH_WORD,
454
+ /[.]?[:]?([.][ ]|[ ])/,
455
+ "){3}"
456
+ )
457
+ // look for 3 words in a row
458
+ }
459
+ );
460
+ return mode;
461
+ };
462
+ var C_LINE_COMMENT_MODE = COMMENT("//", "$");
463
+ var C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
464
+ var HASH_COMMENT_MODE = COMMENT("#", "$");
465
+ var NUMBER_MODE = {
466
+ scope: "number",
467
+ begin: NUMBER_RE,
468
+ relevance: 0
469
+ };
470
+ var C_NUMBER_MODE = {
471
+ scope: "number",
472
+ begin: C_NUMBER_RE,
473
+ relevance: 0
474
+ };
475
+ var BINARY_NUMBER_MODE = {
476
+ scope: "number",
477
+ begin: BINARY_NUMBER_RE,
478
+ relevance: 0
479
+ };
480
+ var REGEXP_MODE = {
481
+ scope: "regexp",
482
+ begin: /\/(?=[^/\n]*\/)/,
483
+ end: /\/[gimuy]*/,
484
+ contains: [
485
+ BACKSLASH_ESCAPE,
486
+ {
487
+ begin: /\[/,
488
+ end: /\]/,
489
+ relevance: 0,
490
+ contains: [BACKSLASH_ESCAPE]
491
+ }
492
+ ]
493
+ };
494
+ var TITLE_MODE = {
495
+ scope: "title",
496
+ begin: IDENT_RE,
497
+ relevance: 0
498
+ };
499
+ var UNDERSCORE_TITLE_MODE = {
500
+ scope: "title",
501
+ begin: UNDERSCORE_IDENT_RE,
502
+ relevance: 0
503
+ };
504
+ var METHOD_GUARD = {
505
+ // excludes method names from keyword processing
506
+ begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
507
+ relevance: 0
508
+ };
509
+ var END_SAME_AS_BEGIN = function(mode) {
510
+ return Object.assign(
511
+ mode,
512
+ {
513
+ /** @type {ModeCallback} */
514
+ "on:begin": (m, resp) => {
515
+ resp.data._beginMatch = m[1];
516
+ },
517
+ /** @type {ModeCallback} */
518
+ "on:end": (m, resp) => {
519
+ if (resp.data._beginMatch !== m[1])
520
+ resp.ignoreMatch();
521
+ }
522
+ }
523
+ );
524
+ };
525
+ var MODES = /* @__PURE__ */ Object.freeze({
526
+ __proto__: null,
527
+ APOS_STRING_MODE,
528
+ BACKSLASH_ESCAPE,
529
+ BINARY_NUMBER_MODE,
530
+ BINARY_NUMBER_RE,
531
+ COMMENT,
532
+ C_BLOCK_COMMENT_MODE,
533
+ C_LINE_COMMENT_MODE,
534
+ C_NUMBER_MODE,
535
+ C_NUMBER_RE,
536
+ END_SAME_AS_BEGIN,
537
+ HASH_COMMENT_MODE,
538
+ IDENT_RE,
539
+ MATCH_NOTHING_RE,
540
+ METHOD_GUARD,
541
+ NUMBER_MODE,
542
+ NUMBER_RE,
543
+ PHRASAL_WORDS_MODE,
544
+ QUOTE_STRING_MODE,
545
+ REGEXP_MODE,
546
+ RE_STARTERS_RE,
547
+ SHEBANG,
548
+ TITLE_MODE,
549
+ UNDERSCORE_IDENT_RE,
550
+ UNDERSCORE_TITLE_MODE
551
+ });
552
+ function skipIfHasPrecedingDot(match, response) {
553
+ const before = match.input[match.index - 1];
554
+ if (before === ".") {
555
+ response.ignoreMatch();
556
+ }
557
+ }
558
+ function scopeClassName(mode, _parent) {
559
+ if (mode.className !== void 0) {
560
+ mode.scope = mode.className;
561
+ delete mode.className;
562
+ }
563
+ }
564
+ function beginKeywords(mode, parent) {
565
+ if (!parent)
566
+ return;
567
+ if (!mode.beginKeywords)
568
+ return;
569
+ mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
570
+ mode.__beforeBegin = skipIfHasPrecedingDot;
571
+ mode.keywords = mode.keywords || mode.beginKeywords;
572
+ delete mode.beginKeywords;
573
+ if (mode.relevance === void 0)
574
+ mode.relevance = 0;
575
+ }
576
+ function compileIllegal(mode, _parent) {
577
+ if (!Array.isArray(mode.illegal))
578
+ return;
579
+ mode.illegal = either(...mode.illegal);
580
+ }
581
+ function compileMatch(mode, _parent) {
582
+ if (!mode.match)
583
+ return;
584
+ if (mode.begin || mode.end)
585
+ throw new Error("begin & end are not supported with match");
586
+ mode.begin = mode.match;
587
+ delete mode.match;
588
+ }
589
+ function compileRelevance(mode, _parent) {
590
+ if (mode.relevance === void 0)
591
+ mode.relevance = 1;
592
+ }
593
+ var beforeMatchExt = (mode, parent) => {
594
+ if (!mode.beforeMatch)
595
+ return;
596
+ if (mode.starts)
597
+ throw new Error("beforeMatch cannot be used with starts");
598
+ const originalMode = Object.assign({}, mode);
599
+ Object.keys(mode).forEach((key) => {
600
+ delete mode[key];
601
+ });
602
+ mode.keywords = originalMode.keywords;
603
+ mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
604
+ mode.starts = {
605
+ relevance: 0,
606
+ contains: [
607
+ Object.assign(originalMode, { endsParent: true })
608
+ ]
609
+ };
610
+ mode.relevance = 0;
611
+ delete originalMode.beforeMatch;
612
+ };
613
+ var COMMON_KEYWORDS = [
614
+ "of",
615
+ "and",
616
+ "for",
617
+ "in",
618
+ "not",
619
+ "or",
620
+ "if",
621
+ "then",
622
+ "parent",
623
+ // common variable name
624
+ "list",
625
+ // common variable name
626
+ "value"
627
+ // common variable name
628
+ ];
629
+ var DEFAULT_KEYWORD_SCOPE = "keyword";
630
+ function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
631
+ const compiledKeywords = /* @__PURE__ */ Object.create(null);
632
+ if (typeof rawKeywords === "string") {
633
+ compileList(scopeName, rawKeywords.split(" "));
634
+ } else if (Array.isArray(rawKeywords)) {
635
+ compileList(scopeName, rawKeywords);
636
+ } else {
637
+ Object.keys(rawKeywords).forEach(function(scopeName2) {
638
+ Object.assign(
639
+ compiledKeywords,
640
+ compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
641
+ );
642
+ });
643
+ }
644
+ return compiledKeywords;
645
+ function compileList(scopeName2, keywordList) {
646
+ if (caseInsensitive) {
647
+ keywordList = keywordList.map((x) => x.toLowerCase());
648
+ }
649
+ keywordList.forEach(function(keyword) {
650
+ const pair = keyword.split("|");
651
+ compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
652
+ });
653
+ }
654
+ }
655
+ function scoreForKeyword(keyword, providedScore) {
656
+ if (providedScore) {
657
+ return Number(providedScore);
658
+ }
659
+ return commonKeyword(keyword) ? 0 : 1;
660
+ }
661
+ function commonKeyword(keyword) {
662
+ return COMMON_KEYWORDS.includes(keyword.toLowerCase());
663
+ }
664
+ var seenDeprecations = {};
665
+ var error = (message) => {
666
+ console.error(message);
667
+ };
668
+ var warn = (message, ...args) => {
669
+ console.log(`WARN: ${message}`, ...args);
670
+ };
671
+ var deprecated = (version2, message) => {
672
+ if (seenDeprecations[`${version2}/${message}`])
673
+ return;
674
+ console.log(`Deprecated as of ${version2}. ${message}`);
675
+ seenDeprecations[`${version2}/${message}`] = true;
676
+ };
677
+ var MultiClassError = new Error();
678
+ function remapScopeNames(mode, regexes, { key }) {
679
+ let offset = 0;
680
+ const scopeNames = mode[key];
681
+ const emit = {};
682
+ const positions = {};
683
+ for (let i = 1; i <= regexes.length; i++) {
684
+ positions[i + offset] = scopeNames[i];
685
+ emit[i + offset] = true;
686
+ offset += countMatchGroups(regexes[i - 1]);
687
+ }
688
+ mode[key] = positions;
689
+ mode[key]._emit = emit;
690
+ mode[key]._multi = true;
691
+ }
692
+ function beginMultiClass(mode) {
693
+ if (!Array.isArray(mode.begin))
694
+ return;
695
+ if (mode.skip || mode.excludeBegin || mode.returnBegin) {
696
+ error("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
697
+ throw MultiClassError;
698
+ }
699
+ if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
700
+ error("beginScope must be object");
701
+ throw MultiClassError;
702
+ }
703
+ remapScopeNames(mode, mode.begin, { key: "beginScope" });
704
+ mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
705
+ }
706
+ function endMultiClass(mode) {
707
+ if (!Array.isArray(mode.end))
708
+ return;
709
+ if (mode.skip || mode.excludeEnd || mode.returnEnd) {
710
+ error("skip, excludeEnd, returnEnd not compatible with endScope: {}");
711
+ throw MultiClassError;
712
+ }
713
+ if (typeof mode.endScope !== "object" || mode.endScope === null) {
714
+ error("endScope must be object");
715
+ throw MultiClassError;
716
+ }
717
+ remapScopeNames(mode, mode.end, { key: "endScope" });
718
+ mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
719
+ }
720
+ function scopeSugar(mode) {
721
+ if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
722
+ mode.beginScope = mode.scope;
723
+ delete mode.scope;
724
+ }
725
+ }
726
+ function MultiClass(mode) {
727
+ scopeSugar(mode);
728
+ if (typeof mode.beginScope === "string") {
729
+ mode.beginScope = { _wrap: mode.beginScope };
730
+ }
731
+ if (typeof mode.endScope === "string") {
732
+ mode.endScope = { _wrap: mode.endScope };
733
+ }
734
+ beginMultiClass(mode);
735
+ endMultiClass(mode);
736
+ }
737
+ function compileLanguage(language) {
738
+ function langRe(value, global) {
739
+ return new RegExp(
740
+ source(value),
741
+ "m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "")
742
+ );
743
+ }
744
+ class MultiRegex {
745
+ constructor() {
746
+ this.matchIndexes = {};
747
+ this.regexes = [];
748
+ this.matchAt = 1;
749
+ this.position = 0;
750
+ }
751
+ // @ts-ignore
752
+ addRule(re, opts) {
753
+ opts.position = this.position++;
754
+ this.matchIndexes[this.matchAt] = opts;
755
+ this.regexes.push([opts, re]);
756
+ this.matchAt += countMatchGroups(re) + 1;
757
+ }
758
+ compile() {
759
+ if (this.regexes.length === 0) {
760
+ this.exec = () => null;
761
+ }
762
+ const terminators = this.regexes.map((el) => el[1]);
763
+ this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
764
+ this.lastIndex = 0;
765
+ }
766
+ /** @param {string} s */
767
+ exec(s) {
768
+ this.matcherRe.lastIndex = this.lastIndex;
769
+ const match = this.matcherRe.exec(s);
770
+ if (!match) {
771
+ return null;
772
+ }
773
+ const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0);
774
+ const matchData = this.matchIndexes[i];
775
+ match.splice(0, i);
776
+ return Object.assign(match, matchData);
777
+ }
778
+ }
779
+ class ResumableMultiRegex {
780
+ constructor() {
781
+ this.rules = [];
782
+ this.multiRegexes = [];
783
+ this.count = 0;
784
+ this.lastIndex = 0;
785
+ this.regexIndex = 0;
786
+ }
787
+ // @ts-ignore
788
+ getMatcher(index) {
789
+ if (this.multiRegexes[index])
790
+ return this.multiRegexes[index];
791
+ const matcher = new MultiRegex();
792
+ this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
793
+ matcher.compile();
794
+ this.multiRegexes[index] = matcher;
795
+ return matcher;
796
+ }
797
+ resumingScanAtSamePosition() {
798
+ return this.regexIndex !== 0;
799
+ }
800
+ considerAll() {
801
+ this.regexIndex = 0;
802
+ }
803
+ // @ts-ignore
804
+ addRule(re, opts) {
805
+ this.rules.push([re, opts]);
806
+ if (opts.type === "begin")
807
+ this.count++;
808
+ }
809
+ /** @param {string} s */
810
+ exec(s) {
811
+ const m = this.getMatcher(this.regexIndex);
812
+ m.lastIndex = this.lastIndex;
813
+ let result = m.exec(s);
814
+ if (this.resumingScanAtSamePosition()) {
815
+ if (result && result.index === this.lastIndex)
816
+ ;
817
+ else {
818
+ const m2 = this.getMatcher(0);
819
+ m2.lastIndex = this.lastIndex + 1;
820
+ result = m2.exec(s);
821
+ }
822
+ }
823
+ if (result) {
824
+ this.regexIndex += result.position + 1;
825
+ if (this.regexIndex === this.count) {
826
+ this.considerAll();
827
+ }
828
+ }
829
+ return result;
830
+ }
831
+ }
832
+ function buildModeRegex(mode) {
833
+ const mm = new ResumableMultiRegex();
834
+ mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
835
+ if (mode.terminatorEnd) {
836
+ mm.addRule(mode.terminatorEnd, { type: "end" });
837
+ }
838
+ if (mode.illegal) {
839
+ mm.addRule(mode.illegal, { type: "illegal" });
840
+ }
841
+ return mm;
842
+ }
843
+ function compileMode(mode, parent) {
844
+ const cmode = (
845
+ /** @type CompiledMode */
846
+ mode
847
+ );
848
+ if (mode.isCompiled)
849
+ return cmode;
850
+ [
851
+ scopeClassName,
852
+ // do this early so compiler extensions generally don't have to worry about
853
+ // the distinction between match/begin
854
+ compileMatch,
855
+ MultiClass,
856
+ beforeMatchExt
857
+ ].forEach((ext) => ext(mode, parent));
858
+ language.compilerExtensions.forEach((ext) => ext(mode, parent));
859
+ mode.__beforeBegin = null;
860
+ [
861
+ beginKeywords,
862
+ // do this later so compiler extensions that come earlier have access to the
863
+ // raw array if they wanted to perhaps manipulate it, etc.
864
+ compileIllegal,
865
+ // default to 1 relevance if not specified
866
+ compileRelevance
867
+ ].forEach((ext) => ext(mode, parent));
868
+ mode.isCompiled = true;
869
+ let keywordPattern = null;
870
+ if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
871
+ mode.keywords = Object.assign({}, mode.keywords);
872
+ keywordPattern = mode.keywords.$pattern;
873
+ delete mode.keywords.$pattern;
874
+ }
875
+ keywordPattern = keywordPattern || /\w+/;
876
+ if (mode.keywords) {
877
+ mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
878
+ }
879
+ cmode.keywordPatternRe = langRe(keywordPattern, true);
880
+ if (parent) {
881
+ if (!mode.begin)
882
+ mode.begin = /\B|\b/;
883
+ cmode.beginRe = langRe(cmode.begin);
884
+ if (!mode.end && !mode.endsWithParent)
885
+ mode.end = /\B|\b/;
886
+ if (mode.end)
887
+ cmode.endRe = langRe(cmode.end);
888
+ cmode.terminatorEnd = source(cmode.end) || "";
889
+ if (mode.endsWithParent && parent.terminatorEnd) {
890
+ cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
891
+ }
892
+ }
893
+ if (mode.illegal)
894
+ cmode.illegalRe = langRe(
895
+ /** @type {RegExp | string} */
896
+ mode.illegal
897
+ );
898
+ if (!mode.contains)
899
+ mode.contains = [];
900
+ mode.contains = [].concat(...mode.contains.map(function(c) {
901
+ return expandOrCloneMode(c === "self" ? mode : c);
902
+ }));
903
+ mode.contains.forEach(function(c) {
904
+ compileMode(
905
+ /** @type Mode */
906
+ c,
907
+ cmode
908
+ );
909
+ });
910
+ if (mode.starts) {
911
+ compileMode(mode.starts, parent);
912
+ }
913
+ cmode.matcher = buildModeRegex(cmode);
914
+ return cmode;
915
+ }
916
+ if (!language.compilerExtensions)
917
+ language.compilerExtensions = [];
918
+ if (language.contains && language.contains.includes("self")) {
919
+ throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
920
+ }
921
+ language.classNameAliases = inherit$1(language.classNameAliases || {});
922
+ return compileMode(
923
+ /** @type Mode */
924
+ language
925
+ );
926
+ }
927
+ function dependencyOnParent(mode) {
928
+ if (!mode)
929
+ return false;
930
+ return mode.endsWithParent || dependencyOnParent(mode.starts);
931
+ }
932
+ function expandOrCloneMode(mode) {
933
+ if (mode.variants && !mode.cachedVariants) {
934
+ mode.cachedVariants = mode.variants.map(function(variant) {
935
+ return inherit$1(mode, { variants: null }, variant);
936
+ });
937
+ }
938
+ if (mode.cachedVariants) {
939
+ return mode.cachedVariants;
940
+ }
941
+ if (dependencyOnParent(mode)) {
942
+ return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
943
+ }
944
+ if (Object.isFrozen(mode)) {
945
+ return inherit$1(mode);
946
+ }
947
+ return mode;
948
+ }
949
+ var version = "11.9.0";
950
+ var HTMLInjectionError = class extends Error {
951
+ constructor(reason, html) {
952
+ super(reason);
953
+ this.name = "HTMLInjectionError";
954
+ this.html = html;
955
+ }
956
+ };
957
+ var escape = escapeHTML;
958
+ var inherit = inherit$1;
959
+ var NO_MATCH = Symbol("nomatch");
960
+ var MAX_KEYWORD_HITS = 7;
961
+ var HLJS = function(hljs) {
962
+ const languages = /* @__PURE__ */ Object.create(null);
963
+ const aliases = /* @__PURE__ */ Object.create(null);
964
+ const plugins = [];
965
+ let SAFE_MODE = true;
966
+ const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
967
+ const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
968
+ let options = {
969
+ ignoreUnescapedHTML: false,
970
+ throwUnescapedHTML: false,
971
+ noHighlightRe: /^(no-?highlight)$/i,
972
+ languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
973
+ classPrefix: "hljs-",
974
+ cssSelector: "pre code",
975
+ languages: null,
976
+ // beta configuration options, subject to change, welcome to discuss
977
+ // https://github.com/highlightjs/highlight.js/issues/1086
978
+ __emitter: TokenTreeEmitter
979
+ };
980
+ function shouldNotHighlight(languageName) {
981
+ return options.noHighlightRe.test(languageName);
982
+ }
983
+ function blockLanguage(block) {
984
+ let classes = block.className + " ";
985
+ classes += block.parentNode ? block.parentNode.className : "";
986
+ const match = options.languageDetectRe.exec(classes);
987
+ if (match) {
988
+ const language = getLanguage(match[1]);
989
+ if (!language) {
990
+ warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
991
+ warn("Falling back to no-highlight mode for this block.", block);
992
+ }
993
+ return language ? match[1] : "no-highlight";
994
+ }
995
+ return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
996
+ }
997
+ function highlight3(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
998
+ let code = "";
999
+ let languageName = "";
1000
+ if (typeof optionsOrCode === "object") {
1001
+ code = codeOrLanguageName;
1002
+ ignoreIllegals = optionsOrCode.ignoreIllegals;
1003
+ languageName = optionsOrCode.language;
1004
+ } else {
1005
+ deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
1006
+ deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
1007
+ languageName = codeOrLanguageName;
1008
+ code = optionsOrCode;
1009
+ }
1010
+ if (ignoreIllegals === void 0) {
1011
+ ignoreIllegals = true;
1012
+ }
1013
+ const context = {
1014
+ code,
1015
+ language: languageName
1016
+ };
1017
+ fire("before:highlight", context);
1018
+ const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
1019
+ result.code = context.code;
1020
+ fire("after:highlight", result);
1021
+ return result;
1022
+ }
1023
+ function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
1024
+ const keywordHits = /* @__PURE__ */ Object.create(null);
1025
+ function keywordData(mode, matchText) {
1026
+ return mode.keywords[matchText];
1027
+ }
1028
+ function processKeywords() {
1029
+ if (!top.keywords) {
1030
+ emitter.addText(modeBuffer);
1031
+ return;
1032
+ }
1033
+ let lastIndex = 0;
1034
+ top.keywordPatternRe.lastIndex = 0;
1035
+ let match = top.keywordPatternRe.exec(modeBuffer);
1036
+ let buf = "";
1037
+ while (match) {
1038
+ buf += modeBuffer.substring(lastIndex, match.index);
1039
+ const word = language.case_insensitive ? match[0].toLowerCase() : match[0];
1040
+ const data = keywordData(top, word);
1041
+ if (data) {
1042
+ const [kind, keywordRelevance] = data;
1043
+ emitter.addText(buf);
1044
+ buf = "";
1045
+ keywordHits[word] = (keywordHits[word] || 0) + 1;
1046
+ if (keywordHits[word] <= MAX_KEYWORD_HITS)
1047
+ relevance += keywordRelevance;
1048
+ if (kind.startsWith("_")) {
1049
+ buf += match[0];
1050
+ } else {
1051
+ const cssClass = language.classNameAliases[kind] || kind;
1052
+ emitKeyword(match[0], cssClass);
1053
+ }
1054
+ } else {
1055
+ buf += match[0];
1056
+ }
1057
+ lastIndex = top.keywordPatternRe.lastIndex;
1058
+ match = top.keywordPatternRe.exec(modeBuffer);
1059
+ }
1060
+ buf += modeBuffer.substring(lastIndex);
1061
+ emitter.addText(buf);
1062
+ }
1063
+ function processSubLanguage() {
1064
+ if (modeBuffer === "")
1065
+ return;
1066
+ let result2 = null;
1067
+ if (typeof top.subLanguage === "string") {
1068
+ if (!languages[top.subLanguage]) {
1069
+ emitter.addText(modeBuffer);
1070
+ return;
1071
+ }
1072
+ result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
1073
+ continuations[top.subLanguage] = /** @type {CompiledMode} */
1074
+ result2._top;
1075
+ } else {
1076
+ result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
1077
+ }
1078
+ if (top.relevance > 0) {
1079
+ relevance += result2.relevance;
1080
+ }
1081
+ emitter.__addSublanguage(result2._emitter, result2.language);
1082
+ }
1083
+ function processBuffer() {
1084
+ if (top.subLanguage != null) {
1085
+ processSubLanguage();
1086
+ } else {
1087
+ processKeywords();
1088
+ }
1089
+ modeBuffer = "";
1090
+ }
1091
+ function emitKeyword(keyword, scope) {
1092
+ if (keyword === "")
1093
+ return;
1094
+ emitter.startScope(scope);
1095
+ emitter.addText(keyword);
1096
+ emitter.endScope();
1097
+ }
1098
+ function emitMultiClass(scope, match) {
1099
+ let i = 1;
1100
+ const max = match.length - 1;
1101
+ while (i <= max) {
1102
+ if (!scope._emit[i]) {
1103
+ i++;
1104
+ continue;
1105
+ }
1106
+ const klass = language.classNameAliases[scope[i]] || scope[i];
1107
+ const text = match[i];
1108
+ if (klass) {
1109
+ emitKeyword(text, klass);
1110
+ } else {
1111
+ modeBuffer = text;
1112
+ processKeywords();
1113
+ modeBuffer = "";
1114
+ }
1115
+ i++;
1116
+ }
1117
+ }
1118
+ function startNewMode(mode, match) {
1119
+ if (mode.scope && typeof mode.scope === "string") {
1120
+ emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
1121
+ }
1122
+ if (mode.beginScope) {
1123
+ if (mode.beginScope._wrap) {
1124
+ emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
1125
+ modeBuffer = "";
1126
+ } else if (mode.beginScope._multi) {
1127
+ emitMultiClass(mode.beginScope, match);
1128
+ modeBuffer = "";
1129
+ }
1130
+ }
1131
+ top = Object.create(mode, { parent: { value: top } });
1132
+ return top;
1133
+ }
1134
+ function endOfMode(mode, match, matchPlusRemainder) {
1135
+ let matched = startsWith(mode.endRe, matchPlusRemainder);
1136
+ if (matched) {
1137
+ if (mode["on:end"]) {
1138
+ const resp = new Response(mode);
1139
+ mode["on:end"](match, resp);
1140
+ if (resp.isMatchIgnored)
1141
+ matched = false;
1142
+ }
1143
+ if (matched) {
1144
+ while (mode.endsParent && mode.parent) {
1145
+ mode = mode.parent;
1146
+ }
1147
+ return mode;
1148
+ }
1149
+ }
1150
+ if (mode.endsWithParent) {
1151
+ return endOfMode(mode.parent, match, matchPlusRemainder);
1152
+ }
1153
+ }
1154
+ function doIgnore(lexeme) {
1155
+ if (top.matcher.regexIndex === 0) {
1156
+ modeBuffer += lexeme[0];
1157
+ return 1;
1158
+ } else {
1159
+ resumeScanAtSamePosition = true;
1160
+ return 0;
1161
+ }
1162
+ }
1163
+ function doBeginMatch(match) {
1164
+ const lexeme = match[0];
1165
+ const newMode = match.rule;
1166
+ const resp = new Response(newMode);
1167
+ const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
1168
+ for (const cb of beforeCallbacks) {
1169
+ if (!cb)
1170
+ continue;
1171
+ cb(match, resp);
1172
+ if (resp.isMatchIgnored)
1173
+ return doIgnore(lexeme);
1174
+ }
1175
+ if (newMode.skip) {
1176
+ modeBuffer += lexeme;
1177
+ } else {
1178
+ if (newMode.excludeBegin) {
1179
+ modeBuffer += lexeme;
1180
+ }
1181
+ processBuffer();
1182
+ if (!newMode.returnBegin && !newMode.excludeBegin) {
1183
+ modeBuffer = lexeme;
1184
+ }
1185
+ }
1186
+ startNewMode(newMode, match);
1187
+ return newMode.returnBegin ? 0 : lexeme.length;
1188
+ }
1189
+ function doEndMatch(match) {
1190
+ const lexeme = match[0];
1191
+ const matchPlusRemainder = codeToHighlight.substring(match.index);
1192
+ const endMode = endOfMode(top, match, matchPlusRemainder);
1193
+ if (!endMode) {
1194
+ return NO_MATCH;
1195
+ }
1196
+ const origin = top;
1197
+ if (top.endScope && top.endScope._wrap) {
1198
+ processBuffer();
1199
+ emitKeyword(lexeme, top.endScope._wrap);
1200
+ } else if (top.endScope && top.endScope._multi) {
1201
+ processBuffer();
1202
+ emitMultiClass(top.endScope, match);
1203
+ } else if (origin.skip) {
1204
+ modeBuffer += lexeme;
1205
+ } else {
1206
+ if (!(origin.returnEnd || origin.excludeEnd)) {
1207
+ modeBuffer += lexeme;
1208
+ }
1209
+ processBuffer();
1210
+ if (origin.excludeEnd) {
1211
+ modeBuffer = lexeme;
1212
+ }
1213
+ }
1214
+ do {
1215
+ if (top.scope) {
1216
+ emitter.closeNode();
1217
+ }
1218
+ if (!top.skip && !top.subLanguage) {
1219
+ relevance += top.relevance;
1220
+ }
1221
+ top = top.parent;
1222
+ } while (top !== endMode.parent);
1223
+ if (endMode.starts) {
1224
+ startNewMode(endMode.starts, match);
1225
+ }
1226
+ return origin.returnEnd ? 0 : lexeme.length;
1227
+ }
1228
+ function processContinuations() {
1229
+ const list = [];
1230
+ for (let current = top; current !== language; current = current.parent) {
1231
+ if (current.scope) {
1232
+ list.unshift(current.scope);
1233
+ }
1234
+ }
1235
+ list.forEach((item) => emitter.openNode(item));
1236
+ }
1237
+ let lastMatch = {};
1238
+ function processLexeme(textBeforeMatch, match) {
1239
+ const lexeme = match && match[0];
1240
+ modeBuffer += textBeforeMatch;
1241
+ if (lexeme == null) {
1242
+ processBuffer();
1243
+ return 0;
1244
+ }
1245
+ if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
1246
+ modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
1247
+ if (!SAFE_MODE) {
1248
+ const err = new Error(`0 width match regex (${languageName})`);
1249
+ err.languageName = languageName;
1250
+ err.badRule = lastMatch.rule;
1251
+ throw err;
1252
+ }
1253
+ return 1;
1254
+ }
1255
+ lastMatch = match;
1256
+ if (match.type === "begin") {
1257
+ return doBeginMatch(match);
1258
+ } else if (match.type === "illegal" && !ignoreIllegals) {
1259
+ const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
1260
+ err.mode = top;
1261
+ throw err;
1262
+ } else if (match.type === "end") {
1263
+ const processed = doEndMatch(match);
1264
+ if (processed !== NO_MATCH) {
1265
+ return processed;
1266
+ }
1267
+ }
1268
+ if (match.type === "illegal" && lexeme === "") {
1269
+ return 1;
1270
+ }
1271
+ if (iterations > 1e5 && iterations > match.index * 3) {
1272
+ const err = new Error("potential infinite loop, way more iterations than matches");
1273
+ throw err;
1274
+ }
1275
+ modeBuffer += lexeme;
1276
+ return lexeme.length;
1277
+ }
1278
+ const language = getLanguage(languageName);
1279
+ if (!language) {
1280
+ error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
1281
+ throw new Error('Unknown language: "' + languageName + '"');
1282
+ }
1283
+ const md = compileLanguage(language);
1284
+ let result = "";
1285
+ let top = continuation || md;
1286
+ const continuations = {};
1287
+ const emitter = new options.__emitter(options);
1288
+ processContinuations();
1289
+ let modeBuffer = "";
1290
+ let relevance = 0;
1291
+ let index = 0;
1292
+ let iterations = 0;
1293
+ let resumeScanAtSamePosition = false;
1294
+ try {
1295
+ if (!language.__emitTokens) {
1296
+ top.matcher.considerAll();
1297
+ for (; ; ) {
1298
+ iterations++;
1299
+ if (resumeScanAtSamePosition) {
1300
+ resumeScanAtSamePosition = false;
1301
+ } else {
1302
+ top.matcher.considerAll();
1303
+ }
1304
+ top.matcher.lastIndex = index;
1305
+ const match = top.matcher.exec(codeToHighlight);
1306
+ if (!match)
1307
+ break;
1308
+ const beforeMatch = codeToHighlight.substring(index, match.index);
1309
+ const processedCount = processLexeme(beforeMatch, match);
1310
+ index = match.index + processedCount;
1311
+ }
1312
+ processLexeme(codeToHighlight.substring(index));
1313
+ } else {
1314
+ language.__emitTokens(codeToHighlight, emitter);
1315
+ }
1316
+ emitter.finalize();
1317
+ result = emitter.toHTML();
1318
+ return {
1319
+ language: languageName,
1320
+ value: result,
1321
+ relevance,
1322
+ illegal: false,
1323
+ _emitter: emitter,
1324
+ _top: top
1325
+ };
1326
+ } catch (err) {
1327
+ if (err.message && err.message.includes("Illegal")) {
1328
+ return {
1329
+ language: languageName,
1330
+ value: escape(codeToHighlight),
1331
+ illegal: true,
1332
+ relevance: 0,
1333
+ _illegalBy: {
1334
+ message: err.message,
1335
+ index,
1336
+ context: codeToHighlight.slice(index - 100, index + 100),
1337
+ mode: err.mode,
1338
+ resultSoFar: result
1339
+ },
1340
+ _emitter: emitter
1341
+ };
1342
+ } else if (SAFE_MODE) {
1343
+ return {
1344
+ language: languageName,
1345
+ value: escape(codeToHighlight),
1346
+ illegal: false,
1347
+ relevance: 0,
1348
+ errorRaised: err,
1349
+ _emitter: emitter,
1350
+ _top: top
1351
+ };
1352
+ } else {
1353
+ throw err;
1354
+ }
1355
+ }
1356
+ }
1357
+ function justTextHighlightResult(code) {
1358
+ const result = {
1359
+ value: escape(code),
1360
+ illegal: false,
1361
+ relevance: 0,
1362
+ _top: PLAINTEXT_LANGUAGE,
1363
+ _emitter: new options.__emitter(options)
1364
+ };
1365
+ result._emitter.addText(code);
1366
+ return result;
1367
+ }
1368
+ function highlightAuto(code, languageSubset) {
1369
+ languageSubset = languageSubset || options.languages || Object.keys(languages);
1370
+ const plaintext = justTextHighlightResult(code);
1371
+ const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
1372
+ (name) => _highlight(name, code, false)
1373
+ );
1374
+ results.unshift(plaintext);
1375
+ const sorted = results.sort((a, b) => {
1376
+ if (a.relevance !== b.relevance)
1377
+ return b.relevance - a.relevance;
1378
+ if (a.language && b.language) {
1379
+ if (getLanguage(a.language).supersetOf === b.language) {
1380
+ return 1;
1381
+ } else if (getLanguage(b.language).supersetOf === a.language) {
1382
+ return -1;
1383
+ }
1384
+ }
1385
+ return 0;
1386
+ });
1387
+ const [best, secondBest] = sorted;
1388
+ const result = best;
1389
+ result.secondBest = secondBest;
1390
+ return result;
1391
+ }
1392
+ function updateClassName(element, currentLang, resultLang) {
1393
+ const language = currentLang && aliases[currentLang] || resultLang;
1394
+ element.classList.add("hljs");
1395
+ element.classList.add(`language-${language}`);
1396
+ }
1397
+ function highlightElement(element) {
1398
+ let node = null;
1399
+ const language = blockLanguage(element);
1400
+ if (shouldNotHighlight(language))
1401
+ return;
1402
+ fire(
1403
+ "before:highlightElement",
1404
+ { el: element, language }
1405
+ );
1406
+ if (element.dataset.highlighted) {
1407
+ console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
1408
+ return;
1409
+ }
1410
+ if (element.children.length > 0) {
1411
+ if (!options.ignoreUnescapedHTML) {
1412
+ console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
1413
+ console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
1414
+ console.warn("The element with unescaped HTML:");
1415
+ console.warn(element);
1416
+ }
1417
+ if (options.throwUnescapedHTML) {
1418
+ const err = new HTMLInjectionError(
1419
+ "One of your code blocks includes unescaped HTML.",
1420
+ element.innerHTML
1421
+ );
1422
+ throw err;
1423
+ }
1424
+ }
1425
+ node = element;
1426
+ const text = node.textContent;
1427
+ const result = language ? highlight3(text, { language, ignoreIllegals: true }) : highlightAuto(text);
1428
+ element.innerHTML = result.value;
1429
+ element.dataset.highlighted = "yes";
1430
+ updateClassName(element, language, result.language);
1431
+ element.result = {
1432
+ language: result.language,
1433
+ // TODO: remove with version 11.0
1434
+ re: result.relevance,
1435
+ relevance: result.relevance
1436
+ };
1437
+ if (result.secondBest) {
1438
+ element.secondBest = {
1439
+ language: result.secondBest.language,
1440
+ relevance: result.secondBest.relevance
1441
+ };
1442
+ }
1443
+ fire("after:highlightElement", { el: element, result, text });
1444
+ }
1445
+ function configure(userOptions) {
1446
+ options = inherit(options, userOptions);
1447
+ }
1448
+ const initHighlighting = () => {
1449
+ highlightAll();
1450
+ deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
1451
+ };
1452
+ function initHighlightingOnLoad() {
1453
+ highlightAll();
1454
+ deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
1455
+ }
1456
+ let wantsHighlight = false;
1457
+ function highlightAll() {
1458
+ if (document.readyState === "loading") {
1459
+ wantsHighlight = true;
1460
+ return;
1461
+ }
1462
+ const blocks = document.querySelectorAll(options.cssSelector);
1463
+ blocks.forEach(highlightElement);
1464
+ }
1465
+ function boot() {
1466
+ if (wantsHighlight)
1467
+ highlightAll();
1468
+ }
1469
+ if (typeof window !== "undefined" && window.addEventListener) {
1470
+ window.addEventListener("DOMContentLoaded", boot, false);
1471
+ }
1472
+ function registerLanguage(languageName, languageDefinition) {
1473
+ let lang = null;
1474
+ try {
1475
+ lang = languageDefinition(hljs);
1476
+ } catch (error$1) {
1477
+ error("Language definition for '{}' could not be registered.".replace("{}", languageName));
1478
+ if (!SAFE_MODE) {
1479
+ throw error$1;
1480
+ } else {
1481
+ error(error$1);
1482
+ }
1483
+ lang = PLAINTEXT_LANGUAGE;
1484
+ }
1485
+ if (!lang.name)
1486
+ lang.name = languageName;
1487
+ languages[languageName] = lang;
1488
+ lang.rawDefinition = languageDefinition.bind(null, hljs);
1489
+ if (lang.aliases) {
1490
+ registerAliases(lang.aliases, { languageName });
1491
+ }
1492
+ }
1493
+ function unregisterLanguage(languageName) {
1494
+ delete languages[languageName];
1495
+ for (const alias of Object.keys(aliases)) {
1496
+ if (aliases[alias] === languageName) {
1497
+ delete aliases[alias];
1498
+ }
1499
+ }
1500
+ }
1501
+ function listLanguages() {
1502
+ return Object.keys(languages);
1503
+ }
1504
+ function getLanguage(name) {
1505
+ name = (name || "").toLowerCase();
1506
+ return languages[name] || languages[aliases[name]];
1507
+ }
1508
+ function registerAliases(aliasList, { languageName }) {
1509
+ if (typeof aliasList === "string") {
1510
+ aliasList = [aliasList];
1511
+ }
1512
+ aliasList.forEach((alias) => {
1513
+ aliases[alias.toLowerCase()] = languageName;
1514
+ });
1515
+ }
1516
+ function autoDetection(name) {
1517
+ const lang = getLanguage(name);
1518
+ return lang && !lang.disableAutodetect;
1519
+ }
1520
+ function upgradePluginAPI(plugin) {
1521
+ if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
1522
+ plugin["before:highlightElement"] = (data) => {
1523
+ plugin["before:highlightBlock"](
1524
+ Object.assign({ block: data.el }, data)
1525
+ );
1526
+ };
1527
+ }
1528
+ if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
1529
+ plugin["after:highlightElement"] = (data) => {
1530
+ plugin["after:highlightBlock"](
1531
+ Object.assign({ block: data.el }, data)
1532
+ );
1533
+ };
1534
+ }
1535
+ }
1536
+ function addPlugin(plugin) {
1537
+ upgradePluginAPI(plugin);
1538
+ plugins.push(plugin);
1539
+ }
1540
+ function removePlugin(plugin) {
1541
+ const index = plugins.indexOf(plugin);
1542
+ if (index !== -1) {
1543
+ plugins.splice(index, 1);
1544
+ }
1545
+ }
1546
+ function fire(event, args) {
1547
+ const cb = event;
1548
+ plugins.forEach(function(plugin) {
1549
+ if (plugin[cb]) {
1550
+ plugin[cb](args);
1551
+ }
1552
+ });
1553
+ }
1554
+ function deprecateHighlightBlock(el) {
1555
+ deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
1556
+ deprecated("10.7.0", "Please use highlightElement now.");
1557
+ return highlightElement(el);
1558
+ }
1559
+ Object.assign(hljs, {
1560
+ highlight: highlight3,
1561
+ highlightAuto,
1562
+ highlightAll,
1563
+ highlightElement,
1564
+ // TODO: Remove with v12 API
1565
+ highlightBlock: deprecateHighlightBlock,
1566
+ configure,
1567
+ initHighlighting,
1568
+ initHighlightingOnLoad,
1569
+ registerLanguage,
1570
+ unregisterLanguage,
1571
+ listLanguages,
1572
+ getLanguage,
1573
+ registerAliases,
1574
+ autoDetection,
1575
+ inherit,
1576
+ addPlugin,
1577
+ removePlugin
1578
+ });
1579
+ hljs.debugMode = function() {
1580
+ SAFE_MODE = false;
1581
+ };
1582
+ hljs.safeMode = function() {
1583
+ SAFE_MODE = true;
1584
+ };
1585
+ hljs.versionString = version;
1586
+ hljs.regex = {
1587
+ concat,
1588
+ lookahead,
1589
+ either,
1590
+ optional,
1591
+ anyNumberOfTimes
1592
+ };
1593
+ for (const key in MODES) {
1594
+ if (typeof MODES[key] === "object") {
1595
+ deepFreeze(MODES[key]);
1596
+ }
1597
+ }
1598
+ Object.assign(hljs, MODES);
1599
+ return hljs;
1600
+ };
1601
+ var highlight2 = HLJS({});
1602
+ highlight2.newInstance = () => HLJS({});
1603
+ module.exports = highlight2;
1604
+ highlight2.HighlightJS = highlight2;
1605
+ highlight2.default = highlight2;
1606
+ }
1607
+ });
1608
+
1609
+ // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExample.vue?type=script
1610
+ import { defineComponent as defineComponent2 } from "vue";
1611
+
1612
+ // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExampleSourcecode.vue?type=script
1613
+ import { defineComponent as _defineComponent } from "vue";
1614
+ import { ref, computed, onMounted, watch, nextTick } from "vue";
1615
+
1616
+ // src/expand-animation.ts
1617
+ var DURATION = 400;
1618
+ var ClassNames = {
1619
+ EXPANDING: "expanding",
1620
+ COLLAPSING: "collapsing"
1621
+ };
1622
+ var prefersReducedMotion = window.matchMedia("(prefers-reduced-motion)");
1623
+ var useAnimation = !prefersReducedMotion.matches;
1624
+ prefersReducedMotion.addEventListener("change", (event) => {
1625
+ useAnimation = !event.matches;
1626
+ });
1627
+ function expandAnimation(element) {
1628
+ let animation = null;
1629
+ let isOpen = false;
1630
+ let isClosing = false;
1631
+ let isExpanding = false;
1632
+ return {
1633
+ get isOpen() {
1634
+ return isOpen;
1635
+ },
1636
+ toggle() {
1637
+ if (useAnimation) {
1638
+ element.style.overflow = "hidden";
1639
+ if (isExpanding || isOpen) {
1640
+ isOpen = false;
1641
+ shrink();
1642
+ } else if (isClosing || !isOpen) {
1643
+ isOpen = true;
1644
+ open();
1645
+ }
1646
+ return;
1647
+ }
1648
+ if (isOpen) {
1649
+ isOpen = false;
1650
+ element.setAttribute("aria-expanded", "false");
1651
+ } else {
1652
+ isOpen = true;
1653
+ element.setAttribute("aria-expanded", "true");
1654
+ }
1655
+ }
1656
+ };
1657
+ function shrink() {
1658
+ isClosing = true;
1659
+ const startHeight = `${element.offsetHeight}px`;
1660
+ const endHeight = `0px`;
1661
+ element.classList.add(ClassNames.COLLAPSING);
1662
+ if (animation) {
1663
+ animation.cancel();
1664
+ }
1665
+ animation = element.animate(
1666
+ {
1667
+ height: [startHeight, endHeight]
1668
+ },
1669
+ {
1670
+ duration: DURATION,
1671
+ easing: "ease-in-out"
1672
+ }
1673
+ );
1674
+ animation.onfinish = () => {
1675
+ onAnimationFinish(false);
1676
+ };
1677
+ animation.oncancel = () => {
1678
+ element.classList.remove(ClassNames.COLLAPSING);
1679
+ isClosing = false;
1680
+ };
1681
+ }
1682
+ function open() {
1683
+ let currentHeight = 0;
1684
+ if (animation) {
1685
+ currentHeight = element.getBoundingClientRect().height;
1686
+ }
1687
+ element.setAttribute("aria-expanded", "true");
1688
+ window.requestAnimationFrame(() => expand(currentHeight));
1689
+ }
1690
+ function expand(currentHeight) {
1691
+ isExpanding = true;
1692
+ if (animation) {
1693
+ animation.cancel();
1694
+ element.style.height = "";
1695
+ }
1696
+ const startHeight = `${currentHeight}px`;
1697
+ const endHeight = `${element.offsetHeight}px`;
1698
+ element.classList.add(ClassNames.EXPANDING);
1699
+ animation = element.animate(
1700
+ {
1701
+ height: [startHeight, endHeight]
1702
+ },
1703
+ {
1704
+ duration: DURATION,
1705
+ easing: "ease-in-out"
1706
+ }
1707
+ );
1708
+ animation.onfinish = () => {
1709
+ onAnimationFinish(true);
1710
+ };
1711
+ animation.oncancel = () => {
1712
+ element.classList.remove(ClassNames.EXPANDING);
1713
+ isExpanding = false;
1714
+ };
1715
+ }
1716
+ function onAnimationFinish(open2) {
1717
+ element.setAttribute("aria-expanded", open2 ? "true" : "false");
1718
+ animation = null;
1719
+ isClosing = false;
1720
+ isExpanding = false;
1721
+ element.classList.remove(ClassNames.EXPANDING);
1722
+ element.classList.remove(ClassNames.COLLAPSING);
1723
+ element.style.height = "";
1724
+ element.style.overflow = "";
1725
+ }
1726
+ }
1727
+
1728
+ // src/utils/generate-id.ts
1729
+ function cyrb53(str) {
1730
+ const a = 2654435761;
1731
+ const b = 1597334677;
1732
+ const c = 2246822507;
1733
+ const d = 3266489909;
1734
+ const e = 4294967296;
1735
+ const f = 2097151;
1736
+ const seed = 0;
1737
+ let h1 = 3735928559 ^ seed;
1738
+ let h2 = 1103547991 ^ seed;
1739
+ for (let i = 0, ch; i < str.length; i++) {
1740
+ ch = str.charCodeAt(i);
1741
+ h1 = Math.imul(h1 ^ ch, a);
1742
+ h2 = Math.imul(h2 ^ ch, b);
1743
+ }
1744
+ h1 = Math.imul(h1 ^ h1 >>> 16, c) ^ Math.imul(h2 ^ h2 >>> 13, d);
1745
+ h2 = Math.imul(h2 ^ h2 >>> 16, c) ^ Math.imul(h1 ^ h1 >>> 13, d);
1746
+ return e * (f & h2) + (h1 >>> 0);
1747
+ }
1748
+ function generateId(template) {
1749
+ const hash = cyrb53(template);
1750
+ return `le-${hash.toString(16)}`;
1751
+ }
1752
+
1753
+ // src/utils/highlight.ts
1754
+ import prettier from "prettier/standalone";
1755
+ import htmlPlugin from "prettier/parser-html";
1756
+
1757
+ // node_modules/highlight.js/es/core.js
1758
+ var import_core = __toESM(require_core(), 1);
1759
+ var core_default = import_core.default;
1760
+
1761
+ // node_modules/highlight.js/es/languages/xml.js
1762
+ function xml(hljs) {
1763
+ const regex = hljs.regex;
1764
+ const TAG_NAME_RE = regex.concat(/[\p{L}_]/u, regex.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u);
1765
+ const XML_IDENT_RE = /[\p{L}0-9._:-]+/u;
1766
+ const XML_ENTITIES = {
1767
+ className: "symbol",
1768
+ begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/
1769
+ };
1770
+ const XML_META_KEYWORDS = {
1771
+ begin: /\s/,
1772
+ contains: [
1773
+ {
1774
+ className: "keyword",
1775
+ begin: /#?[a-z_][a-z1-9_-]+/,
1776
+ illegal: /\n/
1777
+ }
1778
+ ]
1779
+ };
1780
+ const XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, {
1781
+ begin: /\(/,
1782
+ end: /\)/
1783
+ });
1784
+ const APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, { className: "string" });
1785
+ const QUOTE_META_STRING_MODE = hljs.inherit(hljs.QUOTE_STRING_MODE, { className: "string" });
1786
+ const TAG_INTERNALS = {
1787
+ endsWithParent: true,
1788
+ illegal: /</,
1789
+ relevance: 0,
1790
+ contains: [
1791
+ {
1792
+ className: "attr",
1793
+ begin: XML_IDENT_RE,
1794
+ relevance: 0
1795
+ },
1796
+ {
1797
+ begin: /=\s*/,
1798
+ relevance: 0,
1799
+ contains: [
1800
+ {
1801
+ className: "string",
1802
+ endsParent: true,
1803
+ variants: [
1804
+ {
1805
+ begin: /"/,
1806
+ end: /"/,
1807
+ contains: [XML_ENTITIES]
1808
+ },
1809
+ {
1810
+ begin: /'/,
1811
+ end: /'/,
1812
+ contains: [XML_ENTITIES]
1813
+ },
1814
+ { begin: /[^\s"'=<>`]+/ }
1815
+ ]
1816
+ }
1817
+ ]
1818
+ }
1819
+ ]
1820
+ };
1821
+ return {
1822
+ name: "HTML, XML",
1823
+ aliases: [
1824
+ "html",
1825
+ "xhtml",
1826
+ "rss",
1827
+ "atom",
1828
+ "xjb",
1829
+ "xsd",
1830
+ "xsl",
1831
+ "plist",
1832
+ "wsf",
1833
+ "svg"
1834
+ ],
1835
+ case_insensitive: true,
1836
+ unicodeRegex: true,
1837
+ contains: [
1838
+ {
1839
+ className: "meta",
1840
+ begin: /<![a-z]/,
1841
+ end: />/,
1842
+ relevance: 10,
1843
+ contains: [
1844
+ XML_META_KEYWORDS,
1845
+ QUOTE_META_STRING_MODE,
1846
+ APOS_META_STRING_MODE,
1847
+ XML_META_PAR_KEYWORDS,
1848
+ {
1849
+ begin: /\[/,
1850
+ end: /\]/,
1851
+ contains: [
1852
+ {
1853
+ className: "meta",
1854
+ begin: /<![a-z]/,
1855
+ end: />/,
1856
+ contains: [
1857
+ XML_META_KEYWORDS,
1858
+ XML_META_PAR_KEYWORDS,
1859
+ QUOTE_META_STRING_MODE,
1860
+ APOS_META_STRING_MODE
1861
+ ]
1862
+ }
1863
+ ]
1864
+ }
1865
+ ]
1866
+ },
1867
+ hljs.COMMENT(
1868
+ /<!--/,
1869
+ /-->/,
1870
+ { relevance: 10 }
1871
+ ),
1872
+ {
1873
+ begin: /<!\[CDATA\[/,
1874
+ end: /\]\]>/,
1875
+ relevance: 10
1876
+ },
1877
+ XML_ENTITIES,
1878
+ // xml processing instructions
1879
+ {
1880
+ className: "meta",
1881
+ end: /\?>/,
1882
+ variants: [
1883
+ {
1884
+ begin: /<\?xml/,
1885
+ relevance: 10,
1886
+ contains: [
1887
+ QUOTE_META_STRING_MODE
1888
+ ]
1889
+ },
1890
+ {
1891
+ begin: /<\?[a-z][a-z0-9]+/
1892
+ }
1893
+ ]
1894
+ },
1895
+ {
1896
+ className: "tag",
1897
+ /*
1898
+ The lookahead pattern (?=...) ensures that 'begin' only matches
1899
+ '<style' as a single word, followed by a whitespace or an
1900
+ ending bracket.
1901
+ */
1902
+ begin: /<style(?=\s|>)/,
1903
+ end: />/,
1904
+ keywords: { name: "style" },
1905
+ contains: [TAG_INTERNALS],
1906
+ starts: {
1907
+ end: /<\/style>/,
1908
+ returnEnd: true,
1909
+ subLanguage: [
1910
+ "css",
1911
+ "xml"
1912
+ ]
1913
+ }
1914
+ },
1915
+ {
1916
+ className: "tag",
1917
+ // See the comment in the <style tag about the lookahead pattern
1918
+ begin: /<script(?=\s|>)/,
1919
+ end: />/,
1920
+ keywords: { name: "script" },
1921
+ contains: [TAG_INTERNALS],
1922
+ starts: {
1923
+ end: /<\/script>/,
1924
+ returnEnd: true,
1925
+ subLanguage: [
1926
+ "javascript",
1927
+ "handlebars",
1928
+ "xml"
1929
+ ]
1930
+ }
1931
+ },
1932
+ // we need this for now for jSX
1933
+ {
1934
+ className: "tag",
1935
+ begin: /<>|<\/>/
1936
+ },
1937
+ // open tag
1938
+ {
1939
+ className: "tag",
1940
+ begin: regex.concat(
1941
+ /</,
1942
+ regex.lookahead(regex.concat(
1943
+ TAG_NAME_RE,
1944
+ // <tag/>
1945
+ // <tag>
1946
+ // <tag ...
1947
+ regex.either(/\/>/, />/, /\s/)
1948
+ ))
1949
+ ),
1950
+ end: /\/?>/,
1951
+ contains: [
1952
+ {
1953
+ className: "name",
1954
+ begin: TAG_NAME_RE,
1955
+ relevance: 0,
1956
+ starts: TAG_INTERNALS
1957
+ }
1958
+ ]
1959
+ },
1960
+ // close tag
1961
+ {
1962
+ className: "tag",
1963
+ begin: regex.concat(
1964
+ /<\//,
1965
+ regex.lookahead(regex.concat(
1966
+ TAG_NAME_RE,
1967
+ />/
1968
+ ))
1969
+ ),
1970
+ contains: [
1971
+ {
1972
+ className: "name",
1973
+ begin: TAG_NAME_RE,
1974
+ relevance: 0
1975
+ },
1976
+ {
1977
+ begin: />/,
1978
+ relevance: 0,
1979
+ endsParent: true
1980
+ }
1981
+ ]
1982
+ }
1983
+ ]
1984
+ };
1985
+ }
1986
+
1987
+ // src/utils/highlight.ts
1988
+ core_default.registerLanguage("html", xml);
1989
+ var prettierConfig = {
1990
+ parser: "html",
1991
+ plugins: [htmlPlugin],
1992
+ singleQuote: false,
1993
+ arrowParens: "always",
1994
+ tabWidth: 4,
1995
+ printWidth: 80
1996
+ };
1997
+ async function highlight(code) {
1998
+ const formatted = await prettier.format(code, prettierConfig);
1999
+ const { value } = core_default.highlight(formatted, { language: "html" });
2000
+ return `<code class="hljs lang-html" tabindex="0">${value}</code>`;
2001
+ }
2002
+
2003
+ // src/utils/strip-comments.ts
2004
+ function stripComments(html) {
2005
+ const commentPattern = /<!--.*?-->/g;
2006
+ return html.replace(commentPattern, "");
2007
+ }
2008
+
2009
+ // src/utils/get-source-code.ts
2010
+ async function getSourceCode(options) {
2011
+ const { language, template, element } = options;
2012
+ if (language === "original") {
2013
+ return await highlight(template);
2014
+ } else {
2015
+ const html = element.innerHTML;
2016
+ const uncommented = stripComments(html);
2017
+ return await highlight(uncommented);
2018
+ }
2019
+ }
2020
+
2021
+ // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExampleSourcecode.vue?type=script
2022
+ var LiveExampleSourcecode_default = /* @__PURE__ */ _defineComponent({
2023
+ __name: "LiveExampleSourcecode",
2024
+ props: {
2025
+ element: {
2026
+ type: HTMLElement,
2027
+ required: true
2028
+ },
2029
+ template: {
2030
+ type: String,
2031
+ required: true
2032
+ },
2033
+ templateLanguage: {
2034
+ type: String,
2035
+ required: true
2036
+ }
2037
+ },
2038
+ setup(__props, { expose: __expose }) {
2039
+ __expose();
2040
+ const props = __props;
2041
+ let idPrefix = generateId(props.template);
2042
+ const sourcecode = ref("");
2043
+ const expandable = ref(null);
2044
+ const animation = ref({
2045
+ isOpen: false,
2046
+ toggle() {
2047
+ }
2048
+ });
2049
+ const selectedLanguage = ref(toSelectedLanguage(props.templateLanguage));
2050
+ const codeToggleText = computed(() => {
2051
+ return animation.value.isOpen ? "D\xF6lj kod" : "Visa kod";
2052
+ });
2053
+ onMounted(() => {
2054
+ if (expandable.value) {
2055
+ animation.value = expandAnimation(expandable.value);
2056
+ } else {
2057
+ throw new Error("Missing HTML element");
2058
+ }
2059
+ updateSourcecode();
2060
+ });
2061
+ watch(() => props.template, onUpdateTemplate);
2062
+ watch(() => props.templateLanguage, updateSelectedLanguage, { once: true });
2063
+ async function updateSourcecode() {
2064
+ await nextTick();
2065
+ sourcecode.value = await getSourceCode({
2066
+ language: selectedLanguage.value,
2067
+ template: props.template ?? "",
2068
+ element: unwrapElement(props.element)
2069
+ });
2070
+ }
2071
+ function unwrapElement(element) {
2072
+ const firstElementChild = element.firstElementChild;
2073
+ return firstElementChild ?? element;
2074
+ }
2075
+ function updateSelectedLanguage(value) {
2076
+ selectedLanguage.value = toSelectedLanguage(value);
2077
+ }
2078
+ function id(suffix) {
2079
+ return `${idPrefix}--${suffix}`;
2080
+ }
2081
+ function toSelectedLanguage(value) {
2082
+ return value === "html" ? "rendered" : "original";
2083
+ }
2084
+ function onUpdateTemplate(template) {
2085
+ idPrefix = generateId(template);
2086
+ updateSourcecode();
2087
+ }
2088
+ function onToggleCode() {
2089
+ animation.value.toggle();
2090
+ }
2091
+ const __returned__ = { props, get idPrefix() {
2092
+ return idPrefix;
2093
+ }, set idPrefix(v) {
2094
+ idPrefix = v;
2095
+ }, sourcecode, expandable, animation, selectedLanguage, codeToggleText, updateSourcecode, unwrapElement, updateSelectedLanguage, id, toSelectedLanguage, onUpdateTemplate, onToggleCode };
2096
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
2097
+ return __returned__;
2098
+ }
2099
+ });
2100
+
2101
+ // sfc-template:/home/runner/work/docs-live-example/docs-live-example/src/LiveExampleSourcecode.vue?type=template
2102
+ import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createCommentVNode as _createCommentVNode, vModelRadio as _vModelRadio, withDirectives as _withDirectives, openBlock as _openBlock, createElementBlock as _createElementBlock, Fragment as _Fragment, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
2103
+ var _withScopeId = (n) => (_pushScopeId("data-v-7a98eb26"), n = n(), _popScopeId(), n);
2104
+ var _hoisted_1 = { class: "live-example__code-toggle" };
2105
+ var _hoisted_2 = ["aria-controls", "aria-expanded"];
2106
+ var _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ _createElementVNode(
2107
+ "i",
2108
+ { class: "icon icon--code" },
2109
+ null,
2110
+ -1
2111
+ /* HOISTED */
2112
+ ));
2113
+ var _hoisted_4 = ["id"];
2114
+ var _hoisted_5 = {
2115
+ class: "live-example__code-languages",
2116
+ onsubmit: "event.preventDefault()"
2117
+ };
2118
+ var _hoisted_6 = {
2119
+ key: 0,
2120
+ class: "fieldset radio-button-group radio-button-group--horizontal"
2121
+ };
2122
+ var _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ _createElementVNode(
2123
+ "legend",
2124
+ { class: "label fieldset__label" },
2125
+ "Kodspr\xE5k",
2126
+ -1
2127
+ /* HOISTED */
2128
+ ));
2129
+ var _hoisted_8 = { class: "fieldset__content radio-button-group__content" };
2130
+ var _hoisted_9 = {
2131
+ key: 0,
2132
+ class: "radio-button"
2133
+ };
2134
+ var _hoisted_10 = ["id"];
2135
+ var _hoisted_11 = ["for"];
2136
+ var _hoisted_12 = { class: "radio-button" };
2137
+ var _hoisted_13 = ["id"];
2138
+ var _hoisted_14 = ["for"];
2139
+ var _hoisted_15 = ["innerHTML"];
2140
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
2141
+ return _openBlock(), _createElementBlock(
2142
+ _Fragment,
2143
+ null,
2144
+ [
2145
+ _createElementVNode("div", _hoisted_1, [
2146
+ _createElementVNode("button", {
2147
+ type: "button",
2148
+ class: "button button--discrete",
2149
+ "aria-controls": $setup.id("code-expand"),
2150
+ "aria-expanded": $setup.animation.isOpen ? "true" : "false",
2151
+ onClick: $setup.onToggleCode
2152
+ }, [
2153
+ _hoisted_3,
2154
+ _createTextVNode(
2155
+ " " + _toDisplayString($setup.codeToggleText),
2156
+ 1
2157
+ /* TEXT */
2158
+ )
2159
+ ], 8, _hoisted_2)
2160
+ ]),
2161
+ _createElementVNode("div", {
2162
+ id: $setup.id("code-expand"),
2163
+ ref: "expandable",
2164
+ class: "collapsed"
2165
+ }, [
2166
+ _createCommentVNode(" [html-validate-disable-next wcag/h32 -- this form is not meant to be submitted] "),
2167
+ _createElementVNode("form", _hoisted_5, [
2168
+ $setup.sourcecode ? (_openBlock(), _createElementBlock("fieldset", _hoisted_6, [
2169
+ _hoisted_7,
2170
+ _createElementVNode("div", _hoisted_8, [
2171
+ $props.templateLanguage === "vue" ? (_openBlock(), _createElementBlock("div", _hoisted_9, [
2172
+ _withDirectives(_createElementVNode("input", {
2173
+ id: $setup.id("lang-original"),
2174
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.selectedLanguage = $event),
2175
+ type: "radio",
2176
+ class: "radio-button__input",
2177
+ name: "selected-language",
2178
+ value: "original",
2179
+ onChange: $setup.updateSourcecode
2180
+ }, null, 40, _hoisted_10), [
2181
+ [_vModelRadio, $setup.selectedLanguage]
2182
+ ]),
2183
+ _createElementVNode("label", {
2184
+ for: $setup.id("lang-original"),
2185
+ class: "radio-button__label"
2186
+ }, " Vue ", 8, _hoisted_11)
2187
+ ])) : _createCommentVNode("v-if", true),
2188
+ _createElementVNode("div", _hoisted_12, [
2189
+ _withDirectives(_createElementVNode("input", {
2190
+ id: $setup.id("lang-rendered"),
2191
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => $setup.selectedLanguage = $event),
2192
+ type: "radio",
2193
+ class: "radio-button__input",
2194
+ name: "selected-language",
2195
+ value: "rendered",
2196
+ onChange: $setup.updateSourcecode
2197
+ }, null, 40, _hoisted_13), [
2198
+ [_vModelRadio, $setup.selectedLanguage]
2199
+ ]),
2200
+ _createElementVNode("label", {
2201
+ for: $setup.id("lang-rendered"),
2202
+ class: "radio-button__label"
2203
+ }, " HTML ", 8, _hoisted_14)
2204
+ ])
2205
+ ])
2206
+ ])) : _createCommentVNode("v-if", true)
2207
+ ]),
2208
+ _createCommentVNode(" eslint-disable-next-line vue/no-v-html -- expected to show highlighted markup "),
2209
+ _createElementVNode("pre", { innerHTML: $setup.sourcecode }, null, 8, _hoisted_15)
2210
+ ], 8, _hoisted_4)
2211
+ ],
2212
+ 64
2213
+ /* STABLE_FRAGMENT */
2214
+ );
2215
+ }
2216
+
2217
+ // src/LiveExampleSourcecode.vue
2218
+ LiveExampleSourcecode_default.render = render;
2219
+ LiveExampleSourcecode_default.__file = "src/LiveExampleSourcecode.vue";
2220
+ LiveExampleSourcecode_default.__scopeId = "data-v-7a98eb26";
2221
+ var LiveExampleSourcecode_default2 = LiveExampleSourcecode_default;
2222
+
2223
+ // src/live-vue-code.ts
2224
+ import { defineComponent, compile, h } from "vue";
2225
+ var live_vue_code_default = defineComponent({
2226
+ name: "LiveVueCode",
2227
+ props: {
2228
+ template: {
2229
+ type: String,
2230
+ required: true
2231
+ },
2232
+ components: {
2233
+ type: Object,
2234
+ required: true
2235
+ },
2236
+ livedata: {
2237
+ type: Object,
2238
+ required: true
2239
+ },
2240
+ livemethods: {
2241
+ type: Object,
2242
+ required: true
2243
+ }
2244
+ },
2245
+ render() {
2246
+ const renderFunction = compile(this.template);
2247
+ if (!renderFunction) {
2248
+ const message = "Failed to compile Vue render function!";
2249
+ return h("div", { style: "color: red" }, message);
2250
+ }
2251
+ return h(
2252
+ {
2253
+ name: "LiveComponent",
2254
+ data() {
2255
+ return { ...this.livedata };
2256
+ },
2257
+ props: {
2258
+ livedata: {
2259
+ type: Object,
2260
+ required: true
2261
+ },
2262
+ livemethods: {
2263
+ type: Object,
2264
+ required: true
2265
+ }
2266
+ },
2267
+ methods: { ...this.livemethods },
2268
+ components: this.components,
2269
+ render: renderFunction
2270
+ },
2271
+ { livedata: this.livedata, livemethods: this.livemethods }
2272
+ );
2273
+ }
2274
+ });
2275
+
2276
+ // sfc-script:/home/runner/work/docs-live-example/docs-live-example/src/LiveExample.vue?type=script
2277
+ var LiveExample_default = defineComponent2({
2278
+ name: "LiveExample",
2279
+ components: { LiveExampleSourcecode: LiveExampleSourcecode_default2, LiveVueCode: live_vue_code_default },
2280
+ props: {
2281
+ /**
2282
+ * Explicitly render example in given language.
2283
+ *
2284
+ * Must be one of:
2285
+ *
2286
+ * - `"vue"` - Interpret `template` as a Vue SFC.
2287
+ * - `"html"` - Interpret `template` as vanilla HTML.
2288
+ *
2289
+ * Default is `"auto"` but you should not explicitly set this value
2290
+ * yourself. When set to `"auto"` the contents of `template` prop will
2291
+ * be autodetected based on some heurestics (subject to change at any
2292
+ * time).
2293
+ */
2294
+ language: {
2295
+ type: String,
2296
+ required: false,
2297
+ default: "auto",
2298
+ validator(value) {
2299
+ return ["vue", "html", "auto"].includes(value);
2300
+ }
2301
+ },
2302
+ template: {
2303
+ type: String,
2304
+ required: true
2305
+ },
2306
+ components: {
2307
+ type: Object,
2308
+ required: false,
2309
+ default: () => {
2310
+ return {};
2311
+ }
2312
+ },
2313
+ livedata: {
2314
+ type: Object,
2315
+ required: false,
2316
+ default: () => {
2317
+ return {};
2318
+ }
2319
+ },
2320
+ livemethods: {
2321
+ type: Object,
2322
+ required: false,
2323
+ default: () => {
2324
+ return {};
2325
+ }
2326
+ }
2327
+ },
2328
+ data() {
2329
+ return {
2330
+ /** Language declared by parent element via `data-language`, if any */
2331
+ parentLanguage: "",
2332
+ exampleElement: void 0
2333
+ };
2334
+ },
2335
+ computed: {
2336
+ templateLanguage() {
2337
+ if (this.language !== "auto") {
2338
+ return this.language;
2339
+ }
2340
+ if (this.parentLanguage) {
2341
+ return this.parentLanguage;
2342
+ }
2343
+ const hasChildComponents = Object.keys(this.components).length > 0;
2344
+ return hasChildComponents ? "vue" : "html";
2345
+ }
2346
+ },
2347
+ mounted() {
2348
+ const parent = this.$el.closest("[data-language]");
2349
+ if (parent) {
2350
+ this.parentLanguage = parent.dataset.language ?? "";
2351
+ }
2352
+ this.exampleElement = this.$refs.example;
2353
+ }
2354
+ });
2355
+
2356
+ // sfc-template:/home/runner/work/docs-live-example/docs-live-example/src/LiveExample.vue?type=template
2357
+ import { resolveComponent as _resolveComponent, createVNode as _createVNode, openBlock as _openBlock2, createElementBlock as _createElementBlock2, createCommentVNode as _createCommentVNode2, createElementVNode as _createElementVNode2, Fragment as _Fragment2, renderSlot as _renderSlot } from "vue";
2358
+ var _hoisted_16 = { class: "live-example__container" };
2359
+ var _hoisted_22 = {
2360
+ ref: "example",
2361
+ class: "live-example__example"
2362
+ };
2363
+ var _hoisted_32 = { key: 0 };
2364
+ var _hoisted_42 = ["innerHTML"];
2365
+ var _hoisted_52 = { key: 2 };
2366
+ var _hoisted_62 = /* @__PURE__ */ _createElementVNode2(
2367
+ "pre",
2368
+ null,
2369
+ "Unknown language, cannot render example",
2370
+ -1
2371
+ /* HOISTED */
2372
+ );
2373
+ var _hoisted_72 = [
2374
+ _hoisted_62
2375
+ ];
2376
+ var _hoisted_82 = { class: "live-example__controls" };
2377
+ var _hoisted_92 = {
2378
+ key: 0,
2379
+ class: "live-example__code"
2380
+ };
2381
+ function render2(_ctx, _cache, $props, $setup, $data, $options) {
2382
+ const _component_live_vue_code = _resolveComponent("live-vue-code");
2383
+ const _component_live_example_sourcecode = _resolveComponent("live-example-sourcecode");
2384
+ return _openBlock2(), _createElementBlock2("div", _hoisted_16, [
2385
+ _createElementVNode2(
2386
+ "div",
2387
+ _hoisted_22,
2388
+ [
2389
+ _ctx.templateLanguage === "vue" ? (_openBlock2(), _createElementBlock2("div", _hoisted_32, [
2390
+ _createVNode(_component_live_vue_code, {
2391
+ components: _ctx.components,
2392
+ template: _ctx.template,
2393
+ livedata: _ctx.livedata,
2394
+ livemethods: _ctx.livemethods
2395
+ }, null, 8, ["components", "template", "livedata", "livemethods"])
2396
+ ])) : _ctx.templateLanguage === "html" ? (_openBlock2(), _createElementBlock2(
2397
+ _Fragment2,
2398
+ { key: 1 },
2399
+ [
2400
+ _createCommentVNode2(" eslint-disable-next-line vue/no-v-html -- expected to show rendered html "),
2401
+ _createElementVNode2("div", { innerHTML: _ctx.template }, null, 8, _hoisted_42)
2402
+ ],
2403
+ 2112
2404
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
2405
+ )) : (_openBlock2(), _createElementBlock2("div", _hoisted_52, [..._hoisted_72]))
2406
+ ],
2407
+ 512
2408
+ /* NEED_PATCH */
2409
+ ),
2410
+ _createElementVNode2("div", _hoisted_82, [
2411
+ _renderSlot(_ctx.$slots, "default")
2412
+ ]),
2413
+ _ctx.exampleElement ? (_openBlock2(), _createElementBlock2("div", _hoisted_92, [
2414
+ _createVNode(_component_live_example_sourcecode, {
2415
+ element: _ctx.exampleElement,
2416
+ template: _ctx.template,
2417
+ "template-language": _ctx.templateLanguage
2418
+ }, null, 8, ["element", "template", "template-language"])
2419
+ ])) : _createCommentVNode2("v-if", true)
2420
+ ]);
2421
+ }
2422
+
2423
+ // src/LiveExample.vue
2424
+ LiveExample_default.render = render2;
2425
+ LiveExample_default.__file = "src/LiveExample.vue";
2426
+ var LiveExample_default2 = LiveExample_default;
2427
+ export {
2428
+ LiveExample_default2 as LiveExample
2429
+ };