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