@powerduck/md-editor 0.9.5 → 0.10.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.
- package/dist/Editor.d.ts +2 -0
- package/dist/index.cjs +62 -14
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +1164 -1001
- package/dist/perf/IncrementalRenderer.d.ts +1 -0
- package/dist/plugins/mention.d.ts +8 -7
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ class Zt {
|
|
|
9
9
|
constructor(e, t = {}) {
|
|
10
10
|
this.dropdown = null, this.items = [], this.selectedIndex = 0, this.trigger = null, this.activeHead = 0, this.searchAbort = null, this.destroyed = !1, this.view = e, this.options = {
|
|
11
11
|
onMentionSearch: t.onMentionSearch ?? (() => []),
|
|
12
|
-
onMentionSelect: t.onMentionSelect ?? ((i) =>
|
|
12
|
+
onMentionSelect: t.onMentionSelect ?? ((i) => `[@${i.label}](mention:${i.id})`),
|
|
13
13
|
minChars: t.minChars ?? 0,
|
|
14
14
|
maxItems: t.maxItems ?? 8
|
|
15
15
|
};
|
|
@@ -47,17 +47,17 @@ class Zt {
|
|
|
47
47
|
return !1;
|
|
48
48
|
}
|
|
49
49
|
findTrigger() {
|
|
50
|
-
const { head: e } = this.view.state.selection.main, t = this.view.state.doc.lineAt(e), i = t.text,
|
|
51
|
-
for (let a =
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
50
|
+
const { head: e } = this.view.state.selection.main, t = this.view.state.doc.lineAt(e), i = t.text, r = e - t.from;
|
|
51
|
+
for (let a = r - 1; a >= 0; a--) {
|
|
52
|
+
const s = i[a];
|
|
53
|
+
if (s === "@") {
|
|
54
54
|
if (a === 0 || /\s|[^\w@]/.test(i[a - 1])) {
|
|
55
|
-
const o = i.slice(a + 1,
|
|
55
|
+
const o = i.slice(a + 1, r);
|
|
56
56
|
return /\s/.test(o) ? null : { from: t.from + a, query: o };
|
|
57
57
|
}
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
|
-
if (/\s/.test(
|
|
60
|
+
if (/\s/.test(s)) break;
|
|
61
61
|
}
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
@@ -72,9 +72,9 @@ class Zt {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
try {
|
|
75
|
-
const
|
|
75
|
+
const r = await this.options.onMentionSearch(e);
|
|
76
76
|
if (t || this.destroyed) return;
|
|
77
|
-
this.items =
|
|
77
|
+
this.items = r.slice(0, this.options.maxItems), this.selectedIndex = 0, this.items.length > 0 ? this.show() : this.hide();
|
|
78
78
|
} catch {
|
|
79
79
|
t || this.hide();
|
|
80
80
|
}
|
|
@@ -88,13 +88,13 @@ class Zt {
|
|
|
88
88
|
const a = i.target.closest(".md-editor-mention-item");
|
|
89
89
|
if (!a) return;
|
|
90
90
|
i.preventDefault(), i.stopPropagation();
|
|
91
|
-
const
|
|
92
|
-
Number.isNaN(
|
|
91
|
+
const s = Number(a.dataset.index);
|
|
92
|
+
Number.isNaN(s) || this.selectItem(s);
|
|
93
93
|
}), this.dropdown.addEventListener("mouseover", (i) => {
|
|
94
94
|
const a = i.target.closest(".md-editor-mention-item");
|
|
95
95
|
if (!a) return;
|
|
96
|
-
const
|
|
97
|
-
!Number.isNaN(
|
|
96
|
+
const s = Number(a.dataset.index);
|
|
97
|
+
!Number.isNaN(s) && s !== this.selectedIndex && (this.selectedIndex = s, this.updateActiveClass());
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
this.renderDropdown(), this.positionDropdown();
|
|
@@ -104,17 +104,17 @@ class Zt {
|
|
|
104
104
|
this.dropdown && (this.dropdown.innerHTML = "", this.items.forEach((e, t) => {
|
|
105
105
|
const i = document.createElement("div");
|
|
106
106
|
if (i.className = "md-editor-mention-item" + (t === this.selectedIndex ? " is-active" : ""), i.setAttribute("role", "option"), i.setAttribute("aria-selected", t === this.selectedIndex ? "true" : "false"), i.dataset.index = String(t), e.avatar) {
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const s = document.createElement("img");
|
|
108
|
+
s.className = "md-editor-mention-avatar", s.src = e.avatar, s.alt = "", i.appendChild(s);
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const r = document.createElement("div");
|
|
111
|
+
r.className = "md-editor-mention-text";
|
|
112
112
|
const a = document.createElement("div");
|
|
113
|
-
if (a.className = "md-editor-mention-label", a.textContent = e.label,
|
|
114
|
-
const
|
|
115
|
-
|
|
113
|
+
if (a.className = "md-editor-mention-label", a.textContent = e.label, r.appendChild(a), e.description) {
|
|
114
|
+
const s = document.createElement("div");
|
|
115
|
+
s.className = "md-editor-mention-desc", s.textContent = e.description, r.appendChild(s);
|
|
116
116
|
}
|
|
117
|
-
i.appendChild(
|
|
117
|
+
i.appendChild(r), this.dropdown.appendChild(i);
|
|
118
118
|
}));
|
|
119
119
|
}
|
|
120
120
|
/** Update the active-item CSS class without rebuilding the DOM. */
|
|
@@ -122,8 +122,8 @@ class Zt {
|
|
|
122
122
|
if (!this.dropdown) return;
|
|
123
123
|
const e = this.dropdown.children;
|
|
124
124
|
for (let t = 0; t < e.length; t++) {
|
|
125
|
-
const i = e[t],
|
|
126
|
-
i.classList.toggle("is-active",
|
|
125
|
+
const i = e[t], r = t === this.selectedIndex;
|
|
126
|
+
i.classList.toggle("is-active", r), i.setAttribute("aria-selected", r ? "true" : "false");
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
positionDropdown() {
|
|
@@ -135,20 +135,24 @@ class Zt {
|
|
|
135
135
|
e = null;
|
|
136
136
|
}
|
|
137
137
|
if (!e) {
|
|
138
|
-
const
|
|
139
|
-
e = { top:
|
|
138
|
+
const s = this.view.dom.getBoundingClientRect();
|
|
139
|
+
e = { top: s.top, bottom: s.top + 20, left: s.left };
|
|
140
140
|
}
|
|
141
141
|
const t = this.dropdown.getBoundingClientRect(), i = window.innerHeight;
|
|
142
|
-
let
|
|
143
|
-
|
|
142
|
+
let r = e.bottom + 4, a = e.left;
|
|
143
|
+
r + t.height > i - 8 && (r = e.top - t.height - 4), a = Math.max(8, Math.min(a, window.innerWidth - t.width - 8)), this.dropdown.style.top = `${r}px`, this.dropdown.style.left = `${a}px`;
|
|
144
144
|
}
|
|
145
145
|
selectItem(e) {
|
|
146
146
|
const t = this.items[e], i = this.trigger;
|
|
147
147
|
if (!t || !i) return;
|
|
148
|
-
const
|
|
148
|
+
const r = this.options.onMentionSelect(t);
|
|
149
|
+
this.options.onMentionSelect !== void 0 && !r.includes("](mention:") && r.startsWith("@") && console.warn(
|
|
150
|
+
"[md-editor] onMentionSelect returned plain '@" + t.label + "'. For badge rendering in the preview, return '[@" + t.label + "](mention:" + t.id + ")' instead, or omit onMentionSelect to use the default wrapper."
|
|
151
|
+
);
|
|
152
|
+
const a = i.from, s = this.activeHead;
|
|
149
153
|
this.view.focus(), this.view.dispatch({
|
|
150
|
-
changes: { from: a, to:
|
|
151
|
-
selection: { anchor: a +
|
|
154
|
+
changes: { from: a, to: s, insert: r },
|
|
155
|
+
selection: { anchor: a + r.length }
|
|
152
156
|
}), this.hide();
|
|
153
157
|
}
|
|
154
158
|
hide() {
|
|
@@ -159,47 +163,38 @@ class Zt {
|
|
|
159
163
|
this.destroyed = !0, this.hide();
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
function Vt(n) {
|
|
167
|
+
const e = n.renderer.rules.link_open ?? ((r, a, s, o, c) => c.renderToken(r, a, s)), t = n.renderer.rules.link_close ?? ((r, a, s, o, c) => c.renderToken(r, a, s));
|
|
168
|
+
let i = !1;
|
|
169
|
+
n.renderer.rules.link_open = (r, a, s, o, c) => {
|
|
170
|
+
const l = r[a], d = (l == null ? void 0 : l.attrGet("href")) ?? "";
|
|
171
|
+
if (typeof d == "string" && d.startsWith("mention:")) {
|
|
172
|
+
i = !0;
|
|
173
|
+
const h = d.slice(8);
|
|
174
|
+
return `<span class="md-editor-mention" data-mention-id="${Xt(h)}">`;
|
|
171
175
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (!t) {
|
|
175
|
-
const r = e.push("mention", "span", 0);
|
|
176
|
-
r.content = a[0], r.markup = a[1] ?? "";
|
|
177
|
-
}
|
|
178
|
-
return e.pos += a[0].length, !0;
|
|
179
|
-
}), n.renderer.rules.mention = (e, t) => {
|
|
180
|
-
const i = e[t];
|
|
181
|
-
return i ? `<span class="md-editor-mention">${Qt(i.content)}</span>` : "";
|
|
182
|
-
};
|
|
176
|
+
return i = !1, e(r, a, s, o, c);
|
|
177
|
+
}, n.renderer.rules.link_close = (r, a, s, o, c) => i ? (i = !1, "</span>") : t(r, a, s, o, c);
|
|
183
178
|
}
|
|
184
|
-
function
|
|
185
|
-
return n.replace(
|
|
179
|
+
function Xt(n) {
|
|
180
|
+
return n.replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
186
181
|
}
|
|
187
|
-
async function
|
|
182
|
+
async function Qt(n) {
|
|
188
183
|
const e = await fetch(n, { mode: "cors" });
|
|
189
184
|
if (!e.ok) throw new Error(`HTTP ${e.status}`);
|
|
190
185
|
const t = await e.text();
|
|
191
|
-
return
|
|
186
|
+
return Jt(t, n);
|
|
192
187
|
}
|
|
193
|
-
function
|
|
194
|
-
var c, l, d,
|
|
188
|
+
function Jt(n, e) {
|
|
189
|
+
var c, l, d, h, p, m, b;
|
|
195
190
|
const t = {}, i = new DOMParser().parseFromString(n, "text/html"), a = ((c = i.querySelector('meta[property="og:title"]')) == null ? void 0 : c.getAttribute("content")) ?? ((l = i.querySelector("title")) == null ? void 0 : l.textContent) ?? void 0;
|
|
196
191
|
a && (t.title = a.trim());
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
const o = ((p = i.querySelector('meta[property="og:image"]')) == null ? void 0 : p.getAttribute("content")) ?? ((m = i.querySelector('meta[property="og:image:secure_url"]')) == null ? void 0 : m.getAttribute("content")) ?? ((
|
|
192
|
+
const s = ((d = i.querySelector('meta[property="og:description"]')) == null ? void 0 : d.getAttribute("content")) ?? ((h = i.querySelector('meta[name="description"]')) == null ? void 0 : h.getAttribute("content"));
|
|
193
|
+
s && (t.description = s.trim());
|
|
194
|
+
const o = ((p = i.querySelector('meta[property="og:image"]')) == null ? void 0 : p.getAttribute("content")) ?? ((m = i.querySelector('meta[property="og:image:secure_url"]')) == null ? void 0 : m.getAttribute("content")) ?? ((b = i.querySelector('meta[name="twitter:image"]')) == null ? void 0 : b.getAttribute("content"));
|
|
200
195
|
return o && (t.thumbnail = o.startsWith("http") ? o : new URL(o, e).href), t;
|
|
201
196
|
}
|
|
202
|
-
class
|
|
197
|
+
class jt {
|
|
203
198
|
constructor(e, t = {}) {
|
|
204
199
|
this.dropdown = null, this.items = [], this.selectedIndex = 0, this.trigger = null, this.activeHead = 0, this.searchAbort = null, this.destroyed = !1, this.view = e, this.options = {
|
|
205
200
|
onDocSearch: t.onDocSearch ?? (() => []),
|
|
@@ -209,7 +204,7 @@ class en {
|
|
|
209
204
|
maxItems: t.maxItems ?? 8,
|
|
210
205
|
// Use the built-in fetch+DOMParser fetcher unless the consumer provides
|
|
211
206
|
// their own (e.g. a backend proxy to avoid CORS).
|
|
212
|
-
onFetchDocMeta: t.onFetchDocMeta ??
|
|
207
|
+
onFetchDocMeta: t.onFetchDocMeta ?? Qt
|
|
213
208
|
};
|
|
214
209
|
}
|
|
215
210
|
/** Called on every CodeMirror update. */
|
|
@@ -239,13 +234,13 @@ class en {
|
|
|
239
234
|
return !1;
|
|
240
235
|
}
|
|
241
236
|
findTrigger() {
|
|
242
|
-
const { head: e } = this.view.state.selection.main, t = this.view.state.doc.lineAt(e), i = t.text,
|
|
243
|
-
for (let
|
|
244
|
-
const o = i[
|
|
237
|
+
const { head: e } = this.view.state.selection.main, t = this.view.state.doc.lineAt(e), i = t.text, r = e - t.from, a = this.options.triggerChar;
|
|
238
|
+
for (let s = r - 1; s >= 0; s--) {
|
|
239
|
+
const o = i[s];
|
|
245
240
|
if (o === a) {
|
|
246
|
-
if (
|
|
247
|
-
const c = i.slice(
|
|
248
|
-
return /\s/.test(c) ? null : { from: t.from +
|
|
241
|
+
if (s === 0 || /\s/.test(i[s - 1])) {
|
|
242
|
+
const c = i.slice(s + 1, r);
|
|
243
|
+
return /\s/.test(c) ? null : { from: t.from + s, query: c };
|
|
249
244
|
}
|
|
250
245
|
return null;
|
|
251
246
|
}
|
|
@@ -264,9 +259,9 @@ class en {
|
|
|
264
259
|
return;
|
|
265
260
|
}
|
|
266
261
|
try {
|
|
267
|
-
const
|
|
262
|
+
const r = await this.options.onDocSearch(e);
|
|
268
263
|
if (t || this.destroyed) return;
|
|
269
|
-
this.items =
|
|
264
|
+
this.items = r.slice(0, this.options.maxItems), this.selectedIndex = 0, this.items.length > 0 ? this.show() : this.hide();
|
|
270
265
|
} catch {
|
|
271
266
|
t || this.hide();
|
|
272
267
|
}
|
|
@@ -280,13 +275,13 @@ class en {
|
|
|
280
275
|
const a = i.target.closest(".md-editor-doclink-item");
|
|
281
276
|
if (!a) return;
|
|
282
277
|
i.preventDefault(), i.stopPropagation();
|
|
283
|
-
const
|
|
284
|
-
Number.isNaN(
|
|
278
|
+
const s = Number(a.dataset.index);
|
|
279
|
+
Number.isNaN(s) || this.selectItem(s);
|
|
285
280
|
}), this.dropdown.addEventListener("mouseover", (i) => {
|
|
286
281
|
const a = i.target.closest(".md-editor-doclink-item");
|
|
287
282
|
if (!a) return;
|
|
288
|
-
const
|
|
289
|
-
!Number.isNaN(
|
|
283
|
+
const s = Number(a.dataset.index);
|
|
284
|
+
!Number.isNaN(s) && s !== this.selectedIndex && (this.selectedIndex = s, this.updateActiveClass());
|
|
290
285
|
});
|
|
291
286
|
}
|
|
292
287
|
this.renderDropdown(), this.positionDropdown();
|
|
@@ -299,21 +294,21 @@ class en {
|
|
|
299
294
|
const o = document.createElement("img");
|
|
300
295
|
o.className = "md-editor-doclink-thumb-img", o.src = e.thumbnail, o.alt = "", i.appendChild(o);
|
|
301
296
|
}
|
|
302
|
-
const
|
|
303
|
-
|
|
297
|
+
const r = document.createElement("div");
|
|
298
|
+
r.className = "md-editor-doclink-text";
|
|
304
299
|
const a = document.createElement("div");
|
|
305
|
-
if (a.className = "md-editor-doclink-label", a.textContent = e.title,
|
|
300
|
+
if (a.className = "md-editor-doclink-label", a.textContent = e.title, r.appendChild(a), e.description) {
|
|
306
301
|
const o = document.createElement("div");
|
|
307
|
-
o.className = "md-editor-doclink-desc", o.textContent = e.description,
|
|
302
|
+
o.className = "md-editor-doclink-desc", o.textContent = e.description, r.appendChild(o);
|
|
308
303
|
}
|
|
309
|
-
const
|
|
310
|
-
|
|
304
|
+
const s = document.createElement("div");
|
|
305
|
+
s.className = "md-editor-doclink-url";
|
|
311
306
|
try {
|
|
312
|
-
|
|
307
|
+
s.textContent = new URL(e.url).hostname;
|
|
313
308
|
} catch {
|
|
314
|
-
|
|
309
|
+
s.textContent = e.url;
|
|
315
310
|
}
|
|
316
|
-
|
|
311
|
+
r.appendChild(s), i.appendChild(r), this.dropdown.appendChild(i);
|
|
317
312
|
}));
|
|
318
313
|
}
|
|
319
314
|
/** Update the active-item CSS class without rebuilding the DOM. */
|
|
@@ -321,8 +316,8 @@ class en {
|
|
|
321
316
|
if (!this.dropdown) return;
|
|
322
317
|
const e = this.dropdown.children;
|
|
323
318
|
for (let t = 0; t < e.length; t++) {
|
|
324
|
-
const i = e[t],
|
|
325
|
-
i.classList.toggle("is-active",
|
|
319
|
+
const i = e[t], r = t === this.selectedIndex;
|
|
320
|
+
i.classList.toggle("is-active", r), i.setAttribute("aria-selected", r ? "true" : "false");
|
|
326
321
|
}
|
|
327
322
|
}
|
|
328
323
|
positionDropdown() {
|
|
@@ -334,24 +329,24 @@ class en {
|
|
|
334
329
|
e = null;
|
|
335
330
|
}
|
|
336
331
|
if (!e) {
|
|
337
|
-
const
|
|
338
|
-
e = { top:
|
|
332
|
+
const s = this.view.dom.getBoundingClientRect();
|
|
333
|
+
e = { top: s.top, bottom: s.top + 20, left: s.left };
|
|
339
334
|
}
|
|
340
335
|
const t = this.dropdown.getBoundingClientRect(), i = window.innerHeight;
|
|
341
|
-
let
|
|
342
|
-
|
|
336
|
+
let r = e.bottom + 4, a = e.left;
|
|
337
|
+
r + t.height > i - 8 && (r = e.top - t.height - 4), a = Math.max(8, Math.min(a, window.innerWidth - t.width - 8)), this.dropdown.style.top = `${r}px`, this.dropdown.style.left = `${a}px`;
|
|
343
338
|
}
|
|
344
339
|
async selectItem(e) {
|
|
345
340
|
const t = this.items[e], i = this.trigger;
|
|
346
341
|
if (!t || !i) return;
|
|
347
|
-
const
|
|
342
|
+
const r = i.from, a = this.activeHead;
|
|
348
343
|
this.view.focus(), this.view.dispatch({
|
|
349
|
-
changes: { from:
|
|
344
|
+
changes: { from: r, to: a, insert: "" }
|
|
350
345
|
});
|
|
351
|
-
const
|
|
346
|
+
const s = await this.buildInsertion(t);
|
|
352
347
|
this.view.dispatch({
|
|
353
|
-
changes: { from:
|
|
354
|
-
selection: { anchor:
|
|
348
|
+
changes: { from: r, insert: s },
|
|
349
|
+
selection: { anchor: r + s.length }
|
|
355
350
|
}), this.hide();
|
|
356
351
|
}
|
|
357
352
|
/**
|
|
@@ -382,9 +377,9 @@ class en {
|
|
|
382
377
|
return `[${e.title}](${e.url})`;
|
|
383
378
|
if (t === "card" && !a)
|
|
384
379
|
return `[${e.title}](${e.url})`;
|
|
385
|
-
const
|
|
386
|
-
return
|
|
387
|
-
` +
|
|
380
|
+
const s = [`:::doc-link ${e.url}`];
|
|
381
|
+
return s.push(`# ${i.title ?? e.title}`), i.thumbnail && s.push(``), i.description && s.push(i.description), s.push(":::"), `
|
|
382
|
+
` + s.join(`
|
|
388
383
|
`) + `
|
|
389
384
|
`;
|
|
390
385
|
}
|
|
@@ -396,66 +391,66 @@ class en {
|
|
|
396
391
|
this.destroyed = !0, this.hide();
|
|
397
392
|
}
|
|
398
393
|
}
|
|
399
|
-
const
|
|
400
|
-
function
|
|
401
|
-
n.block.ruler.before("fence", "doclink_block", (e, t, i,
|
|
402
|
-
const
|
|
403
|
-
if (!
|
|
404
|
-
const o =
|
|
394
|
+
const en = /^:::doc-link\s+(\S+)(?:\s+(.+))?$/, tn = /^:::\s*$/;
|
|
395
|
+
function nn(n) {
|
|
396
|
+
n.block.ruler.before("fence", "doclink_block", (e, t, i, r) => {
|
|
397
|
+
const s = e.src.slice(e.bMarks[t], e.eMarks[t]).match(en);
|
|
398
|
+
if (!s) return !1;
|
|
399
|
+
const o = s[1] ?? "";
|
|
405
400
|
let c = t + 1, l = !1;
|
|
406
401
|
for (; c < i; ) {
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
402
|
+
const E = e.src.slice(e.bMarks[c], e.eMarks[c]);
|
|
403
|
+
if (tn.test(E.trim())) {
|
|
409
404
|
l = !0;
|
|
410
405
|
break;
|
|
411
406
|
}
|
|
412
407
|
c++;
|
|
413
408
|
}
|
|
414
409
|
if (!l) return !1;
|
|
415
|
-
if (
|
|
410
|
+
if (r) return !0;
|
|
416
411
|
const d = e.src.slice(e.bMarks[t + 1], e.bMarks[c]).split(`
|
|
417
|
-
`).map((
|
|
418
|
-
let
|
|
412
|
+
`).map((E) => E.trim()).filter((E) => E.length > 0);
|
|
413
|
+
let h = "", p = "";
|
|
419
414
|
const m = [];
|
|
420
|
-
for (const
|
|
421
|
-
if (
|
|
422
|
-
|
|
423
|
-
else if (
|
|
424
|
-
const
|
|
425
|
-
|
|
415
|
+
for (const E of d)
|
|
416
|
+
if (E.startsWith("# "))
|
|
417
|
+
h = E.slice(2).trim();
|
|
418
|
+
else if (E.startsWith(") {
|
|
419
|
+
const N = E.match(/^!\[thumbnail\]\((.+)\)$/);
|
|
420
|
+
N && (p = N[1] ?? "");
|
|
426
421
|
} else
|
|
427
|
-
m.push(
|
|
428
|
-
const
|
|
429
|
-
return
|
|
422
|
+
m.push(E);
|
|
423
|
+
const b = e.push("doclink_block", "div", 0);
|
|
424
|
+
return b.content = JSON.stringify({ url: o, title: h, thumbnail: p, description: m.join(" ") }), e.line = c + 1, !0;
|
|
430
425
|
}), n.renderer.rules.doclink_block = (e, t) => {
|
|
431
426
|
const i = e[t];
|
|
432
427
|
if (!i) return "";
|
|
433
|
-
let
|
|
428
|
+
let r;
|
|
434
429
|
try {
|
|
435
|
-
|
|
430
|
+
r = JSON.parse(i.content);
|
|
436
431
|
} catch {
|
|
437
432
|
return "";
|
|
438
433
|
}
|
|
439
|
-
const { url: a, title:
|
|
434
|
+
const { url: a, title: s, thumbnail: o, description: c } = r;
|
|
440
435
|
let l = a;
|
|
441
436
|
try {
|
|
442
437
|
l = new URL(a).hostname;
|
|
443
438
|
} catch {
|
|
444
439
|
}
|
|
445
440
|
const d = o ? `<div class="md-editor-doclink-card-thumb"><img src="${Fe(o)}" alt="" loading="lazy" /></div>` : "";
|
|
446
|
-
return `<a class="md-editor-doclink-card" href="${Fe(a)}" target="_blank" rel="noopener noreferrer">` + d + `<div class="md-editor-doclink-card-body"><div class="md-editor-doclink-card-title">${
|
|
441
|
+
return `<a class="md-editor-doclink-card" href="${Fe(a)}" target="_blank" rel="noopener noreferrer">` + d + `<div class="md-editor-doclink-card-body"><div class="md-editor-doclink-card-title">${Te(s)}</div>` + (c ? `<div class="md-editor-doclink-card-desc">${Te(c)}</div>` : "") + `<div class="md-editor-doclink-card-url">${Te(l)}</div></div></a>`;
|
|
447
442
|
};
|
|
448
443
|
}
|
|
449
|
-
function
|
|
444
|
+
function Te(n) {
|
|
450
445
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
451
446
|
}
|
|
452
447
|
function Fe(n) {
|
|
453
448
|
return n.replace(/"/g, """).replace(/</g, "<");
|
|
454
449
|
}
|
|
455
|
-
class
|
|
450
|
+
class rn {
|
|
456
451
|
constructor(e, t) {
|
|
457
|
-
var
|
|
458
|
-
this.lineNumbersCompartment = new Be(), this.customKeymapCompartment = new Be(), this.mention = null, this.docLink = null, this.onImageFile = t.onImageFile;
|
|
452
|
+
var r, a;
|
|
453
|
+
this.lineNumbersCompartment = new Be(), this.customKeymapCompartment = new Be(), this.mention = null, this.docLink = null, this.blurTimeout = null, this.destroyed = !1, this.onImageFile = t.onImageFile;
|
|
459
454
|
const i = [
|
|
460
455
|
zt(),
|
|
461
456
|
$e.of([...Kt, ...Gt]),
|
|
@@ -463,50 +458,50 @@ class sn {
|
|
|
463
458
|
qt({ codeLanguages: Wt }),
|
|
464
459
|
ge.lineWrapping,
|
|
465
460
|
this.lineNumbersCompartment.of(t.lineNumbers ? Ue() : []),
|
|
466
|
-
ge.updateListener.of((
|
|
461
|
+
ge.updateListener.of((s) => {
|
|
467
462
|
var o, c, l;
|
|
468
|
-
|
|
463
|
+
s.docChanged && ((o = t.onChange) == null || o.call(t, s.state.doc.toString())), (s.docChanged || s.selectionSet) && ((c = this.mention) == null || c.update(), (l = this.docLink) == null || l.update());
|
|
469
464
|
}),
|
|
470
465
|
// Close dropdowns when the editor loses focus
|
|
471
466
|
ge.domEventHandlers({
|
|
472
|
-
paste: (
|
|
473
|
-
drop: (
|
|
467
|
+
paste: (s) => this.handlePaste(s),
|
|
468
|
+
drop: (s) => this.handleDrop(s),
|
|
474
469
|
blur: () => {
|
|
475
|
-
window.setTimeout(() => {
|
|
476
|
-
var
|
|
477
|
-
this.view.dom.contains(document.activeElement) || ((
|
|
470
|
+
this.blurTimeout = window.setTimeout(() => {
|
|
471
|
+
var s, o;
|
|
472
|
+
this.blurTimeout = null, !this.destroyed && (this.view.dom.contains(document.activeElement) || ((s = this.mention) == null || s.hide(), (o = this.docLink) == null || o.hide()));
|
|
478
473
|
}, 150);
|
|
479
474
|
},
|
|
480
|
-
keydown: (
|
|
475
|
+
keydown: (s) => {
|
|
481
476
|
var o, c;
|
|
482
|
-
return !!((o = this.mention) != null && o.handleKey(
|
|
477
|
+
return !!((o = this.mention) != null && o.handleKey(s) || (c = this.docLink) != null && c.handleKey(s));
|
|
483
478
|
}
|
|
484
479
|
})
|
|
485
480
|
];
|
|
486
481
|
this.view = new ge({
|
|
487
482
|
state: Ft.create({ doc: t.value ?? "", extensions: i }),
|
|
488
483
|
parent: e
|
|
489
|
-
}), (
|
|
484
|
+
}), (r = t.mention) != null && r.onMentionSearch && (this.mention = new Zt(this.view, t.mention)), (a = t.docLink) != null && a.onDocSearch && (this.docLink = new jt(this.view, t.docLink));
|
|
490
485
|
}
|
|
491
486
|
handlePaste(e) {
|
|
492
|
-
var i,
|
|
487
|
+
var i, r;
|
|
493
488
|
const t = (i = e.clipboardData) == null ? void 0 : i.items;
|
|
494
489
|
if (!t) return !1;
|
|
495
490
|
for (const a of Array.from(t))
|
|
496
491
|
if (a.type.startsWith("image/")) {
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
499
|
-
return (
|
|
492
|
+
const s = a.getAsFile();
|
|
493
|
+
if (s)
|
|
494
|
+
return (r = this.onImageFile) == null || r.call(this, s), e.preventDefault(), !0;
|
|
500
495
|
}
|
|
501
496
|
return !1;
|
|
502
497
|
}
|
|
503
498
|
handleDrop(e) {
|
|
504
|
-
var i,
|
|
499
|
+
var i, r;
|
|
505
500
|
const t = (i = e.dataTransfer) == null ? void 0 : i.files;
|
|
506
501
|
if (!t || t.length === 0) return !1;
|
|
507
502
|
for (const a of Array.from(t))
|
|
508
503
|
if (a.type.startsWith("image/"))
|
|
509
|
-
return (
|
|
504
|
+
return (r = this.onImageFile) == null || r.call(this, a), e.preventDefault(), !0;
|
|
510
505
|
return !1;
|
|
511
506
|
}
|
|
512
507
|
/**
|
|
@@ -543,12 +538,12 @@ class sn {
|
|
|
543
538
|
* selected, insert prefix + placeholder + suffix and select the placeholder.
|
|
544
539
|
*/
|
|
545
540
|
wrapSelection(e, t, i) {
|
|
546
|
-
const { from:
|
|
541
|
+
const { from: r, to: a } = this.view.state.selection.main, o = this.view.state.doc.sliceString(r, a) || i, c = `${e}${o}${t}`;
|
|
547
542
|
this.view.dispatch({
|
|
548
|
-
changes: { from:
|
|
543
|
+
changes: { from: r, to: a, insert: c },
|
|
549
544
|
selection: {
|
|
550
|
-
anchor:
|
|
551
|
-
head:
|
|
545
|
+
anchor: r + e.length,
|
|
546
|
+
head: r + e.length + o.length
|
|
552
547
|
}
|
|
553
548
|
}), this.view.focus();
|
|
554
549
|
}
|
|
@@ -562,21 +557,21 @@ class sn {
|
|
|
562
557
|
* ordered list, etc. If nothing is selected, inserts prefix + placeholder.
|
|
563
558
|
*/
|
|
564
559
|
wrapLines(e, t) {
|
|
565
|
-
const { from: i, to:
|
|
566
|
-
let a = this.view.state.doc.sliceString(i,
|
|
560
|
+
const { from: i, to: r } = this.view.state.selection.main;
|
|
561
|
+
let a = this.view.state.doc.sliceString(i, r);
|
|
567
562
|
if (a) {
|
|
568
563
|
const o = a.split(`
|
|
569
564
|
`).map((c) => `${e}${c}`).join(`
|
|
570
565
|
`);
|
|
571
566
|
this.view.dispatch({
|
|
572
|
-
changes: { from: i, to:
|
|
567
|
+
changes: { from: i, to: r, insert: o },
|
|
573
568
|
selection: { anchor: i, head: i + o.length }
|
|
574
569
|
});
|
|
575
570
|
} else {
|
|
576
|
-
const
|
|
577
|
-
a =
|
|
578
|
-
const o =
|
|
579
|
-
`) : [t]).map((
|
|
571
|
+
const s = this.view.state.doc.lineAt(i);
|
|
572
|
+
a = s.text;
|
|
573
|
+
const o = s.from, c = s.to, d = (a ? a.split(`
|
|
574
|
+
`) : [t]).map((h) => `${e}${h}`).join(`
|
|
580
575
|
`);
|
|
581
576
|
this.view.dispatch({
|
|
582
577
|
changes: { from: o, to: c, insert: d },
|
|
@@ -607,34 +602,34 @@ class sn {
|
|
|
607
602
|
* otherwise → check all. Plain lines or `- ` lists get `- [ ] ` prepended.
|
|
608
603
|
*/
|
|
609
604
|
toggleTaskList() {
|
|
610
|
-
const { from: e, to: t } = this.view.state.selection.main, i = this.view.state.doc.lineAt(e),
|
|
611
|
-
for (let p = i.number; p <=
|
|
605
|
+
const { from: e, to: t } = this.view.state.selection.main, i = this.view.state.doc.lineAt(e), r = this.view.state.doc.lineAt(t), a = [];
|
|
606
|
+
for (let p = i.number; p <= r.number; p++)
|
|
612
607
|
a.push(this.view.state.doc.line(p).text);
|
|
613
|
-
const
|
|
608
|
+
const s = /^- \[\s*(?:[xX])?\s*\](\s|$)/, o = /^- \[\s*\](\s|$)/, c = a.every((p) => s.test(p)), l = a.every((p) => o.test(p)), h = a.map((p) => c ? l ? p.replace(/^- \[\s*\](\s?)/, "- [x]$1") : p.replace(/^- \[\s*[xX]\s*\](\s?)/, "- [ ]$1") : /^-(\s|$)/.test(p) ? p.replace(/^-(\s?)/, "- [ ]$1") : `- [ ] ${p}`).join(`
|
|
614
609
|
`);
|
|
615
610
|
this.view.dispatch({
|
|
616
|
-
changes: { from: i.from, to:
|
|
617
|
-
selection: { anchor: i.from, head: i.from +
|
|
611
|
+
changes: { from: i.from, to: r.to, insert: h },
|
|
612
|
+
selection: { anchor: i.from, head: i.from + h.length }
|
|
618
613
|
}), this.view.focus();
|
|
619
614
|
}
|
|
620
615
|
destroy() {
|
|
621
616
|
var e, t;
|
|
622
|
-
(e = this.mention) == null || e.destroy(), (t = this.docLink) == null || t.destroy(), this.view.destroy();
|
|
617
|
+
this.destroyed = !0, this.blurTimeout !== null && (window.clearTimeout(this.blurTimeout), this.blurTimeout = null), (e = this.mention) == null || e.destroy(), (t = this.docLink) == null || t.destroy(), this.view.destroy();
|
|
623
618
|
}
|
|
624
619
|
}
|
|
625
|
-
const
|
|
626
|
-
function
|
|
620
|
+
const sn = /^\$([^$\n]+?)\$/;
|
|
621
|
+
function on(n) {
|
|
627
622
|
return /^[\d.,]+$/.test(n.trim());
|
|
628
623
|
}
|
|
629
|
-
function
|
|
630
|
-
n.block.ruler.before("fence", "math_block", (e, t, i,
|
|
624
|
+
function an(n) {
|
|
625
|
+
n.block.ruler.before("fence", "math_block", (e, t, i, r) => {
|
|
631
626
|
const a = e.src.slice(e.bMarks[t], e.eMarks[t]);
|
|
632
627
|
if (!a.startsWith("$$")) return !1;
|
|
633
|
-
const
|
|
634
|
-
if (
|
|
635
|
-
if (
|
|
636
|
-
const
|
|
637
|
-
return
|
|
628
|
+
const s = a.match(/^\$\$(.+?)\$\$\s*$/);
|
|
629
|
+
if (s) {
|
|
630
|
+
if (r) return !0;
|
|
631
|
+
const h = e.push("math_block", "div", 0);
|
|
632
|
+
return h.content = s[1].trim(), h.markup = "$$", e.line = t + 1, !0;
|
|
638
633
|
}
|
|
639
634
|
let o = t + 1, c = !1;
|
|
640
635
|
for (; o < e.lineMax; ) {
|
|
@@ -645,12 +640,12 @@ function cn(n) {
|
|
|
645
640
|
o++;
|
|
646
641
|
}
|
|
647
642
|
if (!c) return !1;
|
|
648
|
-
if (
|
|
643
|
+
if (r) return !0;
|
|
649
644
|
const l = e.src.slice(e.bMarks[t] + 2, e.eMarks[o] - 2).trim(), d = e.push("math_block", "div", 0);
|
|
650
645
|
return d.content = l, d.markup = "$$", e.line = o + 1, !0;
|
|
651
646
|
}), n.renderer.rules.math_block = (e, t) => {
|
|
652
|
-
var
|
|
653
|
-
const i = ((
|
|
647
|
+
var r;
|
|
648
|
+
const i = ((r = e[t]) == null ? void 0 : r.content) ?? "";
|
|
654
649
|
try {
|
|
655
650
|
return `<div class="md-editor-math-block">${He.renderToString(i, {
|
|
656
651
|
displayMode: !0,
|
|
@@ -662,16 +657,16 @@ function cn(n) {
|
|
|
662
657
|
}
|
|
663
658
|
}, n.inline.ruler.after("escape", "math_inline", (e, t) => {
|
|
664
659
|
if (e.src[e.pos] !== "$" || e.src[e.pos + 1] === "$") return !1;
|
|
665
|
-
const i = e.src.slice(e.pos).match(
|
|
660
|
+
const i = e.src.slice(e.pos).match(sn);
|
|
666
661
|
if (!i) return !1;
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
662
|
+
const r = i[1] ?? "";
|
|
663
|
+
if (on(r)) return !1;
|
|
669
664
|
if (t) return !0;
|
|
670
665
|
const a = e.push("math_inline", "span", 0);
|
|
671
|
-
return a.content =
|
|
666
|
+
return a.content = r, a.markup = "$", e.pos += i[0].length, !0;
|
|
672
667
|
}), n.renderer.rules.math_inline = (e, t) => {
|
|
673
|
-
var
|
|
674
|
-
const i = ((
|
|
668
|
+
var r;
|
|
669
|
+
const i = ((r = e[t]) == null ? void 0 : r.content) ?? "";
|
|
675
670
|
try {
|
|
676
671
|
return He.renderToString(i, {
|
|
677
672
|
displayMode: !1,
|
|
@@ -695,89 +690,100 @@ typeof globalThis.ResizeObserver > "u" && (globalThis.ResizeObserver = class {
|
|
|
695
690
|
}
|
|
696
691
|
});
|
|
697
692
|
let Ke = 0;
|
|
698
|
-
function
|
|
693
|
+
function cn(n) {
|
|
699
694
|
n.block.ruler.before(
|
|
700
695
|
"fence",
|
|
701
696
|
"mindmap_fence",
|
|
702
|
-
(t, i,
|
|
703
|
-
const
|
|
697
|
+
(t, i, r, a) => {
|
|
698
|
+
const s = t.bMarks[i] + t.tShift[i], o = t.eMarks[i], l = t.src.slice(s, o).match(/^(`{3,})\s*mindmap\s*$/i);
|
|
704
699
|
if (!l) return !1;
|
|
705
700
|
if (a) return !0;
|
|
706
701
|
const d = l[1].length;
|
|
707
|
-
let
|
|
708
|
-
for (;
|
|
709
|
-
const
|
|
702
|
+
let h = i + 1, p = 1;
|
|
703
|
+
for (; h < r; ) {
|
|
704
|
+
const E = t.bMarks[h] + t.tShift[h], N = t.eMarks[h], O = t.src.slice(E, N).match(/^(`{3,})\s*(.*)$/);
|
|
710
705
|
if (O && O[1].length >= d) {
|
|
711
706
|
if (O[2].trim())
|
|
712
707
|
p++;
|
|
713
708
|
else if (p--, p === 0) break;
|
|
714
709
|
}
|
|
715
|
-
|
|
710
|
+
h++;
|
|
716
711
|
}
|
|
717
|
-
const m =
|
|
718
|
-
return
|
|
712
|
+
const m = h < r ? h : r - 1, b = t.push("mindmap_block", "div", 0);
|
|
713
|
+
return b.content = t.getLines(
|
|
719
714
|
i + 1,
|
|
720
715
|
m,
|
|
721
716
|
t.blkIndent,
|
|
722
717
|
!0
|
|
723
|
-
),
|
|
718
|
+
), b.map = [i, m + 1], b.markup = l[1], b.info = "mindmap", t.line = m + 1, !0;
|
|
724
719
|
}
|
|
725
720
|
), n.renderer.rules.mindmap_block = (t, i) => {
|
|
726
|
-
const
|
|
727
|
-
if (!
|
|
728
|
-
const a = `md-editor-mindmap-${++Ke}`,
|
|
729
|
-
return `<div class="md-editor-mindmap" id="${a}" data-source="${
|
|
721
|
+
const r = t[i];
|
|
722
|
+
if (!r) return "";
|
|
723
|
+
const a = `md-editor-mindmap-${++Ke}`, s = encodeURIComponent(r.content);
|
|
724
|
+
return `<div class="md-editor-mindmap" id="${a}" data-source="${s}"></div>`;
|
|
730
725
|
};
|
|
731
|
-
const e = n.renderer.rules.fence ? n.renderer.rules.fence.bind(n.renderer.rules) : (t, i,
|
|
732
|
-
n.renderer.rules.fence = (t, i,
|
|
726
|
+
const e = n.renderer.rules.fence ? n.renderer.rules.fence.bind(n.renderer.rules) : (t, i, r, a, s) => s.renderToken(t, i, r);
|
|
727
|
+
n.renderer.rules.fence = (t, i, r, a, s) => {
|
|
733
728
|
const o = t[i];
|
|
734
|
-
if (!o) return e(t, i,
|
|
729
|
+
if (!o) return e(t, i, r, a, s);
|
|
735
730
|
if (o.info.trim().toLowerCase() === "mindmap") {
|
|
736
731
|
const l = `md-editor-mindmap-${++Ke}`, d = encodeURIComponent(o.content);
|
|
737
732
|
return `<div class="md-editor-mindmap" id="${l}" data-source="${d}"></div>`;
|
|
738
733
|
}
|
|
739
|
-
return e(t, i,
|
|
734
|
+
return e(t, i, r, a, s);
|
|
740
735
|
};
|
|
741
736
|
}
|
|
742
|
-
const
|
|
743
|
-
async function
|
|
737
|
+
const ln = 600, dn = 320;
|
|
738
|
+
async function un(n) {
|
|
744
739
|
const e = n.querySelectorAll(
|
|
745
740
|
".md-editor-mindmap:not([data-hydrated])"
|
|
746
741
|
);
|
|
747
742
|
if (e.length === 0) return;
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
743
|
+
let t, i;
|
|
744
|
+
try {
|
|
745
|
+
t = (await import("markmap-lib")).Transformer;
|
|
746
|
+
const s = await import("markmap-view");
|
|
747
|
+
i = s.Markmap ?? s.default;
|
|
748
|
+
} catch {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (!i || !t) return;
|
|
752
|
+
const r = new t();
|
|
753
|
+
for (const a of Array.from(e))
|
|
754
|
+
try {
|
|
755
|
+
a.setAttribute("data-hydrated", "1");
|
|
756
|
+
const s = decodeURIComponent(a.dataset.source ?? "") || "- Empty mindmap", { root: o } = r.transform(s);
|
|
757
|
+
a.innerHTML = "";
|
|
758
|
+
const c = a.clientWidth > 0 ? a.clientWidth : ln, l = a.clientHeight > 0 ? a.clientHeight : dn, d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
759
|
+
d.setAttribute("width", String(c)), d.setAttribute("height", String(l)), d.style.width = "100%", d.style.height = "100%", d.style.display = "block", a.appendChild(d);
|
|
760
|
+
const h = i.create(d, { autoFit: !1 }, o), p = () => {
|
|
761
|
+
try {
|
|
762
|
+
const b = d.querySelector("g");
|
|
763
|
+
if (b) {
|
|
764
|
+
const E = b.getAttribute("transform") || "";
|
|
765
|
+
(!E || E.includes("NaN")) && b.setAttribute(
|
|
766
|
+
"transform",
|
|
767
|
+
`translate(40, ${l / 2}) scale(1)`
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
} catch {
|
|
766
771
|
}
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
|
|
772
|
+
};
|
|
773
|
+
p(), (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (b) => setTimeout(b, 16))(() => {
|
|
774
|
+
var b;
|
|
775
|
+
try {
|
|
776
|
+
if (!a.isConnected) return;
|
|
777
|
+
const E = d.getBoundingClientRect();
|
|
778
|
+
E.width > 0 && E.height > 0 && ((b = h.fit) == null || b.call(h), p());
|
|
779
|
+
} catch {
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
} catch {
|
|
783
|
+
a.removeAttribute("data-hydrated");
|
|
784
|
+
}
|
|
779
785
|
}
|
|
780
|
-
function
|
|
786
|
+
function hn(n) {
|
|
781
787
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
782
788
|
}
|
|
783
789
|
function it(n) {
|
|
@@ -804,29 +810,29 @@ class Ge {
|
|
|
804
810
|
function rt(n) {
|
|
805
811
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
806
812
|
}
|
|
807
|
-
function
|
|
813
|
+
function J(n, ...e) {
|
|
808
814
|
const t = /* @__PURE__ */ Object.create(null);
|
|
809
815
|
for (const i in n)
|
|
810
816
|
t[i] = n[i];
|
|
811
817
|
return e.forEach(function(i) {
|
|
812
|
-
for (const
|
|
813
|
-
t[
|
|
818
|
+
for (const r in i)
|
|
819
|
+
t[r] = i[r];
|
|
814
820
|
}), /** @type {T} */
|
|
815
821
|
t;
|
|
816
822
|
}
|
|
817
|
-
const
|
|
823
|
+
const pn = "</span>", qe = (n) => !!n.scope, gn = (n, { prefix: e }) => {
|
|
818
824
|
if (n.startsWith("language:"))
|
|
819
825
|
return n.replace("language:", "language-");
|
|
820
826
|
if (n.includes(".")) {
|
|
821
827
|
const t = n.split(".");
|
|
822
828
|
return [
|
|
823
829
|
`${e}${t.shift()}`,
|
|
824
|
-
...t.map((i,
|
|
830
|
+
...t.map((i, r) => `${i}${"_".repeat(r + 1)}`)
|
|
825
831
|
].join(" ");
|
|
826
832
|
}
|
|
827
833
|
return `${e}${n}`;
|
|
828
834
|
};
|
|
829
|
-
class
|
|
835
|
+
class mn {
|
|
830
836
|
/**
|
|
831
837
|
* Creates a new HTMLRenderer
|
|
832
838
|
*
|
|
@@ -849,7 +855,7 @@ class fn {
|
|
|
849
855
|
* @param {Node} node */
|
|
850
856
|
openNode(e) {
|
|
851
857
|
if (!qe(e)) return;
|
|
852
|
-
const t =
|
|
858
|
+
const t = gn(
|
|
853
859
|
e.scope,
|
|
854
860
|
{ prefix: this.classPrefix }
|
|
855
861
|
);
|
|
@@ -860,7 +866,7 @@ class fn {
|
|
|
860
866
|
*
|
|
861
867
|
* @param {Node} node */
|
|
862
868
|
closeNode(e) {
|
|
863
|
-
qe(e) && (this.buffer +=
|
|
869
|
+
qe(e) && (this.buffer += pn);
|
|
864
870
|
}
|
|
865
871
|
/**
|
|
866
872
|
* returns the accumulated buffer
|
|
@@ -933,7 +939,7 @@ class Ae {
|
|
|
933
939
|
}));
|
|
934
940
|
}
|
|
935
941
|
}
|
|
936
|
-
class
|
|
942
|
+
class fn extends Ae {
|
|
937
943
|
/**
|
|
938
944
|
* @param {*} options
|
|
939
945
|
*/
|
|
@@ -962,7 +968,7 @@ class bn extends Ae {
|
|
|
962
968
|
t && (i.scope = `language:${t}`), this.add(i);
|
|
963
969
|
}
|
|
964
970
|
toHTML() {
|
|
965
|
-
return new
|
|
971
|
+
return new mn(this, this.options).value();
|
|
966
972
|
}
|
|
967
973
|
finalize() {
|
|
968
974
|
return this.closeAllNodes(), !0;
|
|
@@ -972,32 +978,32 @@ function de(n) {
|
|
|
972
978
|
return n ? typeof n == "string" ? n : n.source : null;
|
|
973
979
|
}
|
|
974
980
|
function st(n) {
|
|
975
|
-
return
|
|
981
|
+
return ne("(?=", n, ")");
|
|
976
982
|
}
|
|
977
|
-
function
|
|
978
|
-
return
|
|
983
|
+
function bn(n) {
|
|
984
|
+
return ne("(?:", n, ")*");
|
|
979
985
|
}
|
|
980
|
-
function
|
|
981
|
-
return
|
|
986
|
+
function _n(n) {
|
|
987
|
+
return ne("(?:", n, ")?");
|
|
982
988
|
}
|
|
983
|
-
function
|
|
989
|
+
function ne(...n) {
|
|
984
990
|
return n.map((t) => de(t)).join("");
|
|
985
991
|
}
|
|
986
|
-
function
|
|
992
|
+
function En(n) {
|
|
987
993
|
const e = n[n.length - 1];
|
|
988
994
|
return typeof e == "object" && e.constructor === Object ? (n.splice(n.length - 1, 1), e) : {};
|
|
989
995
|
}
|
|
990
996
|
function ye(...n) {
|
|
991
|
-
return "(" + (
|
|
997
|
+
return "(" + (En(n).capture ? "" : "?:") + n.map((i) => de(i)).join("|") + ")";
|
|
992
998
|
}
|
|
993
999
|
function ot(n) {
|
|
994
1000
|
return new RegExp(n.toString() + "|").exec("").length - 1;
|
|
995
1001
|
}
|
|
996
|
-
function
|
|
1002
|
+
function yn(n, e) {
|
|
997
1003
|
const t = n && n.exec(e);
|
|
998
1004
|
return t && t.index === 0;
|
|
999
1005
|
}
|
|
1000
|
-
const
|
|
1006
|
+
const wn = new RegExp(ye(
|
|
1001
1007
|
/\[(?:[^\\\]]|\\.)*\]/,
|
|
1002
1008
|
// a character class, inside which ( and \ lose their meaning
|
|
1003
1009
|
/\(\?<(?![=!])[^>]+>/,
|
|
@@ -1015,27 +1021,27 @@ function xe(n, { joinWith: e }) {
|
|
|
1015
1021
|
let t = 0;
|
|
1016
1022
|
return n.map((i) => {
|
|
1017
1023
|
t += 1;
|
|
1018
|
-
const
|
|
1019
|
-
let a = de(i),
|
|
1024
|
+
const r = t;
|
|
1025
|
+
let a = de(i), s = "";
|
|
1020
1026
|
for (; a.length > 0; ) {
|
|
1021
|
-
const o =
|
|
1027
|
+
const o = wn.exec(a);
|
|
1022
1028
|
if (!o) {
|
|
1023
|
-
|
|
1029
|
+
s += a;
|
|
1024
1030
|
break;
|
|
1025
1031
|
}
|
|
1026
|
-
|
|
1032
|
+
s += a.substring(0, o.index), a = a.substring(o.index + o[0].length), o[0][0] === "\\" && o[1] ? s += "\\" + String(Number(o[1]) + r) : (s += o[0], (o[0] === "(" || /^\(\?[<']/.test(o[0])) && t++);
|
|
1027
1033
|
}
|
|
1028
|
-
return
|
|
1034
|
+
return s;
|
|
1029
1035
|
}).map((i) => `(${i})`).join(e);
|
|
1030
1036
|
}
|
|
1031
|
-
const
|
|
1037
|
+
const vn = /\b\B/, at = "[a-zA-Z]\\w*", Ce = "[a-zA-Z_]\\w*", ct = "\\b\\d+(\\.\\d+)?", lt = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", dt = "\\b(0b[01]+)", kn = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", Nn = (n = {}) => {
|
|
1032
1038
|
const e = /^#![ ]*\//;
|
|
1033
|
-
return n.binary && (n.begin =
|
|
1039
|
+
return n.binary && (n.begin = ne(
|
|
1034
1040
|
e,
|
|
1035
1041
|
/.*\b/,
|
|
1036
1042
|
n.binary,
|
|
1037
1043
|
/\b.*/
|
|
1038
|
-
)),
|
|
1044
|
+
)), J({
|
|
1039
1045
|
scope: "meta",
|
|
1040
1046
|
begin: e,
|
|
1041
1047
|
end: /$/,
|
|
@@ -1054,16 +1060,16 @@ const Nn = /\b\B/, at = "[a-zA-Z]\\w*", Ce = "[a-zA-Z_]\\w*", ct = "\\b\\d+(\\.\
|
|
|
1054
1060
|
end: "'",
|
|
1055
1061
|
illegal: "\\n",
|
|
1056
1062
|
contains: [ue]
|
|
1057
|
-
},
|
|
1063
|
+
}, Sn = {
|
|
1058
1064
|
scope: "string",
|
|
1059
1065
|
begin: '"',
|
|
1060
1066
|
end: '"',
|
|
1061
1067
|
illegal: "\\n",
|
|
1062
1068
|
contains: [ue]
|
|
1063
|
-
},
|
|
1069
|
+
}, An = {
|
|
1064
1070
|
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/
|
|
1065
1071
|
}, we = function(n, e, t = {}) {
|
|
1066
|
-
const i =
|
|
1072
|
+
const i = J(
|
|
1067
1073
|
{
|
|
1068
1074
|
scope: "comment",
|
|
1069
1075
|
begin: n,
|
|
@@ -1081,7 +1087,7 @@ const Nn = /\b\B/, at = "[a-zA-Z]\\w*", Ce = "[a-zA-Z_]\\w*", ct = "\\b\\d+(\\.\
|
|
|
1081
1087
|
excludeBegin: !0,
|
|
1082
1088
|
relevance: 0
|
|
1083
1089
|
});
|
|
1084
|
-
const
|
|
1090
|
+
const r = ye(
|
|
1085
1091
|
// list of common 1 and 2 letter words in English
|
|
1086
1092
|
"I",
|
|
1087
1093
|
"a",
|
|
@@ -1117,30 +1123,30 @@ const Nn = /\b\B/, at = "[a-zA-Z]\\w*", Ce = "[a-zA-Z_]\\w*", ct = "\\b\\d+(\\.\
|
|
|
1117
1123
|
//
|
|
1118
1124
|
// for a visual example please see:
|
|
1119
1125
|
// https://github.com/highlightjs/highlight.js/issues/2827
|
|
1120
|
-
begin:
|
|
1126
|
+
begin: ne(
|
|
1121
1127
|
/[ ]+/,
|
|
1122
1128
|
// necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
|
|
1123
1129
|
"(",
|
|
1124
|
-
|
|
1130
|
+
r,
|
|
1125
1131
|
/[.]?[:]?([.][ ]|[ ])/,
|
|
1126
1132
|
"){3}"
|
|
1127
1133
|
)
|
|
1128
1134
|
// look for 3 words in a row
|
|
1129
1135
|
}
|
|
1130
1136
|
), i;
|
|
1131
|
-
},
|
|
1137
|
+
}, xn = we("//", "$"), Cn = we("/\\*", "\\*/"), Mn = we("#", "$"), Rn = {
|
|
1132
1138
|
scope: "number",
|
|
1133
1139
|
begin: ct,
|
|
1134
1140
|
relevance: 0
|
|
1135
|
-
},
|
|
1141
|
+
}, On = {
|
|
1136
1142
|
scope: "number",
|
|
1137
1143
|
begin: lt,
|
|
1138
1144
|
relevance: 0
|
|
1139
|
-
},
|
|
1145
|
+
}, In = {
|
|
1140
1146
|
scope: "number",
|
|
1141
1147
|
begin: dt,
|
|
1142
1148
|
relevance: 0
|
|
1143
|
-
},
|
|
1149
|
+
}, Ln = {
|
|
1144
1150
|
scope: "regexp",
|
|
1145
1151
|
begin: /\/(?=[^/\n]*\/)/,
|
|
1146
1152
|
end: /\/[gimuy]*/,
|
|
@@ -1153,19 +1159,19 @@ const Nn = /\b\B/, at = "[a-zA-Z]\\w*", Ce = "[a-zA-Z_]\\w*", ct = "\\b\\d+(\\.\
|
|
|
1153
1159
|
contains: [ue]
|
|
1154
1160
|
}
|
|
1155
1161
|
]
|
|
1156
|
-
},
|
|
1162
|
+
}, Dn = {
|
|
1157
1163
|
scope: "title",
|
|
1158
1164
|
begin: at,
|
|
1159
1165
|
relevance: 0
|
|
1160
|
-
},
|
|
1166
|
+
}, Pn = {
|
|
1161
1167
|
scope: "title",
|
|
1162
1168
|
begin: Ce,
|
|
1163
1169
|
relevance: 0
|
|
1164
|
-
},
|
|
1170
|
+
}, Bn = {
|
|
1165
1171
|
// excludes method names from keyword processing
|
|
1166
1172
|
begin: "\\.\\s*" + Ce,
|
|
1167
1173
|
relevance: 0
|
|
1168
|
-
},
|
|
1174
|
+
}, $n = function(n) {
|
|
1169
1175
|
return Object.assign(
|
|
1170
1176
|
n,
|
|
1171
1177
|
{
|
|
@@ -1184,63 +1190,63 @@ var me = /* @__PURE__ */ Object.freeze({
|
|
|
1184
1190
|
__proto__: null,
|
|
1185
1191
|
APOS_STRING_MODE: Tn,
|
|
1186
1192
|
BACKSLASH_ESCAPE: ue,
|
|
1187
|
-
BINARY_NUMBER_MODE:
|
|
1193
|
+
BINARY_NUMBER_MODE: In,
|
|
1188
1194
|
BINARY_NUMBER_RE: dt,
|
|
1189
1195
|
COMMENT: we,
|
|
1190
|
-
C_BLOCK_COMMENT_MODE:
|
|
1191
|
-
C_LINE_COMMENT_MODE:
|
|
1192
|
-
C_NUMBER_MODE:
|
|
1196
|
+
C_BLOCK_COMMENT_MODE: Cn,
|
|
1197
|
+
C_LINE_COMMENT_MODE: xn,
|
|
1198
|
+
C_NUMBER_MODE: On,
|
|
1193
1199
|
C_NUMBER_RE: lt,
|
|
1194
|
-
END_SAME_AS_BEGIN:
|
|
1195
|
-
HASH_COMMENT_MODE:
|
|
1200
|
+
END_SAME_AS_BEGIN: $n,
|
|
1201
|
+
HASH_COMMENT_MODE: Mn,
|
|
1196
1202
|
IDENT_RE: at,
|
|
1197
|
-
MATCH_NOTHING_RE:
|
|
1198
|
-
METHOD_GUARD:
|
|
1199
|
-
NUMBER_MODE:
|
|
1203
|
+
MATCH_NOTHING_RE: vn,
|
|
1204
|
+
METHOD_GUARD: Bn,
|
|
1205
|
+
NUMBER_MODE: Rn,
|
|
1200
1206
|
NUMBER_RE: ct,
|
|
1201
|
-
PHRASAL_WORDS_MODE:
|
|
1202
|
-
QUOTE_STRING_MODE:
|
|
1203
|
-
REGEXP_MODE:
|
|
1207
|
+
PHRASAL_WORDS_MODE: An,
|
|
1208
|
+
QUOTE_STRING_MODE: Sn,
|
|
1209
|
+
REGEXP_MODE: Ln,
|
|
1204
1210
|
RE_STARTERS_RE: kn,
|
|
1205
|
-
SHEBANG:
|
|
1206
|
-
TITLE_MODE:
|
|
1211
|
+
SHEBANG: Nn,
|
|
1212
|
+
TITLE_MODE: Dn,
|
|
1207
1213
|
UNDERSCORE_IDENT_RE: Ce,
|
|
1208
|
-
UNDERSCORE_TITLE_MODE:
|
|
1214
|
+
UNDERSCORE_TITLE_MODE: Pn
|
|
1209
1215
|
});
|
|
1210
|
-
function
|
|
1216
|
+
function Un(n, e) {
|
|
1211
1217
|
n.input[n.index - 1] === "." && e.ignoreMatch();
|
|
1212
1218
|
}
|
|
1213
|
-
function
|
|
1219
|
+
function Hn(n, e) {
|
|
1214
1220
|
n.className !== void 0 && (n.scope = n.className, delete n.className);
|
|
1215
1221
|
}
|
|
1216
|
-
function
|
|
1217
|
-
e && n.beginKeywords && (n.begin = "\\b(" + n.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", n.__beforeBegin =
|
|
1222
|
+
function Fn(n, e) {
|
|
1223
|
+
e && n.beginKeywords && (n.begin = "\\b(" + n.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", n.__beforeBegin = Un, n.keywords = n.keywords || n.beginKeywords, delete n.beginKeywords, n.relevance === void 0 && (n.relevance = 0));
|
|
1218
1224
|
}
|
|
1219
|
-
function
|
|
1225
|
+
function zn(n, e) {
|
|
1220
1226
|
Array.isArray(n.illegal) && (n.illegal = ye(...n.illegal));
|
|
1221
1227
|
}
|
|
1222
|
-
function
|
|
1228
|
+
function Kn(n, e) {
|
|
1223
1229
|
if (n.match) {
|
|
1224
1230
|
if (n.begin || n.end) throw new Error("begin & end are not supported with match");
|
|
1225
1231
|
n.begin = n.match, delete n.match;
|
|
1226
1232
|
}
|
|
1227
1233
|
}
|
|
1228
|
-
function
|
|
1234
|
+
function Gn(n, e) {
|
|
1229
1235
|
n.relevance === void 0 && (n.relevance = 1);
|
|
1230
1236
|
}
|
|
1231
|
-
const
|
|
1237
|
+
const qn = (n, e) => {
|
|
1232
1238
|
if (!n.beforeMatch) return;
|
|
1233
1239
|
if (n.starts) throw new Error("beforeMatch cannot be used with starts");
|
|
1234
1240
|
const t = Object.assign({}, n);
|
|
1235
1241
|
Object.keys(n).forEach((i) => {
|
|
1236
1242
|
delete n[i];
|
|
1237
|
-
}), n.keywords = t.keywords, n.begin =
|
|
1243
|
+
}), n.keywords = t.keywords, n.begin = ne(t.beforeMatch, st(t.begin)), n.starts = {
|
|
1238
1244
|
relevance: 0,
|
|
1239
1245
|
contains: [
|
|
1240
1246
|
Object.assign(t, { endsParent: !0 })
|
|
1241
1247
|
]
|
|
1242
1248
|
}, n.relevance = 0, delete t.beforeMatch;
|
|
1243
|
-
},
|
|
1249
|
+
}, Wn = [
|
|
1244
1250
|
"of",
|
|
1245
1251
|
"and",
|
|
1246
1252
|
"for",
|
|
@@ -1255,70 +1261,70 @@ const Wn = (n, e) => {
|
|
|
1255
1261
|
// common variable name
|
|
1256
1262
|
"value"
|
|
1257
1263
|
// common variable name
|
|
1258
|
-
],
|
|
1259
|
-
function ut(n, e, t =
|
|
1264
|
+
], Yn = "keyword";
|
|
1265
|
+
function ut(n, e, t = Yn) {
|
|
1260
1266
|
const i = /* @__PURE__ */ Object.create(null);
|
|
1261
|
-
return typeof n == "string" ?
|
|
1267
|
+
return typeof n == "string" ? r(t, n.split(" ")) : Array.isArray(n) ? r(t, n) : Object.keys(n).forEach(function(a) {
|
|
1262
1268
|
Object.assign(
|
|
1263
1269
|
i,
|
|
1264
1270
|
ut(n[a], e, a)
|
|
1265
1271
|
);
|
|
1266
1272
|
}), i;
|
|
1267
|
-
function
|
|
1268
|
-
e && (
|
|
1273
|
+
function r(a, s) {
|
|
1274
|
+
e && (s = s.map((o) => o.toLowerCase())), s.forEach(function(o) {
|
|
1269
1275
|
const c = o.split("|");
|
|
1270
|
-
i[c[0]] = [a,
|
|
1276
|
+
i[c[0]] = [a, Zn(c[0], c[1])];
|
|
1271
1277
|
});
|
|
1272
1278
|
}
|
|
1273
1279
|
}
|
|
1274
|
-
function
|
|
1275
|
-
return e ? Number(e) :
|
|
1280
|
+
function Zn(n, e) {
|
|
1281
|
+
return e ? Number(e) : Vn(n) ? 0 : 1;
|
|
1276
1282
|
}
|
|
1277
|
-
function
|
|
1278
|
-
return
|
|
1283
|
+
function Vn(n) {
|
|
1284
|
+
return Wn.includes(n.toLowerCase());
|
|
1279
1285
|
}
|
|
1280
|
-
const Ye = {},
|
|
1286
|
+
const Ye = {}, te = (n) => {
|
|
1281
1287
|
console.error(n);
|
|
1282
1288
|
}, Ze = (n, ...e) => {
|
|
1283
1289
|
console.log(`WARN: ${n}`, ...e);
|
|
1284
|
-
},
|
|
1290
|
+
}, ie = (n, e) => {
|
|
1285
1291
|
Ye[`${n}/${e}`] || (console.log(`Deprecated as of ${n}. ${e}`), Ye[`${n}/${e}`] = !0);
|
|
1286
1292
|
}, _e = new Error();
|
|
1287
1293
|
function ht(n, e, { key: t }) {
|
|
1288
1294
|
let i = 0;
|
|
1289
|
-
const
|
|
1295
|
+
const r = n[t], a = {}, s = {};
|
|
1290
1296
|
for (let o = 1; o <= e.length; o++)
|
|
1291
|
-
|
|
1292
|
-
n[t] =
|
|
1297
|
+
s[o + i] = r[o], a[o + i] = !0, i += ot(e[o - 1]);
|
|
1298
|
+
n[t] = s, n[t]._emit = a, n[t]._multi = !0;
|
|
1293
1299
|
}
|
|
1294
|
-
function
|
|
1300
|
+
function Xn(n) {
|
|
1295
1301
|
if (Array.isArray(n.begin)) {
|
|
1296
1302
|
if (n.skip || n.excludeBegin || n.returnBegin)
|
|
1297
|
-
throw
|
|
1303
|
+
throw te("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), _e;
|
|
1298
1304
|
if (typeof n.beginScope != "object" || n.beginScope === null)
|
|
1299
|
-
throw
|
|
1305
|
+
throw te("beginScope must be object"), _e;
|
|
1300
1306
|
ht(n, n.begin, { key: "beginScope" }), n.begin = xe(n.begin, { joinWith: "" });
|
|
1301
1307
|
}
|
|
1302
1308
|
}
|
|
1303
|
-
function
|
|
1309
|
+
function Qn(n) {
|
|
1304
1310
|
if (Array.isArray(n.end)) {
|
|
1305
1311
|
if (n.skip || n.excludeEnd || n.returnEnd)
|
|
1306
|
-
throw
|
|
1312
|
+
throw te("skip, excludeEnd, returnEnd not compatible with endScope: {}"), _e;
|
|
1307
1313
|
if (typeof n.endScope != "object" || n.endScope === null)
|
|
1308
|
-
throw
|
|
1314
|
+
throw te("endScope must be object"), _e;
|
|
1309
1315
|
ht(n, n.end, { key: "endScope" }), n.end = xe(n.end, { joinWith: "" });
|
|
1310
1316
|
}
|
|
1311
1317
|
}
|
|
1312
|
-
function
|
|
1318
|
+
function Jn(n) {
|
|
1313
1319
|
n.scope && typeof n.scope == "object" && n.scope !== null && (n.beginScope = n.scope, delete n.scope);
|
|
1314
1320
|
}
|
|
1315
|
-
function
|
|
1316
|
-
|
|
1321
|
+
function jn(n) {
|
|
1322
|
+
Jn(n), typeof n.beginScope == "string" && (n.beginScope = { _wrap: n.beginScope }), typeof n.endScope == "string" && (n.endScope = { _wrap: n.endScope }), Xn(n), Qn(n);
|
|
1317
1323
|
}
|
|
1318
|
-
function
|
|
1319
|
-
function e(
|
|
1324
|
+
function ei(n) {
|
|
1325
|
+
function e(s, o) {
|
|
1320
1326
|
return new RegExp(
|
|
1321
|
-
de(
|
|
1327
|
+
de(s),
|
|
1322
1328
|
"m" + (n.case_insensitive ? "i" : "") + (n.unicodeRegex ? "u" : "") + (o ? "g" : "")
|
|
1323
1329
|
);
|
|
1324
1330
|
}
|
|
@@ -1341,7 +1347,7 @@ function ti(n) {
|
|
|
1341
1347
|
const c = this.matcherRe.exec(o);
|
|
1342
1348
|
if (!c)
|
|
1343
1349
|
return null;
|
|
1344
|
-
const l = c.findIndex((
|
|
1350
|
+
const l = c.findIndex((h, p) => p > 0 && h !== void 0), d = this.matchIndexes[l];
|
|
1345
1351
|
return c.splice(0, l), Object.assign(c, d);
|
|
1346
1352
|
}
|
|
1347
1353
|
}
|
|
@@ -1377,48 +1383,48 @@ function ti(n) {
|
|
|
1377
1383
|
return l && (this.regexIndex += l.position + 1, this.regexIndex === this.count && this.considerAll()), l;
|
|
1378
1384
|
}
|
|
1379
1385
|
}
|
|
1380
|
-
function s
|
|
1386
|
+
function r(s) {
|
|
1381
1387
|
const o = new i();
|
|
1382
|
-
return
|
|
1388
|
+
return s.contains.forEach((c) => o.addRule(c.begin, { rule: c, type: "begin" })), s.terminatorEnd && o.addRule(s.terminatorEnd, { type: "end" }), s.illegal && o.addRule(s.illegal, { type: "illegal" }), o;
|
|
1383
1389
|
}
|
|
1384
|
-
function a(
|
|
1390
|
+
function a(s, o) {
|
|
1385
1391
|
const c = (
|
|
1386
1392
|
/** @type CompiledMode */
|
|
1387
|
-
|
|
1393
|
+
s
|
|
1388
1394
|
);
|
|
1389
|
-
if (
|
|
1395
|
+
if (s.isCompiled) return c;
|
|
1390
1396
|
[
|
|
1391
|
-
|
|
1397
|
+
Hn,
|
|
1392
1398
|
// do this early so compiler extensions generally don't have to worry about
|
|
1393
1399
|
// the distinction between match/begin
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
].forEach((d) => d(
|
|
1398
|
-
|
|
1400
|
+
Kn,
|
|
1401
|
+
jn,
|
|
1402
|
+
qn
|
|
1403
|
+
].forEach((d) => d(s, o)), n.compilerExtensions.forEach((d) => d(s, o)), s.__beforeBegin = null, [
|
|
1404
|
+
Fn,
|
|
1399
1405
|
// do this later so compiler extensions that come earlier have access to the
|
|
1400
1406
|
// raw array if they wanted to perhaps manipulate it, etc.
|
|
1401
|
-
|
|
1407
|
+
zn,
|
|
1402
1408
|
// default to 1 relevance if not specified
|
|
1403
|
-
|
|
1404
|
-
].forEach((d) => d(
|
|
1409
|
+
Gn
|
|
1410
|
+
].forEach((d) => d(s, o)), s.isCompiled = !0;
|
|
1405
1411
|
let l = null;
|
|
1406
|
-
return typeof
|
|
1412
|
+
return typeof s.keywords == "object" && s.keywords.$pattern && (s.keywords = Object.assign({}, s.keywords), l = s.keywords.$pattern, delete s.keywords.$pattern), l = l || /\w+/, s.keywords && (s.keywords = ut(s.keywords, n.case_insensitive)), c.keywordPatternRe = e(l, !0), o && (s.begin || (s.begin = /\B|\b/), c.beginRe = e(c.begin), !s.end && !s.endsWithParent && (s.end = /\B|\b/), s.end && (c.endRe = e(c.end)), c.terminatorEnd = de(c.end) || "", s.endsWithParent && o.terminatorEnd && (c.terminatorEnd += (s.end ? "|" : "") + o.terminatorEnd)), s.illegal && (c.illegalRe = e(
|
|
1407
1413
|
/** @type {RegExp | string} */
|
|
1408
|
-
|
|
1409
|
-
)),
|
|
1410
|
-
return
|
|
1411
|
-
})),
|
|
1414
|
+
s.illegal
|
|
1415
|
+
)), s.contains || (s.contains = []), s.contains = [].concat(...s.contains.map(function(d) {
|
|
1416
|
+
return ti(d === "self" ? s : d);
|
|
1417
|
+
})), s.contains.forEach(function(d) {
|
|
1412
1418
|
a(
|
|
1413
1419
|
/** @type Mode */
|
|
1414
1420
|
d,
|
|
1415
1421
|
c
|
|
1416
1422
|
);
|
|
1417
|
-
}),
|
|
1423
|
+
}), s.starts && a(s.starts, o), c.matcher = r(c), c;
|
|
1418
1424
|
}
|
|
1419
1425
|
if (n.compilerExtensions || (n.compilerExtensions = []), n.contains && n.contains.includes("self"))
|
|
1420
1426
|
throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
|
|
1421
|
-
return n.classNameAliases =
|
|
1427
|
+
return n.classNameAliases = J(n.classNameAliases || {}), a(
|
|
1422
1428
|
/** @type Mode */
|
|
1423
1429
|
n
|
|
1424
1430
|
);
|
|
@@ -1426,21 +1432,21 @@ function ti(n) {
|
|
|
1426
1432
|
function pt(n) {
|
|
1427
1433
|
return n ? n.endsWithParent || pt(n.starts) : !1;
|
|
1428
1434
|
}
|
|
1429
|
-
function
|
|
1435
|
+
function ti(n) {
|
|
1430
1436
|
return n.variants && !n.cachedVariants && (n.cachedVariants = n.variants.map(function(e) {
|
|
1431
|
-
return
|
|
1432
|
-
})), n.cachedVariants ? n.cachedVariants : pt(n) ?
|
|
1437
|
+
return J(n, { variants: null }, e);
|
|
1438
|
+
})), n.cachedVariants ? n.cachedVariants : pt(n) ? J(n, { starts: n.starts ? J(n.starts) : null }) : Object.isFrozen(n) ? J(n) : n;
|
|
1433
1439
|
}
|
|
1434
|
-
var
|
|
1435
|
-
class
|
|
1440
|
+
var ni = "11.12.0";
|
|
1441
|
+
class ii extends Error {
|
|
1436
1442
|
constructor(e, t) {
|
|
1437
1443
|
super(e), this.name = "HTMLInjectionError", this.html = t;
|
|
1438
1444
|
}
|
|
1439
1445
|
}
|
|
1440
|
-
const
|
|
1446
|
+
const Se = rt, Ve = J, Xe = Symbol("nomatch"), ri = 7, gt = function(n) {
|
|
1441
1447
|
const e = /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null), i = [];
|
|
1442
|
-
let
|
|
1443
|
-
const a = "Could not find the language '{}', did you forget to load/include a language module?",
|
|
1448
|
+
let r = !0;
|
|
1449
|
+
const a = "Could not find the language '{}', did you forget to load/include a language module?", s = { disableAutodetect: !0, name: "Plain text", contains: [] };
|
|
1444
1450
|
let o = {
|
|
1445
1451
|
ignoreUnescapedHTML: !1,
|
|
1446
1452
|
throwUnescapedHTML: !1,
|
|
@@ -1451,37 +1457,37 @@ const Te = rt, Ve = Q, Xe = Symbol("nomatch"), si = 7, gt = function(n) {
|
|
|
1451
1457
|
languages: null,
|
|
1452
1458
|
// beta configuration options, subject to change, welcome to discuss
|
|
1453
1459
|
// https://github.com/highlightjs/highlight.js/issues/1086
|
|
1454
|
-
__emitter:
|
|
1460
|
+
__emitter: fn
|
|
1455
1461
|
};
|
|
1456
|
-
function c(
|
|
1457
|
-
return o.noHighlightRe.test(
|
|
1458
|
-
}
|
|
1459
|
-
function l(
|
|
1460
|
-
let _ =
|
|
1461
|
-
_ +=
|
|
1462
|
-
const
|
|
1463
|
-
if (
|
|
1464
|
-
const
|
|
1465
|
-
return
|
|
1462
|
+
function c(u) {
|
|
1463
|
+
return o.noHighlightRe.test(u);
|
|
1464
|
+
}
|
|
1465
|
+
function l(u) {
|
|
1466
|
+
let _ = u.className + " ";
|
|
1467
|
+
_ += u.parentNode ? u.parentNode.className : "";
|
|
1468
|
+
const f = o.languageDetectRe.exec(_);
|
|
1469
|
+
if (f) {
|
|
1470
|
+
const v = $(f[1]);
|
|
1471
|
+
return v || (Ze(a.replace("{}", f[1])), Ze("Falling back to no-highlight mode for this block.", u)), v ? f[1] : "no-highlight";
|
|
1466
1472
|
}
|
|
1467
|
-
return _.split(/\s+/).find((
|
|
1473
|
+
return _.split(/\s+/).find((v) => c(v) || $(v));
|
|
1468
1474
|
}
|
|
1469
|
-
function d(
|
|
1470
|
-
let
|
|
1471
|
-
typeof _ == "object" ? (
|
|
1472
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),
|
|
1475
|
+
function d(u, _, f) {
|
|
1476
|
+
let v = "", T = "";
|
|
1477
|
+
typeof _ == "object" ? (v = u, f = _.ignoreIllegals, T = _.language) : (ie("10.7.0", "highlight(lang, code, ...args) has been deprecated."), ie("10.7.0", `Please use highlight(code, options) instead.
|
|
1478
|
+
https://github.com/highlightjs/highlight.js/issues/2277`), T = u, v = _), f === void 0 && (f = !0);
|
|
1473
1479
|
const P = {
|
|
1474
|
-
code:
|
|
1475
|
-
language:
|
|
1480
|
+
code: v,
|
|
1481
|
+
language: T
|
|
1476
1482
|
};
|
|
1477
1483
|
X("before:highlight", P);
|
|
1478
|
-
const z = P.result ? P.result :
|
|
1484
|
+
const z = P.result ? P.result : h(P.language, P.code, f);
|
|
1479
1485
|
return z.code = P.code, X("after:highlight", z), z;
|
|
1480
1486
|
}
|
|
1481
|
-
function u
|
|
1482
|
-
const
|
|
1483
|
-
function P(g,
|
|
1484
|
-
return g.keywords[
|
|
1487
|
+
function h(u, _, f, v) {
|
|
1488
|
+
const T = /* @__PURE__ */ Object.create(null);
|
|
1489
|
+
function P(g, y) {
|
|
1490
|
+
return g.keywords[y];
|
|
1485
1491
|
}
|
|
1486
1492
|
function z() {
|
|
1487
1493
|
if (!w.keywords) {
|
|
@@ -1490,21 +1496,21 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1490
1496
|
}
|
|
1491
1497
|
let g = 0;
|
|
1492
1498
|
w.keywordPatternRe.lastIndex = 0;
|
|
1493
|
-
let
|
|
1494
|
-
for (;
|
|
1495
|
-
k += M.substring(g,
|
|
1496
|
-
const x = Y.case_insensitive ?
|
|
1499
|
+
let y = w.keywordPatternRe.exec(M), k = "";
|
|
1500
|
+
for (; y; ) {
|
|
1501
|
+
k += M.substring(g, y.index);
|
|
1502
|
+
const x = Y.case_insensitive ? y[0].toLowerCase() : y[0], K = P(w, x);
|
|
1497
1503
|
if (K) {
|
|
1498
1504
|
const [Z, Ut] = K;
|
|
1499
|
-
if (F.addText(k), k = "",
|
|
1500
|
-
k +=
|
|
1505
|
+
if (F.addText(k), k = "", T[x] = (T[x] || 0) + 1, T[x] <= ri && (pe += Ut), Z.startsWith("_"))
|
|
1506
|
+
k += y[0];
|
|
1501
1507
|
else {
|
|
1502
1508
|
const Ht = Y.classNameAliases[Z] || Z;
|
|
1503
|
-
W(
|
|
1509
|
+
W(y[0], Ht);
|
|
1504
1510
|
}
|
|
1505
1511
|
} else
|
|
1506
|
-
k +=
|
|
1507
|
-
g = w.keywordPatternRe.lastIndex,
|
|
1512
|
+
k += y[0];
|
|
1513
|
+
g = w.keywordPatternRe.lastIndex, y = w.keywordPatternRe.exec(M);
|
|
1508
1514
|
}
|
|
1509
1515
|
k += M.substring(g), F.addText(k);
|
|
1510
1516
|
}
|
|
@@ -1516,7 +1522,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1516
1522
|
F.addText(M);
|
|
1517
1523
|
return;
|
|
1518
1524
|
}
|
|
1519
|
-
g =
|
|
1525
|
+
g = h(w.subLanguage, M, !0, Pe[w.subLanguage]), Pe[w.subLanguage] = /** @type {CompiledMode} */
|
|
1520
1526
|
g._top;
|
|
1521
1527
|
} else
|
|
1522
1528
|
g = m(M, w.subLanguage.length ? w.subLanguage : null);
|
|
@@ -1525,30 +1531,30 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1525
1531
|
function G() {
|
|
1526
1532
|
w.subLanguage != null ? q() : z(), M = "";
|
|
1527
1533
|
}
|
|
1528
|
-
function W(g,
|
|
1529
|
-
g !== "" && (F.startScope(
|
|
1534
|
+
function W(g, y) {
|
|
1535
|
+
g !== "" && (F.startScope(y), F.addText(g), F.endScope());
|
|
1530
1536
|
}
|
|
1531
|
-
function Oe(g,
|
|
1537
|
+
function Oe(g, y) {
|
|
1532
1538
|
let k = 1;
|
|
1533
|
-
const x =
|
|
1539
|
+
const x = y.length - 1;
|
|
1534
1540
|
for (; k <= x; ) {
|
|
1535
1541
|
if (!g._emit[k]) {
|
|
1536
1542
|
k++;
|
|
1537
1543
|
continue;
|
|
1538
1544
|
}
|
|
1539
|
-
const K = Y.classNameAliases[g[k]] || g[k], Z =
|
|
1545
|
+
const K = Y.classNameAliases[g[k]] || g[k], Z = y[k];
|
|
1540
1546
|
K ? W(Z, K) : (M = Z, z(), M = ""), k++;
|
|
1541
1547
|
}
|
|
1542
1548
|
}
|
|
1543
|
-
function Ie(g,
|
|
1544
|
-
return g.scope && typeof g.scope == "string" && F.openNode(Y.classNameAliases[g.scope] || g.scope), g.beginScope && (g.beginScope._wrap ? (W(M, Y.classNameAliases[g.beginScope._wrap] || g.beginScope._wrap), M = "") : g.beginScope._multi && (Oe(g.beginScope,
|
|
1549
|
+
function Ie(g, y) {
|
|
1550
|
+
return g.scope && typeof g.scope == "string" && F.openNode(Y.classNameAliases[g.scope] || g.scope), g.beginScope && (g.beginScope._wrap ? (W(M, Y.classNameAliases[g.beginScope._wrap] || g.beginScope._wrap), M = "") : g.beginScope._multi && (Oe(g.beginScope, y), M = "")), w = Object.create(g, { parent: { value: w } }), w;
|
|
1545
1551
|
}
|
|
1546
|
-
function Le(g,
|
|
1547
|
-
let x =
|
|
1552
|
+
function Le(g, y, k) {
|
|
1553
|
+
let x = yn(g.endRe, k);
|
|
1548
1554
|
if (x) {
|
|
1549
1555
|
if (g["on:end"]) {
|
|
1550
1556
|
const K = new Ge(g);
|
|
1551
|
-
g["on:end"](
|
|
1557
|
+
g["on:end"](y, K), K.isMatchIgnored && (x = !1);
|
|
1552
1558
|
}
|
|
1553
1559
|
if (x) {
|
|
1554
1560
|
for (; g.endsParent && g.parent; )
|
|
@@ -1557,87 +1563,87 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1557
1563
|
}
|
|
1558
1564
|
}
|
|
1559
1565
|
if (g.endsWithParent)
|
|
1560
|
-
return Le(g.parent,
|
|
1566
|
+
return Le(g.parent, y, k);
|
|
1561
1567
|
}
|
|
1562
1568
|
function Lt(g) {
|
|
1563
|
-
return w.matcher.regexIndex === 0 ? (M += g[0], 1) : (
|
|
1569
|
+
return w.matcher.regexIndex === 0 ? (M += g[0], 1) : (Ne = !0, 0);
|
|
1564
1570
|
}
|
|
1565
1571
|
function Dt(g) {
|
|
1566
|
-
const
|
|
1572
|
+
const y = g[0], k = g.rule, x = new Ge(k), K = [k.__beforeBegin, k["on:begin"]];
|
|
1567
1573
|
for (const Z of K)
|
|
1568
1574
|
if (Z && (Z(g, x), x.isMatchIgnored))
|
|
1569
|
-
return Lt(
|
|
1570
|
-
return k.skip ? M +=
|
|
1575
|
+
return Lt(y);
|
|
1576
|
+
return k.skip ? M += y : (k.excludeBegin && (M += y), G(), !k.returnBegin && !k.excludeBegin && (M = y)), Ie(k, g), k.returnBegin ? 0 : y.length;
|
|
1571
1577
|
}
|
|
1572
1578
|
function Pt(g) {
|
|
1573
|
-
const
|
|
1579
|
+
const y = g[0], k = _.substring(g.index), x = Le(w, g, k);
|
|
1574
1580
|
if (!x)
|
|
1575
1581
|
return Xe;
|
|
1576
1582
|
const K = w;
|
|
1577
|
-
w.endScope && w.endScope._wrap ? (G(), W(
|
|
1583
|
+
w.endScope && w.endScope._wrap ? (G(), W(y, w.endScope._wrap)) : w.endScope && w.endScope._multi ? (G(), Oe(w.endScope, g)) : K.skip ? M += y : (K.returnEnd || K.excludeEnd || (M += y), G(), K.excludeEnd && (M = y));
|
|
1578
1584
|
do
|
|
1579
1585
|
w.scope && F.closeNode(), !w.skip && !w.subLanguage && (pe += w.relevance), w = w.parent;
|
|
1580
1586
|
while (w !== x.parent);
|
|
1581
|
-
return x.starts && Ie(x.starts, g), K.returnEnd ? 0 :
|
|
1587
|
+
return x.starts && Ie(x.starts, g), K.returnEnd ? 0 : y.length;
|
|
1582
1588
|
}
|
|
1583
1589
|
function Bt() {
|
|
1584
1590
|
const g = [];
|
|
1585
|
-
for (let
|
|
1586
|
-
|
|
1587
|
-
g.forEach((
|
|
1591
|
+
for (let y = w; y !== Y; y = y.parent)
|
|
1592
|
+
y.scope && g.unshift(y.scope);
|
|
1593
|
+
g.forEach((y) => F.openNode(y));
|
|
1588
1594
|
}
|
|
1589
1595
|
let he = {};
|
|
1590
|
-
function De(g,
|
|
1591
|
-
const k =
|
|
1596
|
+
function De(g, y) {
|
|
1597
|
+
const k = y && y[0];
|
|
1592
1598
|
if (M += g, k == null)
|
|
1593
1599
|
return G(), 0;
|
|
1594
|
-
if (he.type === "begin" &&
|
|
1595
|
-
if (M += _.slice(
|
|
1596
|
-
const x = new Error(`0 width match regex (${
|
|
1597
|
-
throw x.languageName =
|
|
1600
|
+
if (he.type === "begin" && y.type === "end" && he.index === y.index && k === "") {
|
|
1601
|
+
if (M += _.slice(y.index, y.index + 1), !r) {
|
|
1602
|
+
const x = new Error(`0 width match regex (${u})`);
|
|
1603
|
+
throw x.languageName = u, x.badRule = he.rule, x;
|
|
1598
1604
|
}
|
|
1599
1605
|
return 1;
|
|
1600
1606
|
}
|
|
1601
|
-
if (he =
|
|
1602
|
-
return Dt(
|
|
1603
|
-
if (
|
|
1607
|
+
if (he = y, y.type === "begin")
|
|
1608
|
+
return Dt(y);
|
|
1609
|
+
if (y.type === "illegal" && !f) {
|
|
1604
1610
|
const x = new Error('Illegal lexeme "' + k + '" for mode "' + (w.scope || "<unnamed>") + '"');
|
|
1605
1611
|
throw x.mode = w, x;
|
|
1606
|
-
} else if (
|
|
1607
|
-
const x = Pt(
|
|
1612
|
+
} else if (y.type === "end") {
|
|
1613
|
+
const x = Pt(y);
|
|
1608
1614
|
if (x !== Xe)
|
|
1609
1615
|
return x;
|
|
1610
1616
|
}
|
|
1611
|
-
if (
|
|
1612
|
-
return
|
|
1617
|
+
if (y.type === "illegal" && k === "")
|
|
1618
|
+
return y.index === _.length || (M += `
|
|
1613
1619
|
`), 1;
|
|
1614
|
-
if (
|
|
1620
|
+
if (ke > 1e5 && ke > y.index * 3)
|
|
1615
1621
|
throw new Error("potential infinite loop, way more iterations than matches");
|
|
1616
1622
|
return M += k, k.length;
|
|
1617
1623
|
}
|
|
1618
|
-
const Y = $(
|
|
1624
|
+
const Y = $(u);
|
|
1619
1625
|
if (!Y)
|
|
1620
|
-
throw
|
|
1621
|
-
const $t =
|
|
1622
|
-
let ve = "", w =
|
|
1626
|
+
throw te(a.replace("{}", u)), new Error('Unknown language: "' + u + '"');
|
|
1627
|
+
const $t = ei(Y);
|
|
1628
|
+
let ve = "", w = v || $t;
|
|
1623
1629
|
const Pe = {}, F = new o.__emitter(o);
|
|
1624
1630
|
Bt();
|
|
1625
|
-
let M = "", pe = 0,
|
|
1631
|
+
let M = "", pe = 0, ee = 0, ke = 0, Ne = !1;
|
|
1626
1632
|
try {
|
|
1627
1633
|
if (Y.__emitTokens)
|
|
1628
1634
|
Y.__emitTokens(_, F);
|
|
1629
1635
|
else {
|
|
1630
1636
|
for (w.matcher.considerAll(); ; ) {
|
|
1631
|
-
|
|
1637
|
+
ke++, Ne ? Ne = !1 : w.matcher.considerAll(), w.matcher.lastIndex = ee;
|
|
1632
1638
|
const g = w.matcher.exec(_);
|
|
1633
1639
|
if (!g) break;
|
|
1634
|
-
const
|
|
1635
|
-
|
|
1640
|
+
const y = _.substring(ee, g.index), k = De(y, g);
|
|
1641
|
+
ee = g.index + k;
|
|
1636
1642
|
}
|
|
1637
|
-
De(_.substring(
|
|
1643
|
+
De(_.substring(ee));
|
|
1638
1644
|
}
|
|
1639
1645
|
return F.finalize(), ve = F.toHTML(), {
|
|
1640
|
-
language:
|
|
1646
|
+
language: u,
|
|
1641
1647
|
value: ve,
|
|
1642
1648
|
relevance: pe,
|
|
1643
1649
|
illegal: !1,
|
|
@@ -1647,23 +1653,23 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1647
1653
|
} catch (g) {
|
|
1648
1654
|
if (g.message && g.message.includes("Illegal"))
|
|
1649
1655
|
return {
|
|
1650
|
-
language:
|
|
1651
|
-
value:
|
|
1656
|
+
language: u,
|
|
1657
|
+
value: Se(_),
|
|
1652
1658
|
illegal: !0,
|
|
1653
1659
|
relevance: 0,
|
|
1654
1660
|
_illegalBy: {
|
|
1655
1661
|
message: g.message,
|
|
1656
|
-
index:
|
|
1657
|
-
context: _.slice(
|
|
1662
|
+
index: ee,
|
|
1663
|
+
context: _.slice(ee - 100, ee + 100),
|
|
1658
1664
|
mode: g.mode,
|
|
1659
1665
|
resultSoFar: ve
|
|
1660
1666
|
},
|
|
1661
1667
|
_emitter: F
|
|
1662
1668
|
};
|
|
1663
|
-
if (
|
|
1669
|
+
if (r)
|
|
1664
1670
|
return {
|
|
1665
|
-
language:
|
|
1666
|
-
value:
|
|
1671
|
+
language: u,
|
|
1672
|
+
value: Se(_),
|
|
1667
1673
|
illegal: !1,
|
|
1668
1674
|
relevance: 0,
|
|
1669
1675
|
errorRaised: g,
|
|
@@ -1673,23 +1679,23 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1673
1679
|
throw g;
|
|
1674
1680
|
}
|
|
1675
1681
|
}
|
|
1676
|
-
function p(
|
|
1682
|
+
function p(u) {
|
|
1677
1683
|
const _ = {
|
|
1678
|
-
value:
|
|
1684
|
+
value: Se(u),
|
|
1679
1685
|
illegal: !1,
|
|
1680
1686
|
relevance: 0,
|
|
1681
|
-
_top:
|
|
1687
|
+
_top: s,
|
|
1682
1688
|
_emitter: new o.__emitter(o)
|
|
1683
1689
|
};
|
|
1684
|
-
return _._emitter.addText(
|
|
1690
|
+
return _._emitter.addText(u), _;
|
|
1685
1691
|
}
|
|
1686
|
-
function m(
|
|
1692
|
+
function m(u, _) {
|
|
1687
1693
|
_ = _ || o.languages || Object.keys(e);
|
|
1688
|
-
const
|
|
1689
|
-
(G) =>
|
|
1694
|
+
const f = p(u), v = _.filter($).filter(V).map(
|
|
1695
|
+
(G) => h(G, u, !1)
|
|
1690
1696
|
);
|
|
1691
|
-
|
|
1692
|
-
const
|
|
1697
|
+
v.unshift(f);
|
|
1698
|
+
const T = v.sort((G, W) => {
|
|
1693
1699
|
if (G.relevance !== W.relevance) return W.relevance - G.relevance;
|
|
1694
1700
|
if (G.language && W.language) {
|
|
1695
1701
|
if ($(G.language).supersetOf === W.language)
|
|
@@ -1698,130 +1704,130 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1698
1704
|
return -1;
|
|
1699
1705
|
}
|
|
1700
1706
|
return 0;
|
|
1701
|
-
}), [P, z] =
|
|
1707
|
+
}), [P, z] = T, q = P;
|
|
1702
1708
|
return q.secondBest = z, q;
|
|
1703
1709
|
}
|
|
1704
|
-
function
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1710
|
+
function b(u, _, f) {
|
|
1711
|
+
const v = _ && t[_] || f;
|
|
1712
|
+
u.classList.add("hljs"), u.classList.add(`language-${v}`);
|
|
1707
1713
|
}
|
|
1708
|
-
function
|
|
1714
|
+
function E(u) {
|
|
1709
1715
|
let _ = null;
|
|
1710
|
-
const
|
|
1711
|
-
if (c(
|
|
1716
|
+
const f = l(u);
|
|
1717
|
+
if (c(f)) return;
|
|
1712
1718
|
if (X(
|
|
1713
1719
|
"before:highlightElement",
|
|
1714
|
-
{ el:
|
|
1715
|
-
),
|
|
1716
|
-
console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",
|
|
1720
|
+
{ el: u, language: f }
|
|
1721
|
+
), u.dataset.highlighted) {
|
|
1722
|
+
console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", u);
|
|
1717
1723
|
return;
|
|
1718
1724
|
}
|
|
1719
|
-
if (
|
|
1720
|
-
throw new
|
|
1725
|
+
if (u.children.length > 0 && (o.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(u)), o.throwUnescapedHTML))
|
|
1726
|
+
throw new ii(
|
|
1721
1727
|
"One of your code blocks includes unescaped HTML.",
|
|
1722
|
-
|
|
1728
|
+
u.innerHTML
|
|
1723
1729
|
);
|
|
1724
|
-
_ =
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1727
|
-
language:
|
|
1730
|
+
_ = u;
|
|
1731
|
+
const v = _.textContent, T = f ? d(v, { language: f, ignoreIllegals: !0 }) : m(v);
|
|
1732
|
+
u.innerHTML = T.value, u.dataset.highlighted = "yes", b(u, f, T.language), u.result = {
|
|
1733
|
+
language: T.language,
|
|
1728
1734
|
// TODO: remove with version 11.0
|
|
1729
|
-
re:
|
|
1730
|
-
relevance:
|
|
1731
|
-
},
|
|
1732
|
-
language:
|
|
1733
|
-
relevance:
|
|
1734
|
-
}), X("after:highlightElement", { el:
|
|
1735
|
-
}
|
|
1736
|
-
function
|
|
1737
|
-
o = Ve(o,
|
|
1738
|
-
}
|
|
1739
|
-
const
|
|
1740
|
-
C(),
|
|
1735
|
+
re: T.relevance,
|
|
1736
|
+
relevance: T.relevance
|
|
1737
|
+
}, T.secondBest && (u.secondBest = {
|
|
1738
|
+
language: T.secondBest.language,
|
|
1739
|
+
relevance: T.secondBest.relevance
|
|
1740
|
+
}), X("after:highlightElement", { el: u, result: T, text: v });
|
|
1741
|
+
}
|
|
1742
|
+
function N(u) {
|
|
1743
|
+
o = Ve(o, u);
|
|
1744
|
+
}
|
|
1745
|
+
const S = () => {
|
|
1746
|
+
C(), ie("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
|
|
1741
1747
|
};
|
|
1742
1748
|
function O() {
|
|
1743
|
-
C(),
|
|
1749
|
+
C(), ie("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
|
|
1744
1750
|
}
|
|
1745
1751
|
let U = !1;
|
|
1746
1752
|
function C() {
|
|
1747
|
-
function
|
|
1753
|
+
function u() {
|
|
1748
1754
|
C();
|
|
1749
1755
|
}
|
|
1750
1756
|
if (document.readyState === "loading") {
|
|
1751
|
-
U || window.addEventListener("DOMContentLoaded",
|
|
1757
|
+
U || window.addEventListener("DOMContentLoaded", u, !1), U = !0;
|
|
1752
1758
|
return;
|
|
1753
1759
|
}
|
|
1754
|
-
document.querySelectorAll(o.cssSelector).forEach(
|
|
1760
|
+
document.querySelectorAll(o.cssSelector).forEach(E);
|
|
1755
1761
|
}
|
|
1756
|
-
function I(
|
|
1757
|
-
let
|
|
1762
|
+
function I(u, _) {
|
|
1763
|
+
let f = null;
|
|
1758
1764
|
try {
|
|
1759
|
-
|
|
1760
|
-
} catch (
|
|
1761
|
-
if (
|
|
1762
|
-
|
|
1765
|
+
f = _(n);
|
|
1766
|
+
} catch (v) {
|
|
1767
|
+
if (te("Language definition for '{}' could not be registered.".replace("{}", u)), r)
|
|
1768
|
+
te(v);
|
|
1763
1769
|
else
|
|
1764
|
-
throw
|
|
1765
|
-
|
|
1770
|
+
throw v;
|
|
1771
|
+
f = s;
|
|
1766
1772
|
}
|
|
1767
|
-
|
|
1773
|
+
f.name || (f.name = u), e[u] = f, f.rawDefinition = _.bind(null, n), f.aliases && H(f.aliases, { languageName: u });
|
|
1768
1774
|
}
|
|
1769
|
-
function D(
|
|
1770
|
-
delete e[
|
|
1775
|
+
function D(u) {
|
|
1776
|
+
delete e[u];
|
|
1771
1777
|
for (const _ of Object.keys(t))
|
|
1772
|
-
t[_] ===
|
|
1778
|
+
t[_] === u && delete t[_];
|
|
1773
1779
|
}
|
|
1774
1780
|
function B() {
|
|
1775
1781
|
return Object.keys(e);
|
|
1776
1782
|
}
|
|
1777
|
-
function $(
|
|
1778
|
-
return
|
|
1783
|
+
function $(u) {
|
|
1784
|
+
return u = (u || "").toLowerCase(), e[u] || e[t[u]];
|
|
1779
1785
|
}
|
|
1780
|
-
function H(
|
|
1781
|
-
typeof
|
|
1782
|
-
t[
|
|
1786
|
+
function H(u, { languageName: _ }) {
|
|
1787
|
+
typeof u == "string" && (u = [u]), u.forEach((f) => {
|
|
1788
|
+
t[f.toLowerCase()] = _;
|
|
1783
1789
|
});
|
|
1784
1790
|
}
|
|
1785
|
-
function V(
|
|
1786
|
-
const _ = $(
|
|
1791
|
+
function V(u) {
|
|
1792
|
+
const _ = $(u);
|
|
1787
1793
|
return _ && !_.disableAutodetect;
|
|
1788
1794
|
}
|
|
1789
|
-
function
|
|
1790
|
-
|
|
1791
|
-
|
|
1795
|
+
function j(u) {
|
|
1796
|
+
u["before:highlightBlock"] && !u["before:highlightElement"] && (u["before:highlightElement"] = (_) => {
|
|
1797
|
+
u["before:highlightBlock"](
|
|
1792
1798
|
Object.assign({ block: _.el }, _)
|
|
1793
1799
|
);
|
|
1794
|
-
}),
|
|
1795
|
-
|
|
1800
|
+
}), u["after:highlightBlock"] && !u["after:highlightElement"] && (u["after:highlightElement"] = (_) => {
|
|
1801
|
+
u["after:highlightBlock"](
|
|
1796
1802
|
Object.assign({ block: _.el }, _)
|
|
1797
1803
|
);
|
|
1798
1804
|
});
|
|
1799
1805
|
}
|
|
1800
|
-
function oe(
|
|
1801
|
-
|
|
1806
|
+
function oe(u) {
|
|
1807
|
+
j(u), i.push(u);
|
|
1802
1808
|
}
|
|
1803
|
-
function ae(
|
|
1804
|
-
const _ = i.indexOf(
|
|
1809
|
+
function ae(u) {
|
|
1810
|
+
const _ = i.indexOf(u);
|
|
1805
1811
|
_ !== -1 && i.splice(_, 1);
|
|
1806
1812
|
}
|
|
1807
|
-
function X(
|
|
1808
|
-
const
|
|
1809
|
-
i.forEach(function(
|
|
1810
|
-
|
|
1813
|
+
function X(u, _) {
|
|
1814
|
+
const f = u;
|
|
1815
|
+
i.forEach(function(v) {
|
|
1816
|
+
v[f] && v[f](_);
|
|
1811
1817
|
});
|
|
1812
1818
|
}
|
|
1813
|
-
function ce(
|
|
1814
|
-
return
|
|
1819
|
+
function ce(u) {
|
|
1820
|
+
return ie("10.7.0", "highlightBlock will be removed entirely in v12.0"), ie("10.7.0", "Please use highlightElement now."), E(u);
|
|
1815
1821
|
}
|
|
1816
1822
|
Object.assign(n, {
|
|
1817
1823
|
highlight: d,
|
|
1818
1824
|
highlightAuto: m,
|
|
1819
1825
|
highlightAll: C,
|
|
1820
|
-
highlightElement:
|
|
1826
|
+
highlightElement: E,
|
|
1821
1827
|
// TODO: Remove with v12 API
|
|
1822
1828
|
highlightBlock: ce,
|
|
1823
|
-
configure:
|
|
1824
|
-
initHighlighting:
|
|
1829
|
+
configure: N,
|
|
1830
|
+
initHighlighting: S,
|
|
1825
1831
|
initHighlightingOnLoad: O,
|
|
1826
1832
|
registerLanguage: I,
|
|
1827
1833
|
unregisterLanguage: D,
|
|
@@ -1833,25 +1839,25 @@ https://github.com/highlightjs/highlight.js/issues/2277`), S = h, N = _), b ===
|
|
|
1833
1839
|
addPlugin: oe,
|
|
1834
1840
|
removePlugin: ae
|
|
1835
1841
|
}), n.debugMode = function() {
|
|
1836
|
-
|
|
1842
|
+
r = !1;
|
|
1837
1843
|
}, n.safeMode = function() {
|
|
1838
|
-
|
|
1839
|
-
}, n.versionString =
|
|
1840
|
-
concat:
|
|
1844
|
+
r = !0;
|
|
1845
|
+
}, n.versionString = ni, n.regex = {
|
|
1846
|
+
concat: ne,
|
|
1841
1847
|
lookahead: st,
|
|
1842
1848
|
either: ye,
|
|
1843
|
-
optional:
|
|
1844
|
-
anyNumberOfTimes:
|
|
1849
|
+
optional: _n,
|
|
1850
|
+
anyNumberOfTimes: bn
|
|
1845
1851
|
};
|
|
1846
|
-
for (const
|
|
1847
|
-
typeof me[
|
|
1852
|
+
for (const u in me)
|
|
1853
|
+
typeof me[u] == "object" && it(me[u]);
|
|
1848
1854
|
return Object.assign(n, me), n;
|
|
1849
1855
|
}, se = gt({});
|
|
1850
1856
|
se.newInstance = () => gt({});
|
|
1851
|
-
var
|
|
1857
|
+
var si = se;
|
|
1852
1858
|
se.HighlightJS = se;
|
|
1853
1859
|
se.default = se;
|
|
1854
|
-
const A = /* @__PURE__ */
|
|
1860
|
+
const A = /* @__PURE__ */ hn(si), Qe = "[A-Za-z$_][0-9A-Za-z$_]*", oi = [
|
|
1855
1861
|
"as",
|
|
1856
1862
|
// for exports
|
|
1857
1863
|
"in",
|
|
@@ -1896,7 +1902,7 @@ const A = /* @__PURE__ */ pn(oi), Qe = "[A-Za-z$_][0-9A-Za-z$_]*", ai = [
|
|
|
1896
1902
|
"extends",
|
|
1897
1903
|
// It's reached stage 3, which is "recommended for implementation":
|
|
1898
1904
|
"using"
|
|
1899
|
-
],
|
|
1905
|
+
], ai = [
|
|
1900
1906
|
"true",
|
|
1901
1907
|
"false",
|
|
1902
1908
|
"null",
|
|
@@ -1980,7 +1986,7 @@ const A = /* @__PURE__ */ pn(oi), Qe = "[A-Za-z$_][0-9A-Za-z$_]*", ai = [
|
|
|
1980
1986
|
"encodeURIComponent",
|
|
1981
1987
|
"escape",
|
|
1982
1988
|
"unescape"
|
|
1983
|
-
],
|
|
1989
|
+
], ci = [
|
|
1984
1990
|
"arguments",
|
|
1985
1991
|
"this",
|
|
1986
1992
|
"super",
|
|
@@ -1993,27 +1999,27 @@ const A = /* @__PURE__ */ pn(oi), Qe = "[A-Za-z$_][0-9A-Za-z$_]*", ai = [
|
|
|
1993
1999
|
"self",
|
|
1994
2000
|
"global"
|
|
1995
2001
|
// Node.js
|
|
1996
|
-
],
|
|
2002
|
+
], li = [].concat(
|
|
1997
2003
|
bt,
|
|
1998
2004
|
mt,
|
|
1999
2005
|
ft
|
|
2000
2006
|
);
|
|
2001
2007
|
function _t(n) {
|
|
2002
|
-
const e = n.regex, t = (
|
|
2003
|
-
const
|
|
2004
|
-
return
|
|
2005
|
-
}, i = Qe,
|
|
2008
|
+
const e = n.regex, t = (f, { after: v }) => {
|
|
2009
|
+
const T = "</" + f[0].slice(1);
|
|
2010
|
+
return f.input.indexOf(T, v) !== -1;
|
|
2011
|
+
}, i = Qe, r = {
|
|
2006
2012
|
begin: "<>",
|
|
2007
2013
|
end: "</>"
|
|
2008
|
-
}, a = /<[A-Za-z0-9\\._:-]+\s*\/>/,
|
|
2014
|
+
}, a = /<[A-Za-z0-9\\._:-]+\s*\/>/, s = {
|
|
2009
2015
|
begin: /<[A-Za-z0-9\\._:-]+/,
|
|
2010
2016
|
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
|
|
2011
2017
|
/**
|
|
2012
2018
|
* @param {RegExpMatchArray} match
|
|
2013
2019
|
* @param {CallbackResponse} response
|
|
2014
2020
|
*/
|
|
2015
|
-
isTrulyOpeningTag: (
|
|
2016
|
-
const
|
|
2021
|
+
isTrulyOpeningTag: (f, v) => {
|
|
2022
|
+
const T = f[0].length + f.index, P = f.input[T];
|
|
2017
2023
|
if (
|
|
2018
2024
|
// HTML should not include another raw `<` inside a tag
|
|
2019
2025
|
// nested type?
|
|
@@ -2022,28 +2028,28 @@ function _t(n) {
|
|
|
2022
2028
|
// `<T, A extends keyof T, V>`
|
|
2023
2029
|
P === ","
|
|
2024
2030
|
) {
|
|
2025
|
-
|
|
2031
|
+
v.ignoreMatch();
|
|
2026
2032
|
return;
|
|
2027
2033
|
}
|
|
2028
|
-
P === ">" && (t(
|
|
2034
|
+
P === ">" && (t(f, { after: T }) || v.ignoreMatch());
|
|
2029
2035
|
let z;
|
|
2030
|
-
const q =
|
|
2036
|
+
const q = f.input.substring(T);
|
|
2031
2037
|
if (z = q.match(/^\s*=/)) {
|
|
2032
|
-
|
|
2038
|
+
v.ignoreMatch();
|
|
2033
2039
|
return;
|
|
2034
2040
|
}
|
|
2035
2041
|
if ((z = q.match(/^\s+extends\s+/)) && z.index === 0) {
|
|
2036
|
-
|
|
2042
|
+
v.ignoreMatch();
|
|
2037
2043
|
return;
|
|
2038
2044
|
}
|
|
2039
2045
|
}
|
|
2040
2046
|
}, o = {
|
|
2041
2047
|
$pattern: Qe,
|
|
2042
|
-
keyword:
|
|
2043
|
-
literal:
|
|
2044
|
-
built_in:
|
|
2045
|
-
"variable.language":
|
|
2046
|
-
}, c = "[0-9](_?[0-9])*", l = `\\.(${c})`, d = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",
|
|
2048
|
+
keyword: oi,
|
|
2049
|
+
literal: ai,
|
|
2050
|
+
built_in: li,
|
|
2051
|
+
"variable.language": ci
|
|
2052
|
+
}, c = "[0-9](_?[0-9])*", l = `\\.(${c})`, d = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*", h = {
|
|
2047
2053
|
className: "number",
|
|
2048
2054
|
variants: [
|
|
2049
2055
|
// DecimalLiteral
|
|
@@ -2079,7 +2085,7 @@ function _t(n) {
|
|
|
2079
2085
|
],
|
|
2080
2086
|
subLanguage: "xml"
|
|
2081
2087
|
}
|
|
2082
|
-
},
|
|
2088
|
+
}, b = {
|
|
2083
2089
|
begin: ".?css`",
|
|
2084
2090
|
end: "",
|
|
2085
2091
|
starts: {
|
|
@@ -2091,7 +2097,7 @@ function _t(n) {
|
|
|
2091
2097
|
],
|
|
2092
2098
|
subLanguage: "css"
|
|
2093
2099
|
}
|
|
2094
|
-
},
|
|
2100
|
+
}, E = {
|
|
2095
2101
|
begin: ".?gql`",
|
|
2096
2102
|
end: "",
|
|
2097
2103
|
starts: {
|
|
@@ -2103,7 +2109,7 @@ function _t(n) {
|
|
|
2103
2109
|
],
|
|
2104
2110
|
subLanguage: "graphql"
|
|
2105
2111
|
}
|
|
2106
|
-
},
|
|
2112
|
+
}, N = {
|
|
2107
2113
|
className: "string",
|
|
2108
2114
|
begin: "`",
|
|
2109
2115
|
end: "`",
|
|
@@ -2160,12 +2166,12 @@ function _t(n) {
|
|
|
2160
2166
|
n.APOS_STRING_MODE,
|
|
2161
2167
|
n.QUOTE_STRING_MODE,
|
|
2162
2168
|
m,
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2169
|
+
b,
|
|
2170
|
+
E,
|
|
2171
|
+
N,
|
|
2166
2172
|
// Skip numbers when they are part of a variable name
|
|
2167
2173
|
{ match: /\$\d+/ },
|
|
2168
|
-
|
|
2174
|
+
h
|
|
2169
2175
|
// This is intentional:
|
|
2170
2176
|
// See https://github.com/highlightjs/highlight.js/issues/3288
|
|
2171
2177
|
// hljs.REGEXP_MODE
|
|
@@ -2285,13 +2291,13 @@ function _t(n) {
|
|
|
2285
2291
|
label: "func.def",
|
|
2286
2292
|
contains: [D],
|
|
2287
2293
|
illegal: /%/
|
|
2288
|
-
},
|
|
2294
|
+
}, j = {
|
|
2289
2295
|
relevance: 0,
|
|
2290
2296
|
match: /\b[A-Z][A-Z_0-9]+\b/,
|
|
2291
2297
|
className: "variable.constant"
|
|
2292
2298
|
};
|
|
2293
|
-
function oe(
|
|
2294
|
-
return e.concat("(?!",
|
|
2299
|
+
function oe(f) {
|
|
2300
|
+
return e.concat("(?!", f.join("|"), ")");
|
|
2295
2301
|
}
|
|
2296
2302
|
const ae = {
|
|
2297
2303
|
match: e.concat(
|
|
@@ -2301,7 +2307,7 @@ function _t(n) {
|
|
|
2301
2307
|
"super",
|
|
2302
2308
|
"import",
|
|
2303
2309
|
"await"
|
|
2304
|
-
].map((
|
|
2310
|
+
].map((f) => `${f}\\s*\\(`)),
|
|
2305
2311
|
i,
|
|
2306
2312
|
e.lookahead(/\s*\(/)
|
|
2307
2313
|
),
|
|
@@ -2334,7 +2340,7 @@ function _t(n) {
|
|
|
2334
2340
|
},
|
|
2335
2341
|
D
|
|
2336
2342
|
]
|
|
2337
|
-
},
|
|
2343
|
+
}, u = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + n.UNDERSCORE_IDENT_RE + ")\\s*=>", _ = {
|
|
2338
2344
|
match: [
|
|
2339
2345
|
/const|var|let/,
|
|
2340
2346
|
/\s+/,
|
|
@@ -2343,7 +2349,7 @@ function _t(n) {
|
|
|
2343
2349
|
/=\s*/,
|
|
2344
2350
|
/(async\s*)?/,
|
|
2345
2351
|
// async is optional
|
|
2346
|
-
e.lookahead(
|
|
2352
|
+
e.lookahead(u)
|
|
2347
2353
|
],
|
|
2348
2354
|
keywords: "async",
|
|
2349
2355
|
className: {
|
|
@@ -2371,13 +2377,13 @@ function _t(n) {
|
|
|
2371
2377
|
n.APOS_STRING_MODE,
|
|
2372
2378
|
n.QUOTE_STRING_MODE,
|
|
2373
2379
|
m,
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2380
|
+
b,
|
|
2381
|
+
E,
|
|
2382
|
+
N,
|
|
2377
2383
|
O,
|
|
2378
2384
|
// Skip numbers when they are part of a variable name
|
|
2379
2385
|
{ match: /\$\d+/ },
|
|
2380
|
-
|
|
2386
|
+
h,
|
|
2381
2387
|
$,
|
|
2382
2388
|
{
|
|
2383
2389
|
scope: "attr",
|
|
@@ -2398,7 +2404,7 @@ function _t(n) {
|
|
|
2398
2404
|
// we have to count the parens to make sure we actually have the
|
|
2399
2405
|
// correct bounding ( ) before the =>. There could be any number of
|
|
2400
2406
|
// sub-expressions inside also surrounded by parens.
|
|
2401
|
-
begin:
|
|
2407
|
+
begin: u,
|
|
2402
2408
|
returnBegin: !0,
|
|
2403
2409
|
end: "\\s*=>",
|
|
2404
2410
|
contains: [
|
|
@@ -2438,21 +2444,21 @@ function _t(n) {
|
|
|
2438
2444
|
{
|
|
2439
2445
|
// JSX
|
|
2440
2446
|
variants: [
|
|
2441
|
-
{ begin:
|
|
2447
|
+
{ begin: r.begin, end: r.end },
|
|
2442
2448
|
{ match: a },
|
|
2443
2449
|
{
|
|
2444
|
-
begin:
|
|
2450
|
+
begin: s.begin,
|
|
2445
2451
|
// we carefully check the opening tag to see if it truly
|
|
2446
2452
|
// is a tag and not a false positive
|
|
2447
|
-
"on:begin":
|
|
2448
|
-
end:
|
|
2453
|
+
"on:begin": s.isTrulyOpeningTag,
|
|
2454
|
+
end: s.end
|
|
2449
2455
|
}
|
|
2450
2456
|
],
|
|
2451
2457
|
subLanguage: "xml",
|
|
2452
2458
|
contains: [
|
|
2453
2459
|
{
|
|
2454
|
-
begin:
|
|
2455
|
-
end:
|
|
2460
|
+
begin: s.begin,
|
|
2461
|
+
end: s.end,
|
|
2456
2462
|
skip: !0,
|
|
2457
2463
|
contains: ["self"]
|
|
2458
2464
|
}
|
|
@@ -2498,7 +2504,7 @@ function _t(n) {
|
|
|
2498
2504
|
contains: [D]
|
|
2499
2505
|
},
|
|
2500
2506
|
ae,
|
|
2501
|
-
|
|
2507
|
+
j,
|
|
2502
2508
|
B,
|
|
2503
2509
|
ce,
|
|
2504
2510
|
{
|
|
@@ -2619,7 +2625,7 @@ const Ee = "[A-Za-z$_][0-9A-Za-z$_]*", Et = [
|
|
|
2619
2625
|
"SyntaxError",
|
|
2620
2626
|
"TypeError",
|
|
2621
2627
|
"URIError"
|
|
2622
|
-
],
|
|
2628
|
+
], kt = [
|
|
2623
2629
|
"setInterval",
|
|
2624
2630
|
"setTimeout",
|
|
2625
2631
|
"clearInterval",
|
|
@@ -2637,7 +2643,7 @@ const Ee = "[A-Za-z$_][0-9A-Za-z$_]*", Et = [
|
|
|
2637
2643
|
"encodeURIComponent",
|
|
2638
2644
|
"escape",
|
|
2639
2645
|
"unescape"
|
|
2640
|
-
],
|
|
2646
|
+
], Nt = [
|
|
2641
2647
|
"arguments",
|
|
2642
2648
|
"this",
|
|
2643
2649
|
"super",
|
|
@@ -2650,27 +2656,27 @@ const Ee = "[A-Za-z$_][0-9A-Za-z$_]*", Et = [
|
|
|
2650
2656
|
"self",
|
|
2651
2657
|
"global"
|
|
2652
2658
|
// Node.js
|
|
2653
|
-
],
|
|
2654
|
-
|
|
2659
|
+
], Tt = [].concat(
|
|
2660
|
+
kt,
|
|
2655
2661
|
wt,
|
|
2656
2662
|
vt
|
|
2657
2663
|
);
|
|
2658
|
-
function
|
|
2659
|
-
const e = n.regex, t = (
|
|
2660
|
-
const
|
|
2661
|
-
return
|
|
2662
|
-
}, i = Ee,
|
|
2664
|
+
function di(n) {
|
|
2665
|
+
const e = n.regex, t = (f, { after: v }) => {
|
|
2666
|
+
const T = "</" + f[0].slice(1);
|
|
2667
|
+
return f.input.indexOf(T, v) !== -1;
|
|
2668
|
+
}, i = Ee, r = {
|
|
2663
2669
|
begin: "<>",
|
|
2664
2670
|
end: "</>"
|
|
2665
|
-
}, a = /<[A-Za-z0-9\\._:-]+\s*\/>/,
|
|
2671
|
+
}, a = /<[A-Za-z0-9\\._:-]+\s*\/>/, s = {
|
|
2666
2672
|
begin: /<[A-Za-z0-9\\._:-]+/,
|
|
2667
2673
|
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
|
|
2668
2674
|
/**
|
|
2669
2675
|
* @param {RegExpMatchArray} match
|
|
2670
2676
|
* @param {CallbackResponse} response
|
|
2671
2677
|
*/
|
|
2672
|
-
isTrulyOpeningTag: (
|
|
2673
|
-
const
|
|
2678
|
+
isTrulyOpeningTag: (f, v) => {
|
|
2679
|
+
const T = f[0].length + f.index, P = f.input[T];
|
|
2674
2680
|
if (
|
|
2675
2681
|
// HTML should not include another raw `<` inside a tag
|
|
2676
2682
|
// nested type?
|
|
@@ -2679,18 +2685,18 @@ function ui(n) {
|
|
|
2679
2685
|
// `<T, A extends keyof T, V>`
|
|
2680
2686
|
P === ","
|
|
2681
2687
|
) {
|
|
2682
|
-
|
|
2688
|
+
v.ignoreMatch();
|
|
2683
2689
|
return;
|
|
2684
2690
|
}
|
|
2685
|
-
P === ">" && (t(
|
|
2691
|
+
P === ">" && (t(f, { after: T }) || v.ignoreMatch());
|
|
2686
2692
|
let z;
|
|
2687
|
-
const q =
|
|
2693
|
+
const q = f.input.substring(T);
|
|
2688
2694
|
if (z = q.match(/^\s*=/)) {
|
|
2689
|
-
|
|
2695
|
+
v.ignoreMatch();
|
|
2690
2696
|
return;
|
|
2691
2697
|
}
|
|
2692
2698
|
if ((z = q.match(/^\s+extends\s+/)) && z.index === 0) {
|
|
2693
|
-
|
|
2699
|
+
v.ignoreMatch();
|
|
2694
2700
|
return;
|
|
2695
2701
|
}
|
|
2696
2702
|
}
|
|
@@ -2698,9 +2704,9 @@ function ui(n) {
|
|
|
2698
2704
|
$pattern: Ee,
|
|
2699
2705
|
keyword: Et,
|
|
2700
2706
|
literal: yt,
|
|
2701
|
-
built_in:
|
|
2702
|
-
"variable.language":
|
|
2703
|
-
}, c = "[0-9](_?[0-9])*", l = `\\.(${c})`, d = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",
|
|
2707
|
+
built_in: Tt,
|
|
2708
|
+
"variable.language": Nt
|
|
2709
|
+
}, c = "[0-9](_?[0-9])*", l = `\\.(${c})`, d = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*", h = {
|
|
2704
2710
|
className: "number",
|
|
2705
2711
|
variants: [
|
|
2706
2712
|
// DecimalLiteral
|
|
@@ -2736,7 +2742,7 @@ function ui(n) {
|
|
|
2736
2742
|
],
|
|
2737
2743
|
subLanguage: "xml"
|
|
2738
2744
|
}
|
|
2739
|
-
},
|
|
2745
|
+
}, b = {
|
|
2740
2746
|
begin: ".?css`",
|
|
2741
2747
|
end: "",
|
|
2742
2748
|
starts: {
|
|
@@ -2748,7 +2754,7 @@ function ui(n) {
|
|
|
2748
2754
|
],
|
|
2749
2755
|
subLanguage: "css"
|
|
2750
2756
|
}
|
|
2751
|
-
},
|
|
2757
|
+
}, E = {
|
|
2752
2758
|
begin: ".?gql`",
|
|
2753
2759
|
end: "",
|
|
2754
2760
|
starts: {
|
|
@@ -2760,7 +2766,7 @@ function ui(n) {
|
|
|
2760
2766
|
],
|
|
2761
2767
|
subLanguage: "graphql"
|
|
2762
2768
|
}
|
|
2763
|
-
},
|
|
2769
|
+
}, N = {
|
|
2764
2770
|
className: "string",
|
|
2765
2771
|
begin: "`",
|
|
2766
2772
|
end: "`",
|
|
@@ -2817,12 +2823,12 @@ function ui(n) {
|
|
|
2817
2823
|
n.APOS_STRING_MODE,
|
|
2818
2824
|
n.QUOTE_STRING_MODE,
|
|
2819
2825
|
m,
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2826
|
+
b,
|
|
2827
|
+
E,
|
|
2828
|
+
N,
|
|
2823
2829
|
// Skip numbers when they are part of a variable name
|
|
2824
2830
|
{ match: /\$\d+/ },
|
|
2825
|
-
|
|
2831
|
+
h
|
|
2826
2832
|
// This is intentional:
|
|
2827
2833
|
// See https://github.com/highlightjs/highlight.js/issues/3288
|
|
2828
2834
|
// hljs.REGEXP_MODE
|
|
@@ -2942,23 +2948,23 @@ function ui(n) {
|
|
|
2942
2948
|
label: "func.def",
|
|
2943
2949
|
contains: [D],
|
|
2944
2950
|
illegal: /%/
|
|
2945
|
-
},
|
|
2951
|
+
}, j = {
|
|
2946
2952
|
relevance: 0,
|
|
2947
2953
|
match: /\b[A-Z][A-Z_0-9]+\b/,
|
|
2948
2954
|
className: "variable.constant"
|
|
2949
2955
|
};
|
|
2950
|
-
function oe(
|
|
2951
|
-
return e.concat("(?!",
|
|
2956
|
+
function oe(f) {
|
|
2957
|
+
return e.concat("(?!", f.join("|"), ")");
|
|
2952
2958
|
}
|
|
2953
2959
|
const ae = {
|
|
2954
2960
|
match: e.concat(
|
|
2955
2961
|
/\b/,
|
|
2956
2962
|
oe([
|
|
2957
|
-
...
|
|
2963
|
+
...kt,
|
|
2958
2964
|
"super",
|
|
2959
2965
|
"import",
|
|
2960
2966
|
"await"
|
|
2961
|
-
].map((
|
|
2967
|
+
].map((f) => `${f}\\s*\\(`)),
|
|
2962
2968
|
i,
|
|
2963
2969
|
e.lookahead(/\s*\(/)
|
|
2964
2970
|
),
|
|
@@ -2991,7 +2997,7 @@ function ui(n) {
|
|
|
2991
2997
|
},
|
|
2992
2998
|
D
|
|
2993
2999
|
]
|
|
2994
|
-
},
|
|
3000
|
+
}, u = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + n.UNDERSCORE_IDENT_RE + ")\\s*=>", _ = {
|
|
2995
3001
|
match: [
|
|
2996
3002
|
/const|var|let/,
|
|
2997
3003
|
/\s+/,
|
|
@@ -3000,7 +3006,7 @@ function ui(n) {
|
|
|
3000
3006
|
/=\s*/,
|
|
3001
3007
|
/(async\s*)?/,
|
|
3002
3008
|
// async is optional
|
|
3003
|
-
e.lookahead(
|
|
3009
|
+
e.lookahead(u)
|
|
3004
3010
|
],
|
|
3005
3011
|
keywords: "async",
|
|
3006
3012
|
className: {
|
|
@@ -3028,13 +3034,13 @@ function ui(n) {
|
|
|
3028
3034
|
n.APOS_STRING_MODE,
|
|
3029
3035
|
n.QUOTE_STRING_MODE,
|
|
3030
3036
|
m,
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3037
|
+
b,
|
|
3038
|
+
E,
|
|
3039
|
+
N,
|
|
3034
3040
|
O,
|
|
3035
3041
|
// Skip numbers when they are part of a variable name
|
|
3036
3042
|
{ match: /\$\d+/ },
|
|
3037
|
-
|
|
3043
|
+
h,
|
|
3038
3044
|
$,
|
|
3039
3045
|
{
|
|
3040
3046
|
scope: "attr",
|
|
@@ -3055,7 +3061,7 @@ function ui(n) {
|
|
|
3055
3061
|
// we have to count the parens to make sure we actually have the
|
|
3056
3062
|
// correct bounding ( ) before the =>. There could be any number of
|
|
3057
3063
|
// sub-expressions inside also surrounded by parens.
|
|
3058
|
-
begin:
|
|
3064
|
+
begin: u,
|
|
3059
3065
|
returnBegin: !0,
|
|
3060
3066
|
end: "\\s*=>",
|
|
3061
3067
|
contains: [
|
|
@@ -3095,21 +3101,21 @@ function ui(n) {
|
|
|
3095
3101
|
{
|
|
3096
3102
|
// JSX
|
|
3097
3103
|
variants: [
|
|
3098
|
-
{ begin:
|
|
3104
|
+
{ begin: r.begin, end: r.end },
|
|
3099
3105
|
{ match: a },
|
|
3100
3106
|
{
|
|
3101
|
-
begin:
|
|
3107
|
+
begin: s.begin,
|
|
3102
3108
|
// we carefully check the opening tag to see if it truly
|
|
3103
3109
|
// is a tag and not a false positive
|
|
3104
|
-
"on:begin":
|
|
3105
|
-
end:
|
|
3110
|
+
"on:begin": s.isTrulyOpeningTag,
|
|
3111
|
+
end: s.end
|
|
3106
3112
|
}
|
|
3107
3113
|
],
|
|
3108
3114
|
subLanguage: "xml",
|
|
3109
3115
|
contains: [
|
|
3110
3116
|
{
|
|
3111
|
-
begin:
|
|
3112
|
-
end:
|
|
3117
|
+
begin: s.begin,
|
|
3118
|
+
end: s.end,
|
|
3113
3119
|
skip: !0,
|
|
3114
3120
|
contains: ["self"]
|
|
3115
3121
|
}
|
|
@@ -3155,7 +3161,7 @@ function ui(n) {
|
|
|
3155
3161
|
contains: [D]
|
|
3156
3162
|
},
|
|
3157
3163
|
ae,
|
|
3158
|
-
|
|
3164
|
+
j,
|
|
3159
3165
|
B,
|
|
3160
3166
|
ce,
|
|
3161
3167
|
{
|
|
@@ -3165,8 +3171,8 @@ function ui(n) {
|
|
|
3165
3171
|
]
|
|
3166
3172
|
};
|
|
3167
3173
|
}
|
|
3168
|
-
function
|
|
3169
|
-
const e = n.regex, t =
|
|
3174
|
+
function St(n) {
|
|
3175
|
+
const e = n.regex, t = di(n), i = Ee, r = [
|
|
3170
3176
|
"any",
|
|
3171
3177
|
"void",
|
|
3172
3178
|
"number",
|
|
@@ -3187,13 +3193,13 @@ function Tt(n) {
|
|
|
3187
3193
|
1: "keyword",
|
|
3188
3194
|
3: "title.class"
|
|
3189
3195
|
}
|
|
3190
|
-
},
|
|
3196
|
+
}, s = {
|
|
3191
3197
|
beginKeywords: "interface",
|
|
3192
3198
|
end: /\{/,
|
|
3193
3199
|
excludeEnd: !0,
|
|
3194
3200
|
keywords: {
|
|
3195
3201
|
keyword: "interface extends",
|
|
3196
|
-
built_in:
|
|
3202
|
+
built_in: r
|
|
3197
3203
|
},
|
|
3198
3204
|
contains: [t.exports.CLASS_REFERENCE]
|
|
3199
3205
|
}, o = {
|
|
@@ -3218,19 +3224,19 @@ function Tt(n) {
|
|
|
3218
3224
|
$pattern: Ee,
|
|
3219
3225
|
keyword: Et.concat(c),
|
|
3220
3226
|
literal: yt,
|
|
3221
|
-
built_in:
|
|
3222
|
-
"variable.language":
|
|
3227
|
+
built_in: Tt.concat(r),
|
|
3228
|
+
"variable.language": Nt
|
|
3223
3229
|
}, d = {
|
|
3224
3230
|
className: "meta",
|
|
3225
3231
|
begin: "@" + i
|
|
3226
|
-
},
|
|
3227
|
-
const O =
|
|
3232
|
+
}, h = (E, N, S) => {
|
|
3233
|
+
const O = E.contains.findIndex((U) => U.label === N);
|
|
3228
3234
|
if (O === -1)
|
|
3229
3235
|
throw new Error("can not find mode to replace");
|
|
3230
|
-
|
|
3236
|
+
E.contains.splice(O, 1, S);
|
|
3231
3237
|
};
|
|
3232
3238
|
Object.assign(t.keywords, l), t.exports.PARAMS_CONTAINS.push(d);
|
|
3233
|
-
const p = t.contains.find((
|
|
3239
|
+
const p = t.contains.find((E) => E.scope === "attr"), m = Object.assign(
|
|
3234
3240
|
{},
|
|
3235
3241
|
p,
|
|
3236
3242
|
{ match: e.concat(i, e.lookahead(/\s*\?:/)) }
|
|
@@ -3245,12 +3251,12 @@ function Tt(n) {
|
|
|
3245
3251
|
]), t.contains = t.contains.concat([
|
|
3246
3252
|
d,
|
|
3247
3253
|
a,
|
|
3248
|
-
|
|
3254
|
+
s,
|
|
3249
3255
|
m
|
|
3250
3256
|
// Added for optional property assignment highlighting
|
|
3251
|
-
]),
|
|
3252
|
-
const
|
|
3253
|
-
return
|
|
3257
|
+
]), h(t, "shebang", n.SHEBANG()), h(t, "use_strict", o);
|
|
3258
|
+
const b = t.contains.find((E) => E.label === "func.def");
|
|
3259
|
+
return b.relevance = 0, Object.assign(t, {
|
|
3254
3260
|
name: "TypeScript",
|
|
3255
3261
|
aliases: [
|
|
3256
3262
|
"ts",
|
|
@@ -3410,7 +3416,7 @@ function At(n) {
|
|
|
3410
3416
|
}, d = {
|
|
3411
3417
|
begin: /\{\{/,
|
|
3412
3418
|
relevance: 0
|
|
3413
|
-
},
|
|
3419
|
+
}, h = {
|
|
3414
3420
|
className: "string",
|
|
3415
3421
|
contains: [n.BACKSLASH_ESCAPE],
|
|
3416
3422
|
variants: [
|
|
@@ -3491,7 +3497,7 @@ function At(n) {
|
|
|
3491
3497
|
n.APOS_STRING_MODE,
|
|
3492
3498
|
n.QUOTE_STRING_MODE
|
|
3493
3499
|
]
|
|
3494
|
-
}, p = "[0-9](_?[0-9])*", m = `(\\b(${p}))?\\.(${p})|\\b(${p})\\.`,
|
|
3500
|
+
}, p = "[0-9](_?[0-9])*", m = `(\\b(${p}))?\\.(${p})|\\b(${p})\\.`, b = `\\b|${i.join("|")}`, E = {
|
|
3495
3501
|
className: "number",
|
|
3496
3502
|
relevance: 0,
|
|
3497
3503
|
variants: [
|
|
@@ -3506,7 +3512,7 @@ function At(n) {
|
|
|
3506
3512
|
// because both MUST contain a decimal point and so cannot be confused with
|
|
3507
3513
|
// the interior part of an identifier
|
|
3508
3514
|
{
|
|
3509
|
-
begin: `(\\b(${p})|(${m}))[eE][+-]?(${p})[jJ]?(?=${
|
|
3515
|
+
begin: `(\\b(${p})|(${m}))[eE][+-]?(${p})[jJ]?(?=${b})`
|
|
3510
3516
|
},
|
|
3511
3517
|
{
|
|
3512
3518
|
begin: `(${m})[jJ]?`
|
|
@@ -3518,24 +3524,24 @@ function At(n) {
|
|
|
3518
3524
|
// decinteger is optionally imaginary
|
|
3519
3525
|
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
|
|
3520
3526
|
{
|
|
3521
|
-
begin: `\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${
|
|
3527
|
+
begin: `\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`
|
|
3522
3528
|
},
|
|
3523
3529
|
{
|
|
3524
|
-
begin: `\\b0[bB](_?[01])+[lL]?(?=${
|
|
3530
|
+
begin: `\\b0[bB](_?[01])+[lL]?(?=${b})`
|
|
3525
3531
|
},
|
|
3526
3532
|
{
|
|
3527
|
-
begin: `\\b0[oO](_?[0-7])+[lL]?(?=${
|
|
3533
|
+
begin: `\\b0[oO](_?[0-7])+[lL]?(?=${b})`
|
|
3528
3534
|
},
|
|
3529
3535
|
{
|
|
3530
|
-
begin: `\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${
|
|
3536
|
+
begin: `\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`
|
|
3531
3537
|
},
|
|
3532
3538
|
// imagnumber (digitpart-based)
|
|
3533
3539
|
// https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals
|
|
3534
3540
|
{
|
|
3535
|
-
begin: `\\b(${p})[jJ](?=${
|
|
3541
|
+
begin: `\\b(${p})[jJ](?=${b})`
|
|
3536
3542
|
}
|
|
3537
3543
|
]
|
|
3538
|
-
},
|
|
3544
|
+
}, N = {
|
|
3539
3545
|
className: "comment",
|
|
3540
3546
|
begin: e.lookahead(/# type:/),
|
|
3541
3547
|
end: /$/,
|
|
@@ -3552,7 +3558,7 @@ function At(n) {
|
|
|
3552
3558
|
endsWithParent: !0
|
|
3553
3559
|
}
|
|
3554
3560
|
]
|
|
3555
|
-
},
|
|
3561
|
+
}, S = {
|
|
3556
3562
|
className: "params",
|
|
3557
3563
|
variants: [
|
|
3558
3564
|
// Exclude params in functions without params
|
|
@@ -3570,16 +3576,16 @@ function At(n) {
|
|
|
3570
3576
|
contains: [
|
|
3571
3577
|
"self",
|
|
3572
3578
|
c,
|
|
3573
|
-
|
|
3574
|
-
|
|
3579
|
+
E,
|
|
3580
|
+
h,
|
|
3575
3581
|
n.HASH_COMMENT_MODE
|
|
3576
3582
|
]
|
|
3577
3583
|
}
|
|
3578
3584
|
]
|
|
3579
3585
|
};
|
|
3580
3586
|
return l.contains = [
|
|
3581
|
-
|
|
3582
|
-
|
|
3587
|
+
h,
|
|
3588
|
+
E,
|
|
3583
3589
|
c
|
|
3584
3590
|
], {
|
|
3585
3591
|
name: "Python",
|
|
@@ -3593,7 +3599,7 @@ function At(n) {
|
|
|
3593
3599
|
illegal: /(<\/|\?)|=>/,
|
|
3594
3600
|
contains: [
|
|
3595
3601
|
c,
|
|
3596
|
-
|
|
3602
|
+
E,
|
|
3597
3603
|
{
|
|
3598
3604
|
// very common convention
|
|
3599
3605
|
scope: "variable.language",
|
|
@@ -3606,8 +3612,8 @@ function At(n) {
|
|
|
3606
3612
|
relevance: 0
|
|
3607
3613
|
},
|
|
3608
3614
|
{ match: /\bor\b/, scope: "keyword" },
|
|
3609
|
-
|
|
3610
|
-
|
|
3615
|
+
h,
|
|
3616
|
+
N,
|
|
3611
3617
|
n.HASH_COMMENT_MODE,
|
|
3612
3618
|
{
|
|
3613
3619
|
match: [
|
|
@@ -3619,7 +3625,7 @@ function At(n) {
|
|
|
3619
3625
|
1: "keyword",
|
|
3620
3626
|
3: "title.function"
|
|
3621
3627
|
},
|
|
3622
|
-
contains: [
|
|
3628
|
+
contains: [S]
|
|
3623
3629
|
},
|
|
3624
3630
|
{
|
|
3625
3631
|
variants: [
|
|
@@ -3653,20 +3659,20 @@ function At(n) {
|
|
|
3653
3659
|
begin: /^[\t ]*@/,
|
|
3654
3660
|
end: /(?=#)|$/,
|
|
3655
3661
|
contains: [
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3662
|
+
E,
|
|
3663
|
+
S,
|
|
3664
|
+
h
|
|
3659
3665
|
]
|
|
3660
3666
|
}
|
|
3661
3667
|
]
|
|
3662
3668
|
};
|
|
3663
3669
|
}
|
|
3664
|
-
const
|
|
3670
|
+
const ui = "([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity", hi = {
|
|
3665
3671
|
scope: "number",
|
|
3666
|
-
match:
|
|
3672
|
+
match: ui,
|
|
3667
3673
|
relevance: 0
|
|
3668
3674
|
};
|
|
3669
|
-
function
|
|
3675
|
+
function pi(n) {
|
|
3670
3676
|
const e = {
|
|
3671
3677
|
className: "attr",
|
|
3672
3678
|
begin: /(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,
|
|
@@ -3679,7 +3685,7 @@ function gi(n) {
|
|
|
3679
3685
|
"true",
|
|
3680
3686
|
"false",
|
|
3681
3687
|
"null"
|
|
3682
|
-
],
|
|
3688
|
+
], r = {
|
|
3683
3689
|
scope: "literal",
|
|
3684
3690
|
beginKeywords: i.join(" ")
|
|
3685
3691
|
};
|
|
@@ -3694,8 +3700,8 @@ function gi(n) {
|
|
|
3694
3700
|
t,
|
|
3695
3701
|
n.APOS_STRING_MODE,
|
|
3696
3702
|
n.QUOTE_STRING_MODE,
|
|
3697
|
-
|
|
3698
|
-
|
|
3703
|
+
r,
|
|
3704
|
+
hi,
|
|
3699
3705
|
n.C_LINE_COMMENT_MODE,
|
|
3700
3706
|
n.C_BLOCK_COMMENT_MODE
|
|
3701
3707
|
],
|
|
@@ -3727,7 +3733,7 @@ function Me(n) {
|
|
|
3727
3733
|
i
|
|
3728
3734
|
]
|
|
3729
3735
|
});
|
|
3730
|
-
const
|
|
3736
|
+
const r = {
|
|
3731
3737
|
className: "subst",
|
|
3732
3738
|
begin: /\$\(/,
|
|
3733
3739
|
end: /\)/,
|
|
@@ -3743,7 +3749,7 @@ function Me(n) {
|
|
|
3743
3749
|
2: "comment"
|
|
3744
3750
|
}
|
|
3745
3751
|
}
|
|
3746
|
-
),
|
|
3752
|
+
), s = {
|
|
3747
3753
|
begin: /<<-?\s*(?=\w+)/,
|
|
3748
3754
|
starts: { contains: [
|
|
3749
3755
|
n.END_SAME_AS_BEGIN({
|
|
@@ -3759,10 +3765,10 @@ function Me(n) {
|
|
|
3759
3765
|
contains: [
|
|
3760
3766
|
n.BACKSLASH_ESCAPE,
|
|
3761
3767
|
t,
|
|
3762
|
-
|
|
3768
|
+
r
|
|
3763
3769
|
]
|
|
3764
3770
|
};
|
|
3765
|
-
|
|
3771
|
+
r.contains.push(o);
|
|
3766
3772
|
const c = {
|
|
3767
3773
|
match: /\\"/
|
|
3768
3774
|
}, l = {
|
|
@@ -3771,7 +3777,7 @@ function Me(n) {
|
|
|
3771
3777
|
end: /'/
|
|
3772
3778
|
}, d = {
|
|
3773
3779
|
match: /\\'/
|
|
3774
|
-
},
|
|
3780
|
+
}, h = {
|
|
3775
3781
|
begin: /\$?\(\(/,
|
|
3776
3782
|
end: /\)\)/,
|
|
3777
3783
|
contains: [
|
|
@@ -3795,13 +3801,13 @@ function Me(n) {
|
|
|
3795
3801
|
], m = n.SHEBANG({
|
|
3796
3802
|
binary: `(${p.join("|")})`,
|
|
3797
3803
|
relevance: 10
|
|
3798
|
-
}),
|
|
3804
|
+
}), b = {
|
|
3799
3805
|
className: "function",
|
|
3800
3806
|
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
|
|
3801
3807
|
returnBegin: !0,
|
|
3802
3808
|
contains: [n.inherit(n.TITLE_MODE, { begin: /\w[\w\d_]*/ })],
|
|
3803
3809
|
relevance: 0
|
|
3804
|
-
},
|
|
3810
|
+
}, E = [
|
|
3805
3811
|
"if",
|
|
3806
3812
|
"then",
|
|
3807
3813
|
"else",
|
|
@@ -3819,10 +3825,10 @@ function Me(n) {
|
|
|
3819
3825
|
"coproc",
|
|
3820
3826
|
"function",
|
|
3821
3827
|
"select"
|
|
3822
|
-
],
|
|
3828
|
+
], N = [
|
|
3823
3829
|
"true",
|
|
3824
3830
|
"false"
|
|
3825
|
-
],
|
|
3831
|
+
], S = { match: /(\/[a-z._-]+)+/ }, O = [
|
|
3826
3832
|
"break",
|
|
3827
3833
|
"cd",
|
|
3828
3834
|
"continue",
|
|
@@ -4046,8 +4052,8 @@ function Me(n) {
|
|
|
4046
4052
|
],
|
|
4047
4053
|
keywords: {
|
|
4048
4054
|
$pattern: /\b[a-z][a-z0-9._-]+\b/,
|
|
4049
|
-
keyword:
|
|
4050
|
-
literal:
|
|
4055
|
+
keyword: E,
|
|
4056
|
+
literal: N,
|
|
4051
4057
|
built_in: [
|
|
4052
4058
|
...O,
|
|
4053
4059
|
...U,
|
|
@@ -4063,11 +4069,11 @@ function Me(n) {
|
|
|
4063
4069
|
// to catch known shells and boost relevancy
|
|
4064
4070
|
n.SHEBANG(),
|
|
4065
4071
|
// to catch unknown shells but still highlight the shebang
|
|
4066
|
-
|
|
4067
|
-
|
|
4072
|
+
b,
|
|
4073
|
+
h,
|
|
4068
4074
|
a,
|
|
4069
|
-
|
|
4070
|
-
|
|
4075
|
+
s,
|
|
4076
|
+
S,
|
|
4071
4077
|
o,
|
|
4072
4078
|
c,
|
|
4073
4079
|
l,
|
|
@@ -4076,7 +4082,7 @@ function Me(n) {
|
|
|
4076
4082
|
]
|
|
4077
4083
|
};
|
|
4078
4084
|
}
|
|
4079
|
-
const
|
|
4085
|
+
const gi = (n) => ({
|
|
4080
4086
|
IMPORTANT: {
|
|
4081
4087
|
scope: "meta",
|
|
4082
4088
|
begin: "!important"
|
|
@@ -4113,7 +4119,7 @@ const mi = (n) => ({
|
|
|
4113
4119
|
className: "attr",
|
|
4114
4120
|
begin: /--[A-Za-z_][A-Za-z0-9_-]*/
|
|
4115
4121
|
}
|
|
4116
|
-
}),
|
|
4122
|
+
}), mi = [
|
|
4117
4123
|
"a",
|
|
4118
4124
|
"abbr",
|
|
4119
4125
|
"address",
|
|
@@ -4191,7 +4197,7 @@ const mi = (n) => ({
|
|
|
4191
4197
|
"ul",
|
|
4192
4198
|
"var",
|
|
4193
4199
|
"video"
|
|
4194
|
-
],
|
|
4200
|
+
], fi = [
|
|
4195
4201
|
"defs",
|
|
4196
4202
|
"g",
|
|
4197
4203
|
"marker",
|
|
@@ -4233,10 +4239,10 @@ const mi = (n) => ({
|
|
|
4233
4239
|
"tspan",
|
|
4234
4240
|
"foreignObject",
|
|
4235
4241
|
"clipPath"
|
|
4242
|
+
], bi = [
|
|
4243
|
+
...mi,
|
|
4244
|
+
...fi
|
|
4236
4245
|
], _i = [
|
|
4237
|
-
...fi,
|
|
4238
|
-
...bi
|
|
4239
|
-
], Ei = [
|
|
4240
4246
|
"any-hover",
|
|
4241
4247
|
"any-pointer",
|
|
4242
4248
|
"aspect-ratio",
|
|
@@ -4271,7 +4277,7 @@ const mi = (n) => ({
|
|
|
4271
4277
|
"max-width",
|
|
4272
4278
|
"min-height",
|
|
4273
4279
|
"max-height"
|
|
4274
|
-
].sort().reverse(),
|
|
4280
|
+
].sort().reverse(), Ei = [
|
|
4275
4281
|
"active",
|
|
4276
4282
|
"any-link",
|
|
4277
4283
|
"blank",
|
|
@@ -4345,7 +4351,7 @@ const mi = (n) => ({
|
|
|
4345
4351
|
"visited",
|
|
4346
4352
|
"where"
|
|
4347
4353
|
// where()
|
|
4348
|
-
].sort().reverse(),
|
|
4354
|
+
].sort().reverse(), yi = [
|
|
4349
4355
|
"after",
|
|
4350
4356
|
"backdrop",
|
|
4351
4357
|
"before",
|
|
@@ -4360,7 +4366,7 @@ const mi = (n) => ({
|
|
|
4360
4366
|
"selection",
|
|
4361
4367
|
"slotted",
|
|
4362
4368
|
"spelling-error"
|
|
4363
|
-
].sort().reverse(),
|
|
4369
|
+
].sort().reverse(), wi = [
|
|
4364
4370
|
"accent-color",
|
|
4365
4371
|
"align-content",
|
|
4366
4372
|
"align-items",
|
|
@@ -4883,8 +4889,8 @@ const mi = (n) => ({
|
|
|
4883
4889
|
"z-index",
|
|
4884
4890
|
"zoom"
|
|
4885
4891
|
].sort().reverse();
|
|
4886
|
-
function
|
|
4887
|
-
const e = n.regex, t =
|
|
4892
|
+
function vi(n) {
|
|
4893
|
+
const e = n.regex, t = gi(n), i = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ }, r = "and or not only", a = /@-?\w[\w]*(-\w+)*/, s = "[a-zA-Z-][a-zA-Z0-9_-]*", o = [
|
|
4888
4894
|
n.APOS_STRING_MODE,
|
|
4889
4895
|
n.QUOTE_STRING_MODE
|
|
4890
4896
|
];
|
|
@@ -4911,15 +4917,15 @@ function Ni(n) {
|
|
|
4911
4917
|
},
|
|
4912
4918
|
{
|
|
4913
4919
|
className: "selector-class",
|
|
4914
|
-
begin: "\\." +
|
|
4920
|
+
begin: "\\." + s,
|
|
4915
4921
|
relevance: 0
|
|
4916
4922
|
},
|
|
4917
4923
|
t.ATTRIBUTE_SELECTOR_MODE,
|
|
4918
4924
|
{
|
|
4919
4925
|
className: "selector-pseudo",
|
|
4920
4926
|
variants: [
|
|
4921
|
-
{ begin: ":(" +
|
|
4922
|
-
{ begin: ":(:)?(" +
|
|
4927
|
+
{ begin: ":(" + Ei.join("|") + ")" },
|
|
4928
|
+
{ begin: ":(:)?(" + yi.join("|") + ")" }
|
|
4923
4929
|
]
|
|
4924
4930
|
},
|
|
4925
4931
|
// we may actually need this (12/2020)
|
|
@@ -4931,7 +4937,7 @@ function Ni(n) {
|
|
|
4931
4937
|
t.CSS_VARIABLE,
|
|
4932
4938
|
{
|
|
4933
4939
|
className: "attribute",
|
|
4934
|
-
begin: "\\b(" +
|
|
4940
|
+
begin: "\\b(" + wi.join("|") + ")\\b"
|
|
4935
4941
|
},
|
|
4936
4942
|
// attribute values
|
|
4937
4943
|
{
|
|
@@ -4986,8 +4992,8 @@ function Ni(n) {
|
|
|
4986
4992
|
relevance: 0,
|
|
4987
4993
|
keywords: {
|
|
4988
4994
|
$pattern: /[a-z-]+/,
|
|
4989
|
-
keyword:
|
|
4990
|
-
attribute:
|
|
4995
|
+
keyword: r,
|
|
4996
|
+
attribute: _i.join(" ")
|
|
4991
4997
|
},
|
|
4992
4998
|
contains: [
|
|
4993
4999
|
{
|
|
@@ -5002,13 +5008,13 @@ function Ni(n) {
|
|
|
5002
5008
|
},
|
|
5003
5009
|
{
|
|
5004
5010
|
className: "selector-tag",
|
|
5005
|
-
begin: "\\b(" +
|
|
5011
|
+
begin: "\\b(" + bi.join("|") + ")\\b"
|
|
5006
5012
|
}
|
|
5007
5013
|
]
|
|
5008
5014
|
};
|
|
5009
5015
|
}
|
|
5010
5016
|
function Re(n) {
|
|
5011
|
-
const e = n.regex, t = e.concat(/[\p{L}_]/u, e.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u), i = /[\p{L}0-9._:-]+/u,
|
|
5017
|
+
const e = n.regex, t = e.concat(/[\p{L}_]/u, e.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u), i = /[\p{L}0-9._:-]+/u, r = {
|
|
5012
5018
|
className: "symbol",
|
|
5013
5019
|
begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/
|
|
5014
5020
|
}, a = {
|
|
@@ -5020,7 +5026,7 @@ function Re(n) {
|
|
|
5020
5026
|
illegal: /\n/
|
|
5021
5027
|
}
|
|
5022
5028
|
]
|
|
5023
|
-
},
|
|
5029
|
+
}, s = n.inherit(a, {
|
|
5024
5030
|
begin: /\(/,
|
|
5025
5031
|
end: /\)/
|
|
5026
5032
|
}), o = n.inherit(n.APOS_STRING_MODE, { className: "string" }), c = n.inherit(n.QUOTE_STRING_MODE, { className: "string" }), l = {
|
|
@@ -5044,12 +5050,12 @@ function Re(n) {
|
|
|
5044
5050
|
{
|
|
5045
5051
|
begin: /"/,
|
|
5046
5052
|
end: /"/,
|
|
5047
|
-
contains: [
|
|
5053
|
+
contains: [r]
|
|
5048
5054
|
},
|
|
5049
5055
|
{
|
|
5050
5056
|
begin: /'/,
|
|
5051
5057
|
end: /'/,
|
|
5052
|
-
contains: [
|
|
5058
|
+
contains: [r]
|
|
5053
5059
|
},
|
|
5054
5060
|
{ begin: /[^\s"'=<>`]+/ }
|
|
5055
5061
|
]
|
|
@@ -5084,7 +5090,7 @@ function Re(n) {
|
|
|
5084
5090
|
a,
|
|
5085
5091
|
c,
|
|
5086
5092
|
o,
|
|
5087
|
-
|
|
5093
|
+
s,
|
|
5088
5094
|
{
|
|
5089
5095
|
begin: /\[/,
|
|
5090
5096
|
end: /\]/,
|
|
@@ -5095,7 +5101,7 @@ function Re(n) {
|
|
|
5095
5101
|
end: />/,
|
|
5096
5102
|
contains: [
|
|
5097
5103
|
a,
|
|
5098
|
-
|
|
5104
|
+
s,
|
|
5099
5105
|
c,
|
|
5100
5106
|
o
|
|
5101
5107
|
]
|
|
@@ -5114,7 +5120,7 @@ function Re(n) {
|
|
|
5114
5120
|
end: /\]\]>/,
|
|
5115
5121
|
relevance: 10
|
|
5116
5122
|
},
|
|
5117
|
-
|
|
5123
|
+
r,
|
|
5118
5124
|
// xml processing instructions
|
|
5119
5125
|
{
|
|
5120
5126
|
className: "meta",
|
|
@@ -5226,7 +5232,7 @@ function ki(n) {
|
|
|
5226
5232
|
contains: [{ match: /''/ }]
|
|
5227
5233
|
}
|
|
5228
5234
|
]
|
|
5229
|
-
},
|
|
5235
|
+
}, r = {
|
|
5230
5236
|
begin: /"/,
|
|
5231
5237
|
end: /"/,
|
|
5232
5238
|
contains: [{ match: /""/ }]
|
|
@@ -5236,7 +5242,7 @@ function ki(n) {
|
|
|
5236
5242
|
// Not sure it's correct to call NULL literal, and clauses like IS [NOT] NULL look strange that way.
|
|
5237
5243
|
// "null",
|
|
5238
5244
|
"unknown"
|
|
5239
|
-
],
|
|
5245
|
+
], s = [
|
|
5240
5246
|
"double precision",
|
|
5241
5247
|
"large object",
|
|
5242
5248
|
"with timezone",
|
|
@@ -5732,7 +5738,7 @@ function ki(n) {
|
|
|
5732
5738
|
"var_pop",
|
|
5733
5739
|
"var_samp",
|
|
5734
5740
|
"width_bucket"
|
|
5735
|
-
],
|
|
5741
|
+
], h = [
|
|
5736
5742
|
"current_catalog",
|
|
5737
5743
|
"current_date",
|
|
5738
5744
|
"current_default_transform_group",
|
|
@@ -5765,17 +5771,17 @@ function ki(n) {
|
|
|
5765
5771
|
"nulls last",
|
|
5766
5772
|
"depth first",
|
|
5767
5773
|
"breadth first"
|
|
5768
|
-
], m = d,
|
|
5774
|
+
], m = d, b = [
|
|
5769
5775
|
...l,
|
|
5770
5776
|
...c
|
|
5771
|
-
].filter((I) => !d.includes(I)),
|
|
5777
|
+
].filter((I) => !d.includes(I)), E = {
|
|
5772
5778
|
scope: "variable",
|
|
5773
5779
|
match: /@[a-z0-9][a-z0-9_]*/
|
|
5774
|
-
},
|
|
5780
|
+
}, N = {
|
|
5775
5781
|
scope: "operator",
|
|
5776
5782
|
match: /[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,
|
|
5777
5783
|
relevance: 0
|
|
5778
|
-
},
|
|
5784
|
+
}, S = {
|
|
5779
5785
|
match: e.concat(/\b/, e.either(...m), /\s*\(/),
|
|
5780
5786
|
relevance: 0,
|
|
5781
5787
|
keywords: { built_in: m }
|
|
@@ -5806,25 +5812,25 @@ function ki(n) {
|
|
|
5806
5812
|
illegal: /[{}]|<\//,
|
|
5807
5813
|
keywords: {
|
|
5808
5814
|
$pattern: /\b[\w\.]+/,
|
|
5809
|
-
keyword: C(
|
|
5815
|
+
keyword: C(b, { when: (I) => I.length < 3 }),
|
|
5810
5816
|
literal: a,
|
|
5811
5817
|
type: o,
|
|
5812
|
-
built_in:
|
|
5818
|
+
built_in: h
|
|
5813
5819
|
},
|
|
5814
5820
|
contains: [
|
|
5815
5821
|
{
|
|
5816
5822
|
scope: "type",
|
|
5817
|
-
match: O(
|
|
5823
|
+
match: O(s)
|
|
5818
5824
|
},
|
|
5819
5825
|
U,
|
|
5820
|
-
|
|
5821
|
-
|
|
5826
|
+
S,
|
|
5827
|
+
E,
|
|
5822
5828
|
i,
|
|
5823
|
-
|
|
5829
|
+
r,
|
|
5824
5830
|
n.C_NUMBER_MODE,
|
|
5825
5831
|
n.C_BLOCK_COMMENT_MODE,
|
|
5826
5832
|
t,
|
|
5827
|
-
|
|
5833
|
+
N
|
|
5828
5834
|
]
|
|
5829
5835
|
};
|
|
5830
5836
|
}
|
|
@@ -5843,7 +5849,7 @@ function xt(n) {
|
|
|
5843
5849
|
begin: /'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/
|
|
5844
5850
|
}
|
|
5845
5851
|
]
|
|
5846
|
-
},
|
|
5852
|
+
}, r = {
|
|
5847
5853
|
className: "template-variable",
|
|
5848
5854
|
variants: [
|
|
5849
5855
|
{
|
|
@@ -5869,7 +5875,7 @@ function xt(n) {
|
|
|
5869
5875
|
relevance: 0
|
|
5870
5876
|
}
|
|
5871
5877
|
]
|
|
5872
|
-
},
|
|
5878
|
+
}, s = {
|
|
5873
5879
|
className: "string",
|
|
5874
5880
|
relevance: 0,
|
|
5875
5881
|
variants: [
|
|
@@ -5881,9 +5887,9 @@ function xt(n) {
|
|
|
5881
5887
|
],
|
|
5882
5888
|
contains: [
|
|
5883
5889
|
n.BACKSLASH_ESCAPE,
|
|
5884
|
-
|
|
5890
|
+
r
|
|
5885
5891
|
]
|
|
5886
|
-
}, o = n.inherit(
|
|
5892
|
+
}, o = n.inherit(s, { variants: [
|
|
5887
5893
|
{
|
|
5888
5894
|
begin: /'/,
|
|
5889
5895
|
end: /'/,
|
|
@@ -5908,19 +5914,19 @@ function xt(n) {
|
|
|
5908
5914
|
excludeEnd: !0,
|
|
5909
5915
|
keywords: e,
|
|
5910
5916
|
relevance: 0
|
|
5911
|
-
},
|
|
5917
|
+
}, b = {
|
|
5912
5918
|
begin: /\{/,
|
|
5913
5919
|
end: /\}/,
|
|
5914
5920
|
contains: [m],
|
|
5915
5921
|
illegal: "\\n",
|
|
5916
5922
|
relevance: 0
|
|
5917
|
-
},
|
|
5923
|
+
}, E = {
|
|
5918
5924
|
begin: "\\[",
|
|
5919
5925
|
end: "\\]",
|
|
5920
5926
|
contains: [m],
|
|
5921
5927
|
illegal: "\\n",
|
|
5922
5928
|
relevance: 0
|
|
5923
|
-
},
|
|
5929
|
+
}, N = [
|
|
5924
5930
|
i,
|
|
5925
5931
|
{
|
|
5926
5932
|
className: "meta",
|
|
@@ -5996,16 +6002,16 @@ function xt(n) {
|
|
|
5996
6002
|
begin: n.C_NUMBER_RE + "\\b",
|
|
5997
6003
|
relevance: 0
|
|
5998
6004
|
},
|
|
5999
|
-
|
|
6000
|
-
|
|
6005
|
+
b,
|
|
6006
|
+
E,
|
|
6001
6007
|
a,
|
|
6002
|
-
|
|
6003
|
-
],
|
|
6004
|
-
return
|
|
6008
|
+
s
|
|
6009
|
+
], S = [...N];
|
|
6010
|
+
return S.pop(), S.push(o), m.contains = S, {
|
|
6005
6011
|
name: "YAML",
|
|
6006
6012
|
case_insensitive: !0,
|
|
6007
6013
|
aliases: ["yml"],
|
|
6008
|
-
contains:
|
|
6014
|
+
contains: N
|
|
6009
6015
|
};
|
|
6010
6016
|
}
|
|
6011
6017
|
function Ct(n) {
|
|
@@ -6014,7 +6020,7 @@ function Ct(n) {
|
|
|
6014
6020
|
end: ">",
|
|
6015
6021
|
subLanguage: "xml",
|
|
6016
6022
|
relevance: 0
|
|
6017
|
-
}, i = { match: /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/ },
|
|
6023
|
+
}, i = { match: /^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/ }, r = {
|
|
6018
6024
|
className: "code",
|
|
6019
6025
|
variants: [
|
|
6020
6026
|
// TODO: fix to allow these to work with sublanguage also
|
|
@@ -6048,7 +6054,7 @@ function Ct(n) {
|
|
|
6048
6054
|
begin: "^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",
|
|
6049
6055
|
end: "\\s+",
|
|
6050
6056
|
excludeEnd: !0
|
|
6051
|
-
},
|
|
6057
|
+
}, s = {
|
|
6052
6058
|
begin: /^\[[^\n]+\]:/,
|
|
6053
6059
|
returnBegin: !0,
|
|
6054
6060
|
contains: [
|
|
@@ -6154,8 +6160,8 @@ function Ct(n) {
|
|
|
6154
6160
|
relevance: 0
|
|
6155
6161
|
}
|
|
6156
6162
|
]
|
|
6157
|
-
},
|
|
6158
|
-
l.contains.push(p), d.contains.push(
|
|
6163
|
+
}, h = n.inherit(l, { contains: [] }), p = n.inherit(d, { contains: [] });
|
|
6164
|
+
l.contains.push(p), d.contains.push(h);
|
|
6159
6165
|
let m = [
|
|
6160
6166
|
t,
|
|
6161
6167
|
c
|
|
@@ -6163,10 +6169,10 @@ function Ct(n) {
|
|
|
6163
6169
|
return [
|
|
6164
6170
|
l,
|
|
6165
6171
|
d,
|
|
6166
|
-
|
|
6172
|
+
h,
|
|
6167
6173
|
p
|
|
6168
|
-
].forEach((
|
|
6169
|
-
|
|
6174
|
+
].forEach((S) => {
|
|
6175
|
+
S.contains = S.contains.concat(m);
|
|
6170
6176
|
}), m = m.concat(l, d), {
|
|
6171
6177
|
name: "Markdown",
|
|
6172
6178
|
aliases: [
|
|
@@ -6209,9 +6215,9 @@ function Ct(n) {
|
|
|
6209
6215
|
contains: m,
|
|
6210
6216
|
end: "$"
|
|
6211
6217
|
},
|
|
6212
|
-
s,
|
|
6213
|
-
c,
|
|
6214
6218
|
r,
|
|
6219
|
+
c,
|
|
6220
|
+
s,
|
|
6215
6221
|
{
|
|
6216
6222
|
//https://spec.commonmark.org/0.31.2/#entity-references
|
|
6217
6223
|
scope: "literal",
|
|
@@ -6220,7 +6226,7 @@ function Ct(n) {
|
|
|
6220
6226
|
]
|
|
6221
6227
|
};
|
|
6222
6228
|
}
|
|
6223
|
-
function
|
|
6229
|
+
function Ni(n) {
|
|
6224
6230
|
const a = {
|
|
6225
6231
|
keyword: [
|
|
6226
6232
|
"break",
|
|
@@ -6374,16 +6380,16 @@ function Si(n) {
|
|
|
6374
6380
|
};
|
|
6375
6381
|
}
|
|
6376
6382
|
function Mt(n) {
|
|
6377
|
-
const e = n.regex, t = /(r#)?/, i = e.concat(t, n.UNDERSCORE_IDENT_RE),
|
|
6383
|
+
const e = n.regex, t = /(r#)?/, i = e.concat(t, n.UNDERSCORE_IDENT_RE), r = e.concat(t, n.IDENT_RE), a = {
|
|
6378
6384
|
scope: "title.function.invoke",
|
|
6379
6385
|
relevance: 0,
|
|
6380
6386
|
begin: e.concat(
|
|
6381
6387
|
/\b/,
|
|
6382
6388
|
/(?!(?:let|for|while|if|else|match)\b)/,
|
|
6383
|
-
|
|
6389
|
+
r,
|
|
6384
6390
|
e.lookahead(/\s*\(/)
|
|
6385
6391
|
)
|
|
6386
|
-
},
|
|
6392
|
+
}, s = "([ui](8|16|32|64|128|size)|f(16|32|64|128))?", o = [
|
|
6387
6393
|
"abstract",
|
|
6388
6394
|
"as",
|
|
6389
6395
|
"async",
|
|
@@ -6579,10 +6585,10 @@ function Mt(n) {
|
|
|
6579
6585
|
{
|
|
6580
6586
|
scope: "number",
|
|
6581
6587
|
variants: [
|
|
6582
|
-
{ begin: "\\b0b([01_]+)" +
|
|
6583
|
-
{ begin: "\\b0o([0-7_]+)" +
|
|
6584
|
-
{ begin: "\\b0x([A-Fa-f0-9_]+)" +
|
|
6585
|
-
{ begin: "\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)" +
|
|
6588
|
+
{ begin: "\\b0b([01_]+)" + s },
|
|
6589
|
+
{ begin: "\\b0o([0-7_]+)" + s },
|
|
6590
|
+
{ begin: "\\b0x([A-Fa-f0-9_]+)" + s },
|
|
6591
|
+
{ begin: "\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)" + s }
|
|
6586
6592
|
],
|
|
6587
6593
|
relevance: 0
|
|
6588
6594
|
},
|
|
@@ -6716,8 +6722,8 @@ function Rt(n, e, t) {
|
|
|
6716
6722
|
return t === -1 ? "" : n.replace(e, (i) => Rt(n, e, t - 1));
|
|
6717
6723
|
}
|
|
6718
6724
|
function Ti(n) {
|
|
6719
|
-
const e = n.regex, t = "[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*", i = "(?:(?:\\s*\\[\\s*])+)?",
|
|
6720
|
-
"(?:\\s*<\\s*" +
|
|
6725
|
+
const e = n.regex, t = "[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*", i = "(?:(?:\\s*\\[\\s*])+)?", r = t + "<@@@>" + i, s = "(?:" + ("\\?(?:\\s+(?:extends|super)\\s+" + r + ")?") + "|" + r + ")", o = Rt(
|
|
6726
|
+
"(?:\\s*<\\s*" + s + "(?:\\s*,\\s*" + s + ")*\\s*>)?",
|
|
6721
6727
|
/<@@@>/g,
|
|
6722
6728
|
2
|
|
6723
6729
|
), p = {
|
|
@@ -6797,7 +6803,7 @@ function Ti(n) {
|
|
|
6797
6803
|
// allow nested () inside our annotation
|
|
6798
6804
|
}
|
|
6799
6805
|
]
|
|
6800
|
-
},
|
|
6806
|
+
}, b = {
|
|
6801
6807
|
className: "params",
|
|
6802
6808
|
begin: /\(/,
|
|
6803
6809
|
end: /\)/,
|
|
@@ -6894,7 +6900,7 @@ function Ti(n) {
|
|
|
6894
6900
|
3: "title.class"
|
|
6895
6901
|
},
|
|
6896
6902
|
contains: [
|
|
6897
|
-
|
|
6903
|
+
b,
|
|
6898
6904
|
n.C_LINE_COMMENT_MODE,
|
|
6899
6905
|
n.C_BLOCK_COMMENT_MODE
|
|
6900
6906
|
]
|
|
@@ -6935,8 +6941,8 @@ function Ti(n) {
|
|
|
6935
6941
|
]
|
|
6936
6942
|
};
|
|
6937
6943
|
}
|
|
6938
|
-
function
|
|
6939
|
-
const e = n.regex, t = n.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), i = "decltype\\(auto\\)",
|
|
6944
|
+
function Si(n) {
|
|
6945
|
+
const e = n.regex, t = n.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), i = "decltype\\(auto\\)", r = "[a-zA-Z_]\\w*::", s = "(" + i + "|" + e.optional(r) + "[a-zA-Z_]\\w*" + e.optional("<[^<>]+>") + ")", o = e.concat(/\batomic_/, e.either(
|
|
6940
6946
|
"bool",
|
|
6941
6947
|
"char",
|
|
6942
6948
|
"schar",
|
|
@@ -7003,7 +7009,7 @@ function Ai(n) {
|
|
|
7003
7009
|
end: /\)([^()\\\s"]{0,16})"/
|
|
7004
7010
|
})
|
|
7005
7011
|
]
|
|
7006
|
-
},
|
|
7012
|
+
}, h = {
|
|
7007
7013
|
className: "number",
|
|
7008
7014
|
variants: [
|
|
7009
7015
|
{ match: /\b(0b[01']+)/ },
|
|
@@ -7044,14 +7050,14 @@ function Ai(n) {
|
|
|
7044
7050
|
t,
|
|
7045
7051
|
n.C_BLOCK_COMMENT_MODE
|
|
7046
7052
|
]
|
|
7047
|
-
},
|
|
7053
|
+
}, b = [
|
|
7048
7054
|
p,
|
|
7049
7055
|
m
|
|
7050
|
-
],
|
|
7056
|
+
], E = {
|
|
7051
7057
|
className: "title",
|
|
7052
|
-
begin: e.optional(
|
|
7058
|
+
begin: e.optional(r) + n.IDENT_RE,
|
|
7053
7059
|
relevance: 0
|
|
7054
|
-
},
|
|
7060
|
+
}, N = e.optional(r) + n.IDENT_RE + "\\s*\\(", S = 12, C = {
|
|
7055
7061
|
keyword: [
|
|
7056
7062
|
"asm",
|
|
7057
7063
|
"auto",
|
|
@@ -7136,11 +7142,11 @@ function Ai(n) {
|
|
|
7136
7142
|
// TODO: apply hinting work similar to what was done in cpp.js
|
|
7137
7143
|
built_in: "std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"
|
|
7138
7144
|
}, I = [
|
|
7139
|
-
...
|
|
7145
|
+
...b,
|
|
7140
7146
|
c,
|
|
7141
7147
|
t,
|
|
7142
7148
|
n.C_BLOCK_COMMENT_MODE,
|
|
7143
|
-
|
|
7149
|
+
h,
|
|
7144
7150
|
d
|
|
7145
7151
|
], D = {
|
|
7146
7152
|
// This mode covers expression context where we can't expect a function
|
|
@@ -7172,7 +7178,7 @@ function Ai(n) {
|
|
|
7172
7178
|
]),
|
|
7173
7179
|
relevance: 0
|
|
7174
7180
|
}, B = {
|
|
7175
|
-
begin: "(" +
|
|
7181
|
+
begin: "(" + s + "[\\*&\\s]+){1," + S + "}" + N,
|
|
7176
7182
|
returnBegin: !0,
|
|
7177
7183
|
end: /[{;=]/,
|
|
7178
7184
|
excludeEnd: !0,
|
|
@@ -7186,9 +7192,9 @@ function Ai(n) {
|
|
|
7186
7192
|
relevance: 0
|
|
7187
7193
|
},
|
|
7188
7194
|
{
|
|
7189
|
-
begin:
|
|
7195
|
+
begin: N,
|
|
7190
7196
|
returnBegin: !0,
|
|
7191
|
-
contains: [n.inherit(
|
|
7197
|
+
contains: [n.inherit(E, { className: "title.function" })],
|
|
7192
7198
|
relevance: 0
|
|
7193
7199
|
},
|
|
7194
7200
|
// allow for multiple declarations, e.g.:
|
|
@@ -7207,7 +7213,7 @@ function Ai(n) {
|
|
|
7207
7213
|
t,
|
|
7208
7214
|
n.C_BLOCK_COMMENT_MODE,
|
|
7209
7215
|
d,
|
|
7210
|
-
|
|
7216
|
+
h,
|
|
7211
7217
|
c,
|
|
7212
7218
|
// Count matching parentheses.
|
|
7213
7219
|
{
|
|
@@ -7220,7 +7226,7 @@ function Ai(n) {
|
|
|
7220
7226
|
t,
|
|
7221
7227
|
n.C_BLOCK_COMMENT_MODE,
|
|
7222
7228
|
d,
|
|
7223
|
-
|
|
7229
|
+
h,
|
|
7224
7230
|
c
|
|
7225
7231
|
]
|
|
7226
7232
|
}
|
|
@@ -7229,7 +7235,7 @@ function Ai(n) {
|
|
|
7229
7235
|
c,
|
|
7230
7236
|
t,
|
|
7231
7237
|
n.C_BLOCK_COMMENT_MODE,
|
|
7232
|
-
...
|
|
7238
|
+
...b
|
|
7233
7239
|
]
|
|
7234
7240
|
};
|
|
7235
7241
|
return {
|
|
@@ -7245,7 +7251,7 @@ function Ai(n) {
|
|
|
7245
7251
|
B,
|
|
7246
7252
|
I,
|
|
7247
7253
|
[
|
|
7248
|
-
...
|
|
7254
|
+
...b,
|
|
7249
7255
|
{
|
|
7250
7256
|
begin: n.IDENT_RE + "::",
|
|
7251
7257
|
keywords: C
|
|
@@ -7269,7 +7275,7 @@ function Ai(n) {
|
|
|
7269
7275
|
};
|
|
7270
7276
|
}
|
|
7271
7277
|
function Ot(n) {
|
|
7272
|
-
const e = n.regex, t = n.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), i = "decltype\\(auto\\)",
|
|
7278
|
+
const e = n.regex, t = n.COMMENT("//", "$", { contains: [{ begin: /\\\n/ }] }), i = "decltype\\(auto\\)", r = "[a-zA-Z_]\\w*::", s = "(?!struct)(" + i + "|" + e.optional(r) + "[a-zA-Z_]\\w*" + e.optional("<[^<>]+>") + ")", o = {
|
|
7273
7279
|
className: "type",
|
|
7274
7280
|
begin: "\\b[a-z\\d_]*_t\\b"
|
|
7275
7281
|
}, l = {
|
|
@@ -7310,7 +7316,7 @@ function Ot(n) {
|
|
|
7310
7316
|
}
|
|
7311
7317
|
],
|
|
7312
7318
|
relevance: 0
|
|
7313
|
-
},
|
|
7319
|
+
}, h = {
|
|
7314
7320
|
scope: "meta",
|
|
7315
7321
|
begin: /#\s*include\b/,
|
|
7316
7322
|
end: /$/,
|
|
@@ -7343,13 +7349,13 @@ function Ot(n) {
|
|
|
7343
7349
|
n.C_BLOCK_COMMENT_MODE
|
|
7344
7350
|
]
|
|
7345
7351
|
}, m = [
|
|
7346
|
-
|
|
7352
|
+
h,
|
|
7347
7353
|
p
|
|
7348
|
-
],
|
|
7354
|
+
], b = {
|
|
7349
7355
|
className: "title",
|
|
7350
|
-
begin: e.optional(
|
|
7356
|
+
begin: e.optional(r) + n.IDENT_RE,
|
|
7351
7357
|
relevance: 0
|
|
7352
|
-
},
|
|
7358
|
+
}, E = e.optional(r) + n.IDENT_RE + "\\s*\\(", N = 12, S = [
|
|
7353
7359
|
"alignas",
|
|
7354
7360
|
"alignof",
|
|
7355
7361
|
"and",
|
|
@@ -7615,7 +7621,7 @@ function Ot(n) {
|
|
|
7615
7621
|
"vsprintf"
|
|
7616
7622
|
], B = {
|
|
7617
7623
|
type: O,
|
|
7618
|
-
keyword:
|
|
7624
|
+
keyword: S,
|
|
7619
7625
|
literal: [
|
|
7620
7626
|
"NULL",
|
|
7621
7627
|
"false",
|
|
@@ -7634,7 +7640,7 @@ function Ot(n) {
|
|
|
7634
7640
|
},
|
|
7635
7641
|
begin: e.concat(
|
|
7636
7642
|
/\b/,
|
|
7637
|
-
`(?!${
|
|
7643
|
+
`(?!${S.join("|")})`,
|
|
7638
7644
|
n.IDENT_RE,
|
|
7639
7645
|
e.lookahead(/(<[^<>]+>|)\s*\(/)
|
|
7640
7646
|
)
|
|
@@ -7675,9 +7681,9 @@ function Ot(n) {
|
|
|
7675
7681
|
}
|
|
7676
7682
|
]),
|
|
7677
7683
|
relevance: 0
|
|
7678
|
-
},
|
|
7684
|
+
}, j = {
|
|
7679
7685
|
className: "function",
|
|
7680
|
-
begin: "(" +
|
|
7686
|
+
begin: "(" + s + "[\\*&\\s]+){1," + N + "}" + E,
|
|
7681
7687
|
returnBegin: !0,
|
|
7682
7688
|
end: /[{;=]/,
|
|
7683
7689
|
excludeEnd: !0,
|
|
@@ -7691,9 +7697,9 @@ function Ot(n) {
|
|
|
7691
7697
|
relevance: 0
|
|
7692
7698
|
},
|
|
7693
7699
|
{
|
|
7694
|
-
begin:
|
|
7700
|
+
begin: E,
|
|
7695
7701
|
returnBegin: !0,
|
|
7696
|
-
contains: [
|
|
7702
|
+
contains: [b],
|
|
7697
7703
|
relevance: 0
|
|
7698
7704
|
},
|
|
7699
7705
|
// needed because we do not have look-behind on the below rule
|
|
@@ -7768,7 +7774,7 @@ function Ot(n) {
|
|
|
7768
7774
|
classNameAliases: { "function.dispatch": "built_in" },
|
|
7769
7775
|
contains: [].concat(
|
|
7770
7776
|
V,
|
|
7771
|
-
|
|
7777
|
+
j,
|
|
7772
7778
|
$,
|
|
7773
7779
|
H,
|
|
7774
7780
|
[
|
|
@@ -7805,15 +7811,15 @@ function Ot(n) {
|
|
|
7805
7811
|
}
|
|
7806
7812
|
A.registerLanguage("javascript", _t);
|
|
7807
7813
|
A.registerLanguage("js", _t);
|
|
7808
|
-
A.registerLanguage("typescript",
|
|
7809
|
-
A.registerLanguage("ts",
|
|
7814
|
+
A.registerLanguage("typescript", St);
|
|
7815
|
+
A.registerLanguage("ts", St);
|
|
7810
7816
|
A.registerLanguage("python", At);
|
|
7811
7817
|
A.registerLanguage("py", At);
|
|
7812
|
-
A.registerLanguage("json",
|
|
7818
|
+
A.registerLanguage("json", pi);
|
|
7813
7819
|
A.registerLanguage("bash", Me);
|
|
7814
7820
|
A.registerLanguage("sh", Me);
|
|
7815
7821
|
A.registerLanguage("shell", Me);
|
|
7816
|
-
A.registerLanguage("css",
|
|
7822
|
+
A.registerLanguage("css", vi);
|
|
7817
7823
|
A.registerLanguage("xml", Re);
|
|
7818
7824
|
A.registerLanguage("html", Re);
|
|
7819
7825
|
A.registerLanguage("svg", Re);
|
|
@@ -7822,109 +7828,109 @@ A.registerLanguage("yaml", xt);
|
|
|
7822
7828
|
A.registerLanguage("yml", xt);
|
|
7823
7829
|
A.registerLanguage("markdown", Ct);
|
|
7824
7830
|
A.registerLanguage("md", Ct);
|
|
7825
|
-
A.registerLanguage("go",
|
|
7831
|
+
A.registerLanguage("go", Ni);
|
|
7826
7832
|
A.registerLanguage("rust", Mt);
|
|
7827
7833
|
A.registerLanguage("rs", Mt);
|
|
7828
7834
|
A.registerLanguage("java", Ti);
|
|
7829
|
-
A.registerLanguage("c",
|
|
7835
|
+
A.registerLanguage("c", Si);
|
|
7830
7836
|
A.registerLanguage("cpp", Ot);
|
|
7831
7837
|
A.registerLanguage("c++", Ot);
|
|
7832
|
-
const
|
|
7838
|
+
const Ai = /* @__PURE__ */ new Set(["mindmap"]);
|
|
7833
7839
|
function le(n) {
|
|
7834
7840
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
7835
7841
|
}
|
|
7836
|
-
function
|
|
7837
|
-
const t = new Set(e.reservedLanguages ??
|
|
7838
|
-
n.renderer.rules.fence = (
|
|
7839
|
-
var
|
|
7840
|
-
const l =
|
|
7841
|
-
if (!l) return i(
|
|
7842
|
-
const
|
|
7843
|
-
if (t.has(
|
|
7844
|
-
return i(
|
|
7842
|
+
function xi(n, e = {}) {
|
|
7843
|
+
const t = new Set(e.reservedLanguages ?? Ai), i = n.renderer.rules.fence ? n.renderer.rules.fence.bind(n.renderer.rules) : (r, a, s, o, c) => c.renderToken(r, a, s);
|
|
7844
|
+
n.renderer.rules.fence = (r, a, s, o, c) => {
|
|
7845
|
+
var E;
|
|
7846
|
+
const l = r[a];
|
|
7847
|
+
if (!l) return i(r, a, s, o, c);
|
|
7848
|
+
const h = ((E = l.info.trim().split(/\s+/)[0]) == null ? void 0 : E.toLowerCase()) ?? "";
|
|
7849
|
+
if (t.has(h))
|
|
7850
|
+
return i(r, a, s, o, c);
|
|
7845
7851
|
const p = l.content;
|
|
7846
|
-
let m,
|
|
7847
|
-
if (
|
|
7852
|
+
let m, b = h || "text";
|
|
7853
|
+
if (h && A.getLanguage(h))
|
|
7848
7854
|
try {
|
|
7849
7855
|
m = A.highlight(p, {
|
|
7850
|
-
language:
|
|
7856
|
+
language: h,
|
|
7851
7857
|
ignoreIllegals: !0
|
|
7852
7858
|
}).value;
|
|
7853
7859
|
} catch {
|
|
7854
7860
|
m = le(p);
|
|
7855
7861
|
}
|
|
7856
|
-
else if (
|
|
7862
|
+
else if (h)
|
|
7857
7863
|
try {
|
|
7858
|
-
const
|
|
7859
|
-
m =
|
|
7864
|
+
const N = A.highlightAuto(p);
|
|
7865
|
+
m = N.value, b = N.language || h;
|
|
7860
7866
|
} catch {
|
|
7861
7867
|
m = le(p);
|
|
7862
7868
|
}
|
|
7863
7869
|
else
|
|
7864
7870
|
try {
|
|
7865
|
-
const
|
|
7866
|
-
m =
|
|
7871
|
+
const N = A.highlightAuto(p);
|
|
7872
|
+
m = N.value, b = N.language || "text";
|
|
7867
7873
|
} catch {
|
|
7868
7874
|
m = le(p);
|
|
7869
7875
|
}
|
|
7870
|
-
return `<div class="md-editor-codeblock"><div class="md-editor-codeblock-header"><span class="md-editor-codeblock-lights"><span class="md-editor-codeblock-dot md-editor-codeblock-dot--red"></span><span class="md-editor-codeblock-dot md-editor-codeblock-dot--yellow"></span><span class="md-editor-codeblock-dot md-editor-codeblock-dot--green"></span></span><span class="md-editor-codeblock-lang">${le(
|
|
7876
|
+
return `<div class="md-editor-codeblock"><div class="md-editor-codeblock-header"><span class="md-editor-codeblock-lights"><span class="md-editor-codeblock-dot md-editor-codeblock-dot--red"></span><span class="md-editor-codeblock-dot md-editor-codeblock-dot--yellow"></span><span class="md-editor-codeblock-dot md-editor-codeblock-dot--green"></span></span><span class="md-editor-codeblock-lang">${le(b)}</span><button type="button" class="md-editor-codeblock-copy" aria-label="Copy code">Copy</button></div><pre class="md-editor-codeblock-pre"><code class="language-${le(b)}">${m}</code></pre></div>`;
|
|
7871
7877
|
};
|
|
7872
7878
|
}
|
|
7873
|
-
const
|
|
7879
|
+
const Ci = [".mp4", ".webm", ".ogg", ".mov", ".m4v", ".avi", ".mkv"], Mi = [
|
|
7874
7880
|
/(?:youtube\.com\/watch\?[^ ]*v=|youtu\.be\/|youtube\.com\/embed\/|youtube\.com\/shorts\/|youtube\.com\/v\/)([a-zA-Z0-9_-]{11})/,
|
|
7875
7881
|
/^([a-zA-Z0-9_-]{11})$/
|
|
7876
7882
|
];
|
|
7877
|
-
function
|
|
7883
|
+
function Ri(n) {
|
|
7878
7884
|
const e = n.trim();
|
|
7879
7885
|
if (!e) return null;
|
|
7880
|
-
for (const t of
|
|
7886
|
+
for (const t of Mi) {
|
|
7881
7887
|
const i = e.match(t);
|
|
7882
7888
|
if (i && i[1]) return i[1];
|
|
7883
7889
|
}
|
|
7884
7890
|
return null;
|
|
7885
7891
|
}
|
|
7886
|
-
function
|
|
7892
|
+
function Oi(n, e = "YouTube video") {
|
|
7887
7893
|
const t = `https://img.youtube.com/vi/${n}/hqdefault.jpg`, i = `https://www.youtube.com/watch?v=${n}`;
|
|
7888
7894
|
return `[](${i})`;
|
|
7889
7895
|
}
|
|
7890
|
-
function
|
|
7896
|
+
function Ii(n) {
|
|
7891
7897
|
const e = n.toLowerCase().split("?")[0] ?? "";
|
|
7892
|
-
return
|
|
7898
|
+
return Ci.some((t) => e.endsWith(t));
|
|
7893
7899
|
}
|
|
7894
7900
|
function je(n, e = "image") {
|
|
7895
7901
|
return ``;
|
|
7896
7902
|
}
|
|
7897
|
-
function
|
|
7903
|
+
function Li(n, e = "video") {
|
|
7898
7904
|
return ``;
|
|
7899
7905
|
}
|
|
7900
|
-
function
|
|
7901
|
-
const e = n.renderer.rules.image ? n.renderer.rules.image.bind(n.renderer.rules) : (t, i,
|
|
7902
|
-
n.renderer.rules.image = (t, i,
|
|
7906
|
+
function Di(n) {
|
|
7907
|
+
const e = n.renderer.rules.image ? n.renderer.rules.image.bind(n.renderer.rules) : (t, i, r, a, s) => s.renderToken(t, i, r);
|
|
7908
|
+
n.renderer.rules.image = (t, i, r, a, s) => {
|
|
7903
7909
|
const o = t[i];
|
|
7904
|
-
if (!o) return e(t, i,
|
|
7910
|
+
if (!o) return e(t, i, r, a, s);
|
|
7905
7911
|
const c = o.attrGet("src") ?? "";
|
|
7906
|
-
if (
|
|
7912
|
+
if (Ii(c)) {
|
|
7907
7913
|
const l = o.content || "";
|
|
7908
7914
|
return `<video src="${c}" controls class="md-editor-video" title="${l}">${l}</video>`;
|
|
7909
7915
|
}
|
|
7910
|
-
return e(t, i,
|
|
7916
|
+
return e(t, i, r, a, s);
|
|
7911
7917
|
};
|
|
7912
7918
|
}
|
|
7913
|
-
const
|
|
7919
|
+
const Pi = /* @__PURE__ */ new Set([
|
|
7914
7920
|
"notice",
|
|
7915
7921
|
"info",
|
|
7916
7922
|
"tip",
|
|
7917
7923
|
"warning",
|
|
7918
7924
|
"danger",
|
|
7919
7925
|
"success"
|
|
7920
|
-
]),
|
|
7926
|
+
]), Bi = /^:::(\w+)(?:\s+(.+))?$/, $i = /^:::\s*$/, et = {
|
|
7921
7927
|
notice: "Notice",
|
|
7922
7928
|
info: "Info",
|
|
7923
7929
|
tip: "Tip",
|
|
7924
7930
|
warning: "Warning",
|
|
7925
7931
|
danger: "Danger",
|
|
7926
7932
|
success: "Success"
|
|
7927
|
-
},
|
|
7933
|
+
}, Ui = {
|
|
7928
7934
|
notice: "i",
|
|
7929
7935
|
info: "i",
|
|
7930
7936
|
tip: "✓",
|
|
@@ -7932,64 +7938,64 @@ const Bi = /* @__PURE__ */ new Set([
|
|
|
7932
7938
|
danger: "✕",
|
|
7933
7939
|
success: "✓"
|
|
7934
7940
|
};
|
|
7935
|
-
function
|
|
7936
|
-
n.block.ruler.before("fence", "tips_block", (e, t, i,
|
|
7937
|
-
const
|
|
7938
|
-
if (!
|
|
7939
|
-
const o = (
|
|
7940
|
-
if (!
|
|
7941
|
+
function Hi(n) {
|
|
7942
|
+
n.block.ruler.before("fence", "tips_block", (e, t, i, r) => {
|
|
7943
|
+
const s = e.src.slice(e.bMarks[t], e.eMarks[t]).match(Bi);
|
|
7944
|
+
if (!s) return !1;
|
|
7945
|
+
const o = (s[1] ?? "").toLowerCase();
|
|
7946
|
+
if (!Pi.has(o)) return !1;
|
|
7941
7947
|
let c = t + 1, l = !1;
|
|
7942
7948
|
for (; c < i; ) {
|
|
7943
|
-
const
|
|
7944
|
-
if (
|
|
7949
|
+
const b = e.src.slice(e.bMarks[c], e.eMarks[c]);
|
|
7950
|
+
if ($i.test(b.trim())) {
|
|
7945
7951
|
l = !0;
|
|
7946
7952
|
break;
|
|
7947
7953
|
}
|
|
7948
7954
|
c++;
|
|
7949
7955
|
}
|
|
7950
7956
|
if (!l) return !1;
|
|
7951
|
-
if (
|
|
7952
|
-
const d =
|
|
7957
|
+
if (r) return !0;
|
|
7958
|
+
const d = s[2] ?? et[o] ?? o, h = e.src.slice(e.bMarks[t + 1], e.bMarks[c]).trim(), p = n.render(h), m = e.push("tips_block", "div", 0);
|
|
7953
7959
|
return m.content = p, m.info = o, m.markup = d, e.line = c + 1, !0;
|
|
7954
7960
|
}), n.renderer.rules.tips_block = (e, t) => {
|
|
7955
7961
|
const i = e[t];
|
|
7956
7962
|
if (!i) return "";
|
|
7957
|
-
const
|
|
7958
|
-
return `<div class="md-editor-tip md-editor-tip--${
|
|
7963
|
+
const r = i.info ?? "notice", a = i.markup ?? et[r] ?? "Notice", s = Ui[r] ?? "i", o = i.content ?? "";
|
|
7964
|
+
return `<div class="md-editor-tip md-editor-tip--${r}"><div class="md-editor-tip-header"><span class="md-editor-tip-icon">${s}</span><span class="md-editor-tip-title">${Fi(a)}</span></div><div class="md-editor-tip-body">${o}</div></div>`;
|
|
7959
7965
|
};
|
|
7960
7966
|
}
|
|
7961
|
-
function
|
|
7967
|
+
function Fi(n) {
|
|
7962
7968
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
7963
7969
|
}
|
|
7964
|
-
function
|
|
7970
|
+
function zi(n) {
|
|
7965
7971
|
const e = n.renderer.rules.list_item_open;
|
|
7966
|
-
n.renderer.rules.list_item_open = (t, i,
|
|
7972
|
+
n.renderer.rules.list_item_open = (t, i, r, a, s) => {
|
|
7967
7973
|
var l, d;
|
|
7968
7974
|
const o = t[i];
|
|
7969
7975
|
if (!o)
|
|
7970
|
-
return e ? e(t, i,
|
|
7976
|
+
return e ? e(t, i, r, a, s) : s.renderToken(t, i, r);
|
|
7971
7977
|
let c;
|
|
7972
|
-
for (let
|
|
7973
|
-
if (((l = t[
|
|
7974
|
-
c = t[
|
|
7978
|
+
for (let h = i + 1; h < t.length && h < i + 6; h++) {
|
|
7979
|
+
if (((l = t[h]) == null ? void 0 : l.type) === "inline") {
|
|
7980
|
+
c = t[h];
|
|
7975
7981
|
break;
|
|
7976
7982
|
}
|
|
7977
|
-
if (((d = t[
|
|
7983
|
+
if (((d = t[h]) == null ? void 0 : d.type) === "list_item_close") break;
|
|
7978
7984
|
}
|
|
7979
7985
|
if (c && c.content) {
|
|
7980
|
-
const
|
|
7986
|
+
const h = c.content, p = /^\[\s*\]\s/.test(h), m = /^\[\s*[xX]\s*\]\s/.test(h);
|
|
7981
7987
|
if (p || m) {
|
|
7982
|
-
const
|
|
7983
|
-
if (c.content =
|
|
7984
|
-
const
|
|
7985
|
-
|
|
7988
|
+
const b = /^\[\s*(?:[xX])?\s*\]\s/;
|
|
7989
|
+
if (c.content = h.replace(b, ""), c.children && c.children.length > 0) {
|
|
7990
|
+
const S = c.children[0];
|
|
7991
|
+
S && S.type === "text" && (S.content = S.content.replace(b, ""));
|
|
7986
7992
|
}
|
|
7987
7993
|
o.attrSet("class", "task-list-item");
|
|
7988
|
-
const
|
|
7989
|
-
return (e ? e(t, i,
|
|
7994
|
+
const E = `<input type="checkbox" disabled${p ? " checked" : ""} /> `;
|
|
7995
|
+
return (e ? e(t, i, r, a, s) : s.renderToken(t, i, r)) + E;
|
|
7990
7996
|
}
|
|
7991
7997
|
}
|
|
7992
|
-
return e ? e(t, i,
|
|
7998
|
+
return e ? e(t, i, r, a, s) : s.renderToken(t, i, r);
|
|
7993
7999
|
};
|
|
7994
8000
|
}
|
|
7995
8001
|
class It {
|
|
@@ -7999,9 +8005,9 @@ class It {
|
|
|
7999
8005
|
linkify: !0,
|
|
8000
8006
|
breaks: e.breaks ?? !1,
|
|
8001
8007
|
typographer: !0
|
|
8002
|
-
}), e.math !== !1 &&
|
|
8008
|
+
}), e.math !== !1 && an(this.md), this.mindmapEnabled = e.mindmap !== !1, this.mindmapEnabled && cn(this.md), e.codeHighlight !== !1 && xi(this.md, {
|
|
8003
8009
|
reservedLanguages: this.mindmapEnabled ? ["mindmap"] : []
|
|
8004
|
-
}), e.tips !== !1 &&
|
|
8010
|
+
}), e.tips !== !1 && Hi(this.md), zi(this.md), nn(this.md), Vt(this.md), Di(this.md);
|
|
8005
8011
|
}
|
|
8006
8012
|
render(e) {
|
|
8007
8013
|
return this.md.render(e || "");
|
|
@@ -8011,22 +8017,26 @@ class It {
|
|
|
8011
8017
|
* mindmap placeholders into real SVG diagrams.
|
|
8012
8018
|
*/
|
|
8013
8019
|
async hydrate(e) {
|
|
8014
|
-
this.mindmapEnabled
|
|
8020
|
+
if (this.mindmapEnabled)
|
|
8021
|
+
try {
|
|
8022
|
+
await un(e);
|
|
8023
|
+
} catch {
|
|
8024
|
+
}
|
|
8015
8025
|
}
|
|
8016
8026
|
}
|
|
8017
|
-
function
|
|
8027
|
+
function dr(n, e = {}) {
|
|
8018
8028
|
return new It(e).render(n);
|
|
8019
8029
|
}
|
|
8020
|
-
class
|
|
8030
|
+
class Ki {
|
|
8021
8031
|
constructor(e) {
|
|
8022
8032
|
this.buttons = /* @__PURE__ */ new Map(), this.el = document.createElement("div"), this.el.className = "md-editor-toolbar", this.el.setAttribute("role", "toolbar");
|
|
8023
8033
|
for (const t of e) {
|
|
8024
8034
|
const i = document.createElement("button");
|
|
8025
|
-
if (i.type = "button", i.className = "md-editor-toolbar-btn", t.toggle && i.classList.add("is-toggle"), t.active && i.classList.add("is-active"), i.title = t.title, i.setAttribute("aria-label", t.title), i.setAttribute("data-action", t.name), i.innerHTML = t.icon, i.addEventListener("mousedown", (
|
|
8026
|
-
|
|
8035
|
+
if (i.type = "button", i.className = "md-editor-toolbar-btn", t.toggle && i.classList.add("is-toggle"), t.active && i.classList.add("is-active"), i.title = t.title, i.setAttribute("aria-label", t.title), i.setAttribute("data-action", t.name), i.innerHTML = t.icon, i.addEventListener("mousedown", (r) => {
|
|
8036
|
+
r.preventDefault(), r.stopPropagation(), t.handler(i);
|
|
8027
8037
|
}), this.buttons.set(t.name, i), this.el.appendChild(i), t.groupEnd) {
|
|
8028
|
-
const
|
|
8029
|
-
|
|
8038
|
+
const r = document.createElement("span");
|
|
8039
|
+
r.className = "md-editor-toolbar-sep", this.el.appendChild(r);
|
|
8030
8040
|
}
|
|
8031
8041
|
}
|
|
8032
8042
|
}
|
|
@@ -8051,7 +8061,7 @@ function tt(n) {
|
|
|
8051
8061
|
wordCount: e ? e.split(/\s+/).length : 0
|
|
8052
8062
|
};
|
|
8053
8063
|
}
|
|
8054
|
-
class
|
|
8064
|
+
class Gi {
|
|
8055
8065
|
constructor(e) {
|
|
8056
8066
|
this.el = document.createElement("div"), this.el.className = "md-editor-statusbar", this.countEl = document.createElement("span"), this.blockEl = document.createElement("span"), this.blockEl.className = "md-editor-statusbar-muted", this.refreshBtn = document.createElement("button"), this.refreshBtn.type = "button", this.refreshBtn.className = "md-editor-statusbar-refresh", this.refreshBtn.textContent = "Refresh preview", this.refreshBtn.style.display = "none", this.refreshBtn.addEventListener("click", e.onRefreshPreview), this.el.appendChild(this.countEl), this.el.appendChild(this.blockEl), this.el.appendChild(this.refreshBtn);
|
|
8057
8067
|
}
|
|
@@ -8062,25 +8072,25 @@ class qi {
|
|
|
8062
8072
|
this.refreshBtn.onclick = null, this.el.remove();
|
|
8063
8073
|
}
|
|
8064
8074
|
}
|
|
8065
|
-
const
|
|
8066
|
-
function
|
|
8075
|
+
const qi = /^ {0,3}#{1,6}\s/, Wi = /^ {0,3}(`{3,}|~{3,})(.*)$/, Yi = /^ {0,3}(`{3,}|~{3,})\s*$/, Zi = /^ {0,3}:{3,}\S/, Vi = /^ {0,3}:{3,}\s*$/;
|
|
8076
|
+
function Xi(n) {
|
|
8067
8077
|
let e = 5381;
|
|
8068
8078
|
for (let t = 0; t < n.length; t++)
|
|
8069
8079
|
e = e * 33 ^ n.charCodeAt(t);
|
|
8070
8080
|
return (e >>> 0).toString(36) + ":" + n.length;
|
|
8071
8081
|
}
|
|
8072
|
-
function
|
|
8082
|
+
function Qi(n) {
|
|
8073
8083
|
const e = n.split(`
|
|
8074
8084
|
`), t = [];
|
|
8075
|
-
let i = [],
|
|
8085
|
+
let i = [], r = !1, a = "", s = 0, o = !1;
|
|
8076
8086
|
for (const l of e) {
|
|
8077
|
-
const d = l.match(
|
|
8087
|
+
const d = l.match(Wi);
|
|
8078
8088
|
if (d) {
|
|
8079
|
-
const
|
|
8080
|
-
|
|
8089
|
+
const h = d[1] ?? "", p = h[0] ?? "", m = h.length;
|
|
8090
|
+
r ? p === a && m >= s && Yi.test(l) && (r = !1) : (r = !0, a = p, s = m), i.push(l);
|
|
8081
8091
|
continue;
|
|
8082
8092
|
}
|
|
8083
|
-
if (
|
|
8093
|
+
if (r || (!o && Zi.test(l) ? o = !0 : o && Vi.test(l) && (o = !1)), !r && !o && qi.test(l) && i.length > 0) {
|
|
8084
8094
|
t.push(i.join(`
|
|
8085
8095
|
`)), i = [l];
|
|
8086
8096
|
continue;
|
|
@@ -8091,26 +8101,34 @@ function Ji(n) {
|
|
|
8091
8101
|
`)), t.length === 0 && t.push("");
|
|
8092
8102
|
const c = /* @__PURE__ */ new Map();
|
|
8093
8103
|
return t.map((l) => {
|
|
8094
|
-
const d =
|
|
8095
|
-
return c.set(d,
|
|
8104
|
+
const d = Xi(l), h = (c.get(d) ?? 0) + 1;
|
|
8105
|
+
return c.set(d, h), { key: `${d}#${h}`, hash: d, source: l };
|
|
8096
8106
|
});
|
|
8097
8107
|
}
|
|
8098
|
-
class
|
|
8108
|
+
class Ji {
|
|
8099
8109
|
constructor(e, t, i = 800) {
|
|
8100
8110
|
this.container = e, this.renderBlock = t, this.maxCacheEntries = i, this.nodeByKey = /* @__PURE__ */ new Map(), this.htmlByHash = /* @__PURE__ */ new Map(), this.prevBlocks = [];
|
|
8101
8111
|
}
|
|
8102
8112
|
update(e) {
|
|
8103
|
-
const t =
|
|
8113
|
+
const t = Qi(e), i = document.createDocumentFragment(), r = /* @__PURE__ */ new Map();
|
|
8104
8114
|
let a = 0;
|
|
8105
|
-
for (const
|
|
8106
|
-
let o = this.nodeByKey.get(
|
|
8115
|
+
for (const s of t) {
|
|
8116
|
+
let o = this.nodeByKey.get(s.key);
|
|
8107
8117
|
if (!o) {
|
|
8108
|
-
let c = this.htmlByHash.get(
|
|
8109
|
-
c === void 0
|
|
8118
|
+
let c = this.htmlByHash.get(s.hash);
|
|
8119
|
+
if (c === void 0) {
|
|
8120
|
+
try {
|
|
8121
|
+
c = this.renderBlock(s.source);
|
|
8122
|
+
} catch {
|
|
8123
|
+
c = `<pre>${this.escapeHtml(s.source)}</pre>`;
|
|
8124
|
+
}
|
|
8125
|
+
this.htmlByHash.set(s.hash, c), a++;
|
|
8126
|
+
}
|
|
8127
|
+
o = document.createElement("div"), o.className = "md-editor-block", o.dataset.blockKey = s.key, o.innerHTML = c;
|
|
8110
8128
|
}
|
|
8111
|
-
|
|
8129
|
+
r.set(s.key, o), i.appendChild(o);
|
|
8112
8130
|
}
|
|
8113
|
-
return this.container.innerHTML = "", this.container.appendChild(i), this.nodeByKey =
|
|
8131
|
+
return this.container.innerHTML = "", this.container.appendChild(i), this.nodeByKey = r, this.prevBlocks = t, this.evictCacheIfNeeded(t), { rerenderedCount: a, totalCount: t.length };
|
|
8114
8132
|
}
|
|
8115
8133
|
/**
|
|
8116
8134
|
* When the cache exceeds the limit, evict hashes that no longer appear in
|
|
@@ -8126,32 +8144,35 @@ class ji {
|
|
|
8126
8144
|
getBlockCount() {
|
|
8127
8145
|
return this.prevBlocks.length;
|
|
8128
8146
|
}
|
|
8147
|
+
escapeHtml(e) {
|
|
8148
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
8149
|
+
}
|
|
8129
8150
|
destroy() {
|
|
8130
8151
|
this.container.innerHTML = "", this.nodeByKey.clear(), this.htmlByHash.clear(), this.prevBlocks = [];
|
|
8131
8152
|
}
|
|
8132
8153
|
}
|
|
8133
|
-
function
|
|
8154
|
+
function ji(n, e) {
|
|
8134
8155
|
let t, i;
|
|
8135
|
-
const
|
|
8156
|
+
const r = (...a) => {
|
|
8136
8157
|
i = a, t !== void 0 && clearTimeout(t), t = setTimeout(() => {
|
|
8137
8158
|
t = void 0, i && n(...i);
|
|
8138
8159
|
}, e);
|
|
8139
8160
|
};
|
|
8140
|
-
return
|
|
8161
|
+
return r.cancel = () => {
|
|
8141
8162
|
t !== void 0 && clearTimeout(t), t = void 0;
|
|
8142
|
-
},
|
|
8163
|
+
}, r.flush = () => {
|
|
8143
8164
|
t !== void 0 && (clearTimeout(t), t = void 0, i && n(...i));
|
|
8144
|
-
},
|
|
8165
|
+
}, r;
|
|
8145
8166
|
}
|
|
8146
|
-
function
|
|
8147
|
-
const i = Math.max(0, n),
|
|
8148
|
-
return Math.min(t, e +
|
|
8167
|
+
function er(n, e = 120, t = 600) {
|
|
8168
|
+
const i = Math.max(0, n), r = Math.floor(i / 2e4) * 60;
|
|
8169
|
+
return Math.min(t, e + r);
|
|
8149
8170
|
}
|
|
8150
|
-
function
|
|
8171
|
+
function ur(n, e = 300) {
|
|
8151
8172
|
const t = window;
|
|
8152
8173
|
return typeof t.requestIdleCallback == "function" ? t.requestIdleCallback(n, { timeout: e }) : window.setTimeout(n, 0);
|
|
8153
8174
|
}
|
|
8154
|
-
function
|
|
8175
|
+
function hr(n) {
|
|
8155
8176
|
const e = window;
|
|
8156
8177
|
typeof e.cancelIdleCallback == "function" ? e.cancelIdleCallback(n) : clearTimeout(n);
|
|
8157
8178
|
}
|
|
@@ -8233,11 +8254,11 @@ const L = (n) => `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xm
|
|
|
8233
8254
|
'<polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>'
|
|
8234
8255
|
)
|
|
8235
8256
|
};
|
|
8236
|
-
class
|
|
8257
|
+
class Q {
|
|
8237
8258
|
constructor(e, t) {
|
|
8238
8259
|
this.inputs = /* @__PURE__ */ new Map(), this.destroyed = !1, this.anchor = e, this.config = t, this.el = document.createElement("div"), this.el.className = "md-editor-popup", this.el.setAttribute("role", "dialog"), this.el.setAttribute("aria-label", t.title), t.theme && this.el.setAttribute("data-theme", t.theme), this.build(), this.onOutsideClick = (i) => {
|
|
8239
|
-
const
|
|
8240
|
-
!this.el.contains(
|
|
8260
|
+
const r = i.target;
|
|
8261
|
+
!this.el.contains(r) && !this.anchor.contains(r) && this.hide();
|
|
8241
8262
|
}, this.onKeyDown = (i) => {
|
|
8242
8263
|
i.key === "Escape" && this.hide();
|
|
8243
8264
|
};
|
|
@@ -8247,22 +8268,22 @@ class ie {
|
|
|
8247
8268
|
e.className = "md-editor-popup-header", e.textContent = this.config.title;
|
|
8248
8269
|
const t = document.createElement("div");
|
|
8249
8270
|
t.className = "md-editor-popup-body";
|
|
8250
|
-
for (const
|
|
8271
|
+
for (const s of this.config.fields) {
|
|
8251
8272
|
const o = document.createElement("div");
|
|
8252
8273
|
o.className = "md-editor-popup-field";
|
|
8253
8274
|
const c = document.createElement("label");
|
|
8254
|
-
c.className = "md-editor-popup-label", c.textContent =
|
|
8275
|
+
c.className = "md-editor-popup-label", c.textContent = s.label, c.setAttribute("for", `md-editor-popup-${s.name}`);
|
|
8255
8276
|
let l;
|
|
8256
|
-
|
|
8277
|
+
s.type === "textarea" ? (l = document.createElement("textarea"), l.rows = 2) : (l = document.createElement("input"), l.type = "text"), l.id = `md-editor-popup-${s.name}`, l.className = "md-editor-popup-input", s.placeholder && (l.placeholder = s.placeholder), s.required && (l.required = !0), o.appendChild(c), o.appendChild(l), t.appendChild(o), this.inputs.set(s.name, l);
|
|
8257
8278
|
}
|
|
8258
8279
|
const i = document.createElement("div");
|
|
8259
8280
|
i.className = "md-editor-popup-footer";
|
|
8260
|
-
const
|
|
8261
|
-
|
|
8281
|
+
const r = document.createElement("button");
|
|
8282
|
+
r.type = "button", r.className = "md-editor-popup-btn md-editor-popup-btn--ghost", r.textContent = "Cancel", r.addEventListener("click", () => this.hide());
|
|
8262
8283
|
const a = document.createElement("button");
|
|
8263
|
-
a.type = "button", a.className = "md-editor-popup-btn md-editor-popup-btn--primary", a.textContent = this.config.submitLabel ?? "Insert", a.addEventListener("click", () => this.submit()), i.appendChild(
|
|
8264
|
-
for (const
|
|
8265
|
-
|
|
8284
|
+
a.type = "button", a.className = "md-editor-popup-btn md-editor-popup-btn--primary", a.textContent = this.config.submitLabel ?? "Insert", a.addEventListener("click", () => this.submit()), i.appendChild(r), i.appendChild(a), this.el.appendChild(e), this.el.appendChild(t), this.el.appendChild(i);
|
|
8285
|
+
for (const s of this.inputs.values())
|
|
8286
|
+
s.tagName === "INPUT" && s.addEventListener("keydown", (o) => {
|
|
8266
8287
|
const c = o;
|
|
8267
8288
|
c.key === "Enter" && (c.preventDefault(), this.submit());
|
|
8268
8289
|
});
|
|
@@ -8285,14 +8306,14 @@ class ie {
|
|
|
8285
8306
|
position() {
|
|
8286
8307
|
const e = this.anchor.getBoundingClientRect(), t = this.el.getBoundingClientRect();
|
|
8287
8308
|
let i = e.left;
|
|
8288
|
-
const
|
|
8289
|
-
i + t.width > window.innerWidth - 8 && (i = window.innerWidth - t.width - 8), i < 8 && (i = 8), this.el.style.left = `${i + window.scrollX}px`, this.el.style.top = `${
|
|
8309
|
+
const r = e.bottom + 6;
|
|
8310
|
+
i + t.width > window.innerWidth - 8 && (i = window.innerWidth - t.width - 8), i < 8 && (i = 8), this.el.style.left = `${i + window.scrollX}px`, this.el.style.top = `${r + window.scrollY}px`;
|
|
8290
8311
|
}
|
|
8291
8312
|
destroy() {
|
|
8292
8313
|
this.hide(), this.destroyed = !0, this.inputs.clear();
|
|
8293
8314
|
}
|
|
8294
8315
|
}
|
|
8295
|
-
const
|
|
8316
|
+
const tr = [
|
|
8296
8317
|
{ action: "bold", key: "Mod-b", description: "Bold" },
|
|
8297
8318
|
{ action: "italic", key: "Mod-i", description: "Italic" },
|
|
8298
8319
|
{ action: "heading", key: "Mod-Alt-1", description: "Heading" },
|
|
@@ -8306,17 +8327,17 @@ const nr = [
|
|
|
8306
8327
|
{ action: "preview", key: "Mod-Alt-p", description: "Toggle preview" },
|
|
8307
8328
|
{ action: "theme", key: "Mod-Shift-l", description: "Toggle theme" }
|
|
8308
8329
|
];
|
|
8309
|
-
function
|
|
8330
|
+
function pr(n, e) {
|
|
8310
8331
|
var c;
|
|
8311
8332
|
const t = n.toLowerCase().split("-");
|
|
8312
|
-
let i = "",
|
|
8333
|
+
let i = "", r = !1, a = !1, s = !1, o = !1;
|
|
8313
8334
|
for (const l of t)
|
|
8314
8335
|
switch (l) {
|
|
8315
8336
|
case "mod":
|
|
8316
|
-
(c = navigator.platform) != null && c.toLowerCase().includes("mac") ? a = !0 :
|
|
8337
|
+
(c = navigator.platform) != null && c.toLowerCase().includes("mac") ? a = !0 : r = !0;
|
|
8317
8338
|
break;
|
|
8318
8339
|
case "ctrl":
|
|
8319
|
-
|
|
8340
|
+
r = !0;
|
|
8320
8341
|
break;
|
|
8321
8342
|
case "meta":
|
|
8322
8343
|
case "cmd":
|
|
@@ -8324,7 +8345,7 @@ function gr(n, e) {
|
|
|
8324
8345
|
break;
|
|
8325
8346
|
case "alt":
|
|
8326
8347
|
case "option":
|
|
8327
|
-
|
|
8348
|
+
s = !0;
|
|
8328
8349
|
break;
|
|
8329
8350
|
case "shift":
|
|
8330
8351
|
o = !0;
|
|
@@ -8332,13 +8353,13 @@ function gr(n, e) {
|
|
|
8332
8353
|
default:
|
|
8333
8354
|
i = l;
|
|
8334
8355
|
}
|
|
8335
|
-
return !(e.ctrlKey !==
|
|
8356
|
+
return !(e.ctrlKey !== r || e.metaKey !== a || e.altKey !== s || e.shiftKey !== o || e.key.toLowerCase() !== i);
|
|
8336
8357
|
}
|
|
8337
|
-
function
|
|
8358
|
+
function gr(n) {
|
|
8338
8359
|
var i;
|
|
8339
8360
|
const e = ((i = navigator.platform) == null ? void 0 : i.toLowerCase().includes("mac")) ?? !1;
|
|
8340
|
-
return n.split("-").map((
|
|
8341
|
-
switch (
|
|
8361
|
+
return n.split("-").map((r) => {
|
|
8362
|
+
switch (r.toLowerCase()) {
|
|
8342
8363
|
case "mod":
|
|
8343
8364
|
return e ? "Cmd" : "Ctrl";
|
|
8344
8365
|
case "ctrl":
|
|
@@ -8351,36 +8372,36 @@ function mr(n) {
|
|
|
8351
8372
|
case "shift":
|
|
8352
8373
|
return "Shift";
|
|
8353
8374
|
default:
|
|
8354
|
-
return
|
|
8375
|
+
return r.toUpperCase();
|
|
8355
8376
|
}
|
|
8356
8377
|
}).join("+");
|
|
8357
8378
|
}
|
|
8358
|
-
function
|
|
8379
|
+
function nr(n) {
|
|
8359
8380
|
var i;
|
|
8360
8381
|
const e = ((i = navigator.platform) == null ? void 0 : i.toLowerCase().includes("mac")) ?? !1;
|
|
8361
|
-
return n.split("-").map((
|
|
8362
|
-
let a =
|
|
8363
|
-
switch (
|
|
8382
|
+
return n.split("-").map((r) => {
|
|
8383
|
+
let a = r, s = "";
|
|
8384
|
+
switch (r.toLowerCase()) {
|
|
8364
8385
|
case "mod":
|
|
8365
|
-
a = e ? "Cmd" : "Ctrl",
|
|
8386
|
+
a = e ? "Cmd" : "Ctrl", s = e ? "⌘" : "";
|
|
8366
8387
|
break;
|
|
8367
8388
|
case "ctrl":
|
|
8368
|
-
a = "Ctrl",
|
|
8389
|
+
a = "Ctrl", s = e ? "⌃" : "";
|
|
8369
8390
|
break;
|
|
8370
8391
|
case "meta":
|
|
8371
8392
|
case "cmd":
|
|
8372
|
-
a = "Cmd",
|
|
8393
|
+
a = "Cmd", s = "⌘";
|
|
8373
8394
|
break;
|
|
8374
8395
|
case "alt":
|
|
8375
|
-
a = e ? "Option" : "Alt",
|
|
8396
|
+
a = e ? "Option" : "Alt", s = e ? "⌥" : "";
|
|
8376
8397
|
break;
|
|
8377
8398
|
case "shift":
|
|
8378
|
-
a = "Shift",
|
|
8399
|
+
a = "Shift", s = "⇧";
|
|
8379
8400
|
break;
|
|
8380
8401
|
default:
|
|
8381
|
-
a =
|
|
8402
|
+
a = r.toUpperCase();
|
|
8382
8403
|
}
|
|
8383
|
-
return `<kbd class="md-editor-kbd">${
|
|
8404
|
+
return `<kbd class="md-editor-kbd">${s ? `<span class="md-editor-kbd-symbol">${s}</span>` : ""}<span>${a}</span></kbd>`;
|
|
8384
8405
|
}).join('<span class="md-editor-kbd-plus">+</span>');
|
|
8385
8406
|
}
|
|
8386
8407
|
const nt = {
|
|
@@ -8410,29 +8431,29 @@ const nt = {
|
|
|
8410
8431
|
---
|
|
8411
8432
|
`, "", ""]
|
|
8412
8433
|
};
|
|
8413
|
-
class
|
|
8434
|
+
class mr {
|
|
8414
8435
|
constructor(e, t = {}) {
|
|
8415
8436
|
this.previewPane = null, this.incremental = null, this.toolbar = null, this.statusBar = null, this.activePopup = null, this.scheduledRender = null, this.scheduledWait = 0;
|
|
8416
8437
|
const i = typeof e == "string" ? document.querySelector(e) : e;
|
|
8417
8438
|
if (!i) throw new Error("MarkdownEditor: mount container not found");
|
|
8418
|
-
this.container = i, this.mode = t.mode ?? "simple", this.theme = t.theme ?? "light", this.showPreview = t.preview ?? !0, this.autoPreview = t.autoPreview ?? !0, this.renderDebounceOpt = t.renderDebounce, this.onChange = t.onChange, this.onImageUpload = t.onImageUpload, this.toolbarConfig = t.toolbar, this.shortcuts =
|
|
8439
|
+
this.container = i, this.mode = t.mode ?? "simple", this.theme = t.theme ?? "light", this.showPreview = t.preview ?? !0, this.autoPreview = t.autoPreview ?? !0, this.renderDebounceOpt = t.renderDebounce, this.onChange = t.onChange, this.onImageUpload = t.onImageUpload, this.toolbarConfig = t.toolbar, this.shortcuts = tr, this.container.classList.add("md-editor-root", `md-editor-mode-${this.mode}`), this.container.setAttribute("data-theme", this.theme), this.renderer = new It({
|
|
8419
8440
|
math: t.math ?? !0,
|
|
8420
8441
|
mindmap: t.mindmap ?? !0,
|
|
8421
8442
|
codeHighlight: t.codeHighlight ?? !0,
|
|
8422
8443
|
tips: t.tips ?? !0
|
|
8423
|
-
}), this.buildLayout(), this.codeEditor = new
|
|
8444
|
+
}), this.buildLayout(), this.codeEditor = new rn(this.editorPane, {
|
|
8424
8445
|
value: t.value ?? "",
|
|
8425
8446
|
lineNumbers: this.mode === "complex",
|
|
8426
|
-
onChange: (
|
|
8447
|
+
onChange: (r) => {
|
|
8427
8448
|
var a;
|
|
8428
|
-
(a = this.onChange) == null || a.call(this,
|
|
8449
|
+
(a = this.onChange) == null || a.call(this, r), this.autoPreview && this.requestPreviewRender(r), this.updateStatusBar(r);
|
|
8429
8450
|
},
|
|
8430
|
-
onImageFile: (
|
|
8451
|
+
onImageFile: (r) => this.handleImageFile(r),
|
|
8431
8452
|
mention: t.mention,
|
|
8432
8453
|
docLink: t.docLink
|
|
8433
|
-
}), this.setupKeyboardShortcuts(), this.mode === "complex" && (this.buildToolbar(), this.buildStatusBar()), this.previewPane && (this.previewPane.classList.add("markdown-body"), this.incremental = new
|
|
8454
|
+
}), this.setupKeyboardShortcuts(), this.mode === "complex" && (this.buildToolbar(), this.buildStatusBar()), this.previewPane && (this.previewPane.classList.add("markdown-body"), this.incremental = new Ji(
|
|
8434
8455
|
this.previewPane,
|
|
8435
|
-
(
|
|
8456
|
+
(r) => this.renderer.render(r)
|
|
8436
8457
|
), this.setupCopyHandler()), this.renderPreview(t.value ?? ""), this.updateStatusBar(t.value ?? "");
|
|
8437
8458
|
}
|
|
8438
8459
|
// ---------- Layout ----------
|
|
@@ -8453,16 +8474,16 @@ class fr {
|
|
|
8453
8474
|
return this.toolbarConfig && !Array.isArray(this.toolbarConfig) ? ((i = this.toolbarConfig[e]) == null ? void 0 : i.icon) ?? t : t;
|
|
8454
8475
|
}
|
|
8455
8476
|
buildToolbar() {
|
|
8456
|
-
const e = [], t = (i,
|
|
8477
|
+
const e = [], t = (i, r, a, s, o = {}) => {
|
|
8457
8478
|
this.isActionVisible(i) && e.push({
|
|
8458
8479
|
name: i,
|
|
8459
|
-
title: this.getActionLabel(i,
|
|
8480
|
+
title: this.getActionLabel(i, r),
|
|
8460
8481
|
icon: this.getActionIcon(i, a),
|
|
8461
|
-
handler:
|
|
8482
|
+
handler: s,
|
|
8462
8483
|
...o
|
|
8463
8484
|
});
|
|
8464
8485
|
};
|
|
8465
|
-
t("heading", "Heading", R.heading, () => this.insertSnippet("heading")), t("bold", "Bold (Ctrl+B)", R.bold, () => this.wrapSnippet("bold")), t("italic", "Italic (Ctrl+I)", R.italic, () => this.wrapSnippet("italic"), { groupEnd: !0 }), t("link", "Link (Ctrl+K)", R.link, () => this.wrapSnippet("link")), t("image", "Insert image", R.image, (i) => this.showImagePopup(i)), t("video", "Insert video", R.video, (i) => this.showVideoPopup(i), { groupEnd: !0 }), t("youtube", "Insert YouTube video", R.youtube, (i) => this.showYouTubePopup(i), { groupEnd: !0 }), t("quote", "Quote", R.quote, () => this.codeEditor.wrapLines("> ", "quoted text")), t("ul", "Unordered list", R.list, () => this.codeEditor.wrapLines("- ", "list item")), t("ol", "Ordered list", R.listOrdered, () => this.codeEditor.wrapLines("1. ", "list item")), t("tasklist", "Task list", R.taskList, () => this.codeEditor.toggleTaskList(), { groupEnd: !0 }), t("mention", "Mention (@)", R.mention, () => this.codeEditor.insertMention()), t("doclink", "Insert document link", R.fileText, () => this.codeEditor.insertDocLink()), t("code", "Code block", R.code, () => this.insertSnippet("code")), t("table", "Table", R.table, (i) => this.showTablePopup(i), { groupEnd: !0 }), t("math", "Math formula", R.sigma, () => this.
|
|
8486
|
+
t("heading", "Heading", R.heading, () => this.insertSnippet("heading")), t("bold", "Bold (Ctrl+B)", R.bold, () => this.wrapSnippet("bold")), t("italic", "Italic (Ctrl+I)", R.italic, () => this.wrapSnippet("italic"), { groupEnd: !0 }), t("link", "Link (Ctrl+K)", R.link, () => this.wrapSnippet("link")), t("image", "Insert image", R.image, (i) => this.showImagePopup(i)), t("video", "Insert video", R.video, (i) => this.showVideoPopup(i), { groupEnd: !0 }), t("youtube", "Insert YouTube video", R.youtube, (i) => this.showYouTubePopup(i), { groupEnd: !0 }), t("quote", "Quote", R.quote, () => this.codeEditor.wrapLines("> ", "quoted text")), t("ul", "Unordered list", R.list, () => this.codeEditor.wrapLines("- ", "list item")), t("ol", "Ordered list", R.listOrdered, () => this.codeEditor.wrapLines("1. ", "list item")), t("tasklist", "Task list", R.taskList, () => this.codeEditor.toggleTaskList(), { groupEnd: !0 }), t("mention", "Mention (@)", R.mention, () => this.codeEditor.insertMention()), t("doclink", "Insert document link", R.fileText, () => this.codeEditor.insertDocLink()), t("code", "Code block", R.code, () => this.insertSnippet("code")), t("table", "Table", R.table, (i) => this.showTablePopup(i), { groupEnd: !0 }), t("math", "Math formula", R.sigma, (i) => this.showMathPopup(i), { groupEnd: !0 }), t("mindmap", "Insert mindmap", R.mindmap, (i) => this.showMindmapPopup(i)), t("hr", "Horizontal rule", R.hr, () => this.insertSnippet("hr")), t("tips", "Insert callout", R.alert, (i) => this.showTipsPopup(i), { groupEnd: !0 }), t("preview", "Toggle preview", R.eye, () => this.togglePreview(), {
|
|
8466
8487
|
toggle: !0,
|
|
8467
8488
|
active: this.showPreview
|
|
8468
8489
|
}), t("help", "Keyboard shortcuts", R.help, (i) => this.showHelpPopup(i)), t(
|
|
@@ -8470,10 +8491,10 @@ class fr {
|
|
|
8470
8491
|
"Toggle theme",
|
|
8471
8492
|
this.theme === "dark" ? R.sun : R.moon,
|
|
8472
8493
|
() => this.setTheme(this.theme === "dark" ? "light" : "dark")
|
|
8473
|
-
), this.toolbar = new
|
|
8494
|
+
), this.toolbar = new Ki(e), this.container.insertBefore(this.toolbar.el, this.body);
|
|
8474
8495
|
}
|
|
8475
8496
|
buildStatusBar() {
|
|
8476
|
-
this.statusBar = new
|
|
8497
|
+
this.statusBar = new Gi({
|
|
8477
8498
|
onRefreshPreview: () => this.renderPreview(this.codeEditor.getValue())
|
|
8478
8499
|
}), this.container.appendChild(this.statusBar.el);
|
|
8479
8500
|
}
|
|
@@ -8530,22 +8551,22 @@ class fr {
|
|
|
8530
8551
|
var i;
|
|
8531
8552
|
(i = this.activePopup) == null || i.destroy();
|
|
8532
8553
|
const t = typeof this.onImageUpload == "function";
|
|
8533
|
-
this.activePopup = new
|
|
8554
|
+
this.activePopup = new Q(e, {
|
|
8534
8555
|
title: "Insert image",
|
|
8535
8556
|
theme: this.theme,
|
|
8536
8557
|
fields: [
|
|
8537
8558
|
{ name: "url", label: "Image URL", placeholder: "https://example.com/image.png" },
|
|
8538
8559
|
...t ? [{ name: "file", label: "Or paste/drop an image into the editor", type: "text", placeholder: "Upload via paste or drag-and-drop" }] : []
|
|
8539
8560
|
],
|
|
8540
|
-
onSubmit: (
|
|
8541
|
-
const a =
|
|
8561
|
+
onSubmit: (r) => {
|
|
8562
|
+
const a = r.url ?? "";
|
|
8542
8563
|
a && this.codeEditor.insertAtCursor(je(a, "image"));
|
|
8543
8564
|
}
|
|
8544
8565
|
}), this.activePopup.show();
|
|
8545
8566
|
}
|
|
8546
8567
|
showVideoPopup(e) {
|
|
8547
8568
|
var t;
|
|
8548
|
-
(t = this.activePopup) == null || t.destroy(), this.activePopup = new
|
|
8569
|
+
(t = this.activePopup) == null || t.destroy(), this.activePopup = new Q(e, {
|
|
8549
8570
|
title: "Insert video",
|
|
8550
8571
|
theme: this.theme,
|
|
8551
8572
|
fields: [
|
|
@@ -8553,14 +8574,14 @@ class fr {
|
|
|
8553
8574
|
{ name: "alt", label: "Title", placeholder: "video title" }
|
|
8554
8575
|
],
|
|
8555
8576
|
onSubmit: (i) => {
|
|
8556
|
-
const
|
|
8557
|
-
|
|
8577
|
+
const r = i.url ?? "";
|
|
8578
|
+
r && this.codeEditor.insertAtCursor(Li(r, i.alt || "video"));
|
|
8558
8579
|
}
|
|
8559
8580
|
}), this.activePopup.show();
|
|
8560
8581
|
}
|
|
8561
8582
|
showYouTubePopup(e) {
|
|
8562
8583
|
var t;
|
|
8563
|
-
(t = this.activePopup) == null || t.destroy(), this.activePopup = new
|
|
8584
|
+
(t = this.activePopup) == null || t.destroy(), this.activePopup = new Q(e, {
|
|
8564
8585
|
title: "Insert YouTube video",
|
|
8565
8586
|
theme: this.theme,
|
|
8566
8587
|
fields: [
|
|
@@ -8572,14 +8593,14 @@ class fr {
|
|
|
8572
8593
|
}
|
|
8573
8594
|
],
|
|
8574
8595
|
onSubmit: (i) => {
|
|
8575
|
-
const
|
|
8576
|
-
a && this.codeEditor.insertAtCursor(
|
|
8596
|
+
const r = i.url ?? "", a = Ri(r);
|
|
8597
|
+
a && this.codeEditor.insertAtCursor(Oi(a));
|
|
8577
8598
|
}
|
|
8578
8599
|
}), this.activePopup.show();
|
|
8579
8600
|
}
|
|
8580
8601
|
showTablePopup(e) {
|
|
8581
8602
|
var t;
|
|
8582
|
-
(t = this.activePopup) == null || t.destroy(), this.activePopup = new
|
|
8603
|
+
(t = this.activePopup) == null || t.destroy(), this.activePopup = new Q(e, {
|
|
8583
8604
|
title: "Insert table",
|
|
8584
8605
|
theme: this.theme,
|
|
8585
8606
|
fields: [
|
|
@@ -8588,28 +8609,28 @@ class fr {
|
|
|
8588
8609
|
],
|
|
8589
8610
|
submitLabel: "Insert",
|
|
8590
8611
|
onSubmit: (i) => {
|
|
8591
|
-
const
|
|
8592
|
-
this.codeEditor.insertAtCursor(this.generateTable(
|
|
8612
|
+
const r = Math.max(1, Math.min(50, parseInt(i.rows ?? "3", 10) || 3)), a = Math.max(1, Math.min(20, parseInt(i.cols ?? "3", 10) || 3));
|
|
8613
|
+
this.codeEditor.insertAtCursor(this.generateTable(r, a));
|
|
8593
8614
|
}
|
|
8594
8615
|
}), this.activePopup.show();
|
|
8595
8616
|
}
|
|
8596
8617
|
generateTable(e, t) {
|
|
8597
|
-
const i = "| " + Array.from({ length: t }, (o, c) => `Col ${c + 1}`).join(" | ") + " |",
|
|
8618
|
+
const i = "| " + Array.from({ length: t }, (o, c) => `Col ${c + 1}`).join(" | ") + " |", r = "| " + Array.from({ length: t }, () => "---").join(" | ") + " |", a = Math.max(0, e - 1), s = Array.from(
|
|
8598
8619
|
{ length: a },
|
|
8599
8620
|
() => "| " + Array.from({ length: t }, () => "content").join(" | ") + " |"
|
|
8600
8621
|
).join(`
|
|
8601
8622
|
`);
|
|
8602
8623
|
return a > 0 ? `${i}
|
|
8603
|
-
${s}
|
|
8604
8624
|
${r}
|
|
8605
|
-
` : `${i}
|
|
8606
8625
|
${s}
|
|
8626
|
+
` : `${i}
|
|
8627
|
+
${r}
|
|
8607
8628
|
`;
|
|
8608
8629
|
}
|
|
8609
8630
|
showHelpPopup(e) {
|
|
8610
8631
|
var a;
|
|
8611
8632
|
(a = this.activePopup) == null || a.destroy();
|
|
8612
|
-
const t = new
|
|
8633
|
+
const t = new Q(e, {
|
|
8613
8634
|
title: "Keyboard Shortcuts",
|
|
8614
8635
|
theme: this.theme,
|
|
8615
8636
|
fields: [],
|
|
@@ -8617,7 +8638,7 @@ ${s}
|
|
|
8617
8638
|
}
|
|
8618
8639
|
}), i = t.el.querySelector(".md-editor-popup-body");
|
|
8619
8640
|
if (i) {
|
|
8620
|
-
const
|
|
8641
|
+
const s = [
|
|
8621
8642
|
{ label: "Task list", hint: "- [ ] checked / - [x] unchecked" },
|
|
8622
8643
|
{ label: "@mention", hint: "Type @ then pick a user from the dropdown" },
|
|
8623
8644
|
{ label: "Document link", hint: "Type / then pick a document" },
|
|
@@ -8628,17 +8649,17 @@ ${s}
|
|
|
8628
8649
|
i.innerHTML = '<div class="md-editor-help-list">' + this.shortcuts.map(
|
|
8629
8650
|
(o) => `<div class="md-editor-help-row">
|
|
8630
8651
|
<span class="md-editor-help-desc">${o.description}</span>
|
|
8631
|
-
<span class="md-editor-help-keys">${
|
|
8652
|
+
<span class="md-editor-help-keys">${nr(o.key)}</span>
|
|
8632
8653
|
</div>`
|
|
8633
|
-
).join("") + '</div><div class="md-editor-help-section-title">Syntax</div><div class="md-editor-help-list">' +
|
|
8654
|
+
).join("") + '</div><div class="md-editor-help-section-title">Syntax</div><div class="md-editor-help-list">' + s.map(
|
|
8634
8655
|
(o) => `<div class="md-editor-help-row">
|
|
8635
8656
|
<span class="md-editor-help-desc">${o.label}</span>
|
|
8636
8657
|
<span class="md-editor-help-syntax">${o.hint}</span>
|
|
8637
8658
|
</div>`
|
|
8638
8659
|
).join("") + "</div>";
|
|
8639
8660
|
}
|
|
8640
|
-
const
|
|
8641
|
-
|
|
8661
|
+
const r = t.el.querySelector(".md-editor-popup-footer");
|
|
8662
|
+
r && r.remove(), this.activePopup = t, this.activePopup.show();
|
|
8642
8663
|
}
|
|
8643
8664
|
// ---------- Image upload ----------
|
|
8644
8665
|
async handleImageFile(e) {
|
|
@@ -8651,8 +8672,8 @@ ${s}
|
|
|
8651
8672
|
}
|
|
8652
8673
|
// ---------- Tips / callout dropdown ----------
|
|
8653
8674
|
showTipsPopup(e) {
|
|
8654
|
-
var
|
|
8655
|
-
(
|
|
8675
|
+
var s;
|
|
8676
|
+
(s = this.activePopup) == null || s.destroy();
|
|
8656
8677
|
const t = [
|
|
8657
8678
|
{ key: "notice", label: "Notice", color: "#0969da" },
|
|
8658
8679
|
{ key: "info", label: "Info", color: "#0969da" },
|
|
@@ -8660,14 +8681,14 @@ ${s}
|
|
|
8660
8681
|
{ key: "success", label: "Success", color: "#1a7f37" },
|
|
8661
8682
|
{ key: "warning", label: "Warning", color: "#9a6700" },
|
|
8662
8683
|
{ key: "danger", label: "Danger", color: "#cf222e" }
|
|
8663
|
-
], i = new
|
|
8684
|
+
], i = new Q(e, {
|
|
8664
8685
|
title: "Insert callout",
|
|
8665
8686
|
theme: this.theme,
|
|
8666
8687
|
fields: [],
|
|
8667
8688
|
onSubmit: () => {
|
|
8668
8689
|
}
|
|
8669
|
-
}),
|
|
8670
|
-
if (
|
|
8690
|
+
}), r = i.el.querySelector(".md-editor-popup-body");
|
|
8691
|
+
if (r) {
|
|
8671
8692
|
const o = document.createElement("div");
|
|
8672
8693
|
o.className = "md-editor-tips-grid";
|
|
8673
8694
|
for (const c of t) {
|
|
@@ -8683,7 +8704,140 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8683
8704
|
), i.hide();
|
|
8684
8705
|
}), o.appendChild(l);
|
|
8685
8706
|
}
|
|
8686
|
-
|
|
8707
|
+
r.innerHTML = "", r.appendChild(o);
|
|
8708
|
+
}
|
|
8709
|
+
const a = i.el.querySelector(".md-editor-popup-footer");
|
|
8710
|
+
a && a.remove(), this.activePopup = i, this.activePopup.show();
|
|
8711
|
+
}
|
|
8712
|
+
// ---------- Math formula template dropdown ----------
|
|
8713
|
+
showMathPopup(e) {
|
|
8714
|
+
var s;
|
|
8715
|
+
(s = this.activePopup) == null || s.destroy();
|
|
8716
|
+
const t = [
|
|
8717
|
+
{ label: "Inline formula", snippet: "$E=mc^2$", hint: "Inline $...$" },
|
|
8718
|
+
{ label: "Block formula", snippet: `$$
|
|
8719
|
+
E = mc^2
|
|
8720
|
+
$$
|
|
8721
|
+
`, hint: "Block $$...$$" },
|
|
8722
|
+
{ label: "Fraction", snippet: "$\\frac{a}{b}$", hint: "\\frac{a}{b}" },
|
|
8723
|
+
{ label: "Square root", snippet: "$\\sqrt{x}$", hint: "\\sqrt{x}" },
|
|
8724
|
+
{ label: "Sum", snippet: "$\\sum_{i=1}^{n} i$", hint: "\\sum_{i=1}^{n}" },
|
|
8725
|
+
{ label: "Integral", snippet: "$\\int_{a}^{b} f(x)\\,dx$", hint: "\\int_{a}^{b}" },
|
|
8726
|
+
{ label: "Limit", snippet: "$\\lim_{x \\to \\infty} f(x)$", hint: "\\lim_{x \\to \\infty}" },
|
|
8727
|
+
{ label: "Matrix", snippet: `$$
|
|
8728
|
+
\\begin{pmatrix}
|
|
8729
|
+
a & b \\\\
|
|
8730
|
+
c & d
|
|
8731
|
+
\\end{pmatrix}
|
|
8732
|
+
$$
|
|
8733
|
+
`, hint: "pmatrix 2x2" }
|
|
8734
|
+
], i = new Q(e, {
|
|
8735
|
+
title: "Insert math formula",
|
|
8736
|
+
theme: this.theme,
|
|
8737
|
+
fields: [],
|
|
8738
|
+
onSubmit: () => {
|
|
8739
|
+
}
|
|
8740
|
+
}), r = i.el.querySelector(".md-editor-popup-body");
|
|
8741
|
+
if (r) {
|
|
8742
|
+
const o = document.createElement("div");
|
|
8743
|
+
o.className = "md-editor-template-grid";
|
|
8744
|
+
for (const c of t) {
|
|
8745
|
+
const l = document.createElement("button");
|
|
8746
|
+
l.type = "button", l.className = "md-editor-template-option", l.innerHTML = `<span class="md-editor-template-label">${c.label}</span><span class="md-editor-template-hint">${c.hint}</span>`, l.addEventListener("click", () => {
|
|
8747
|
+
this.codeEditor.insertAtCursor(c.snippet), i.hide();
|
|
8748
|
+
}), o.appendChild(l);
|
|
8749
|
+
}
|
|
8750
|
+
r.innerHTML = "", r.appendChild(o);
|
|
8751
|
+
}
|
|
8752
|
+
const a = i.el.querySelector(".md-editor-popup-footer");
|
|
8753
|
+
a && a.remove(), this.activePopup = i, this.activePopup.show();
|
|
8754
|
+
}
|
|
8755
|
+
// ---------- Mindmap template dropdown ----------
|
|
8756
|
+
showMindmapPopup(e) {
|
|
8757
|
+
var s;
|
|
8758
|
+
(s = this.activePopup) == null || s.destroy();
|
|
8759
|
+
const t = [
|
|
8760
|
+
{
|
|
8761
|
+
label: "Simple",
|
|
8762
|
+
hint: "Root with two branches",
|
|
8763
|
+
snippet: "```mindmap\n# Root topic\n## Branch one\n## Branch two\n```\n"
|
|
8764
|
+
},
|
|
8765
|
+
{
|
|
8766
|
+
label: "Multi-level",
|
|
8767
|
+
hint: "Root, branches, sub-branches",
|
|
8768
|
+
snippet: `\`\`\`mindmap
|
|
8769
|
+
# Root
|
|
8770
|
+
## Branch one
|
|
8771
|
+
### Sub-branch A
|
|
8772
|
+
### Sub-branch B
|
|
8773
|
+
## Branch two
|
|
8774
|
+
### Sub-branch C
|
|
8775
|
+
\`\`\`
|
|
8776
|
+
`
|
|
8777
|
+
},
|
|
8778
|
+
{
|
|
8779
|
+
label: "With list items",
|
|
8780
|
+
hint: "Branches with bullet children",
|
|
8781
|
+
snippet: `\`\`\`mindmap
|
|
8782
|
+
# Root topic
|
|
8783
|
+
## Branch one
|
|
8784
|
+
- Child A
|
|
8785
|
+
- Child B
|
|
8786
|
+
## Branch two
|
|
8787
|
+
- Child C
|
|
8788
|
+
- Child D
|
|
8789
|
+
\`\`\`
|
|
8790
|
+
`
|
|
8791
|
+
},
|
|
8792
|
+
{
|
|
8793
|
+
label: "Org chart",
|
|
8794
|
+
hint: "CEO -> Departments -> Teams",
|
|
8795
|
+
snippet: `\`\`\`mindmap
|
|
8796
|
+
# CEO
|
|
8797
|
+
## Engineering
|
|
8798
|
+
### Frontend
|
|
8799
|
+
### Backend
|
|
8800
|
+
## Marketing
|
|
8801
|
+
### Content
|
|
8802
|
+
### Ads
|
|
8803
|
+
## Operations
|
|
8804
|
+
\`\`\`
|
|
8805
|
+
`
|
|
8806
|
+
},
|
|
8807
|
+
{
|
|
8808
|
+
label: "Project plan",
|
|
8809
|
+
hint: "Phases with tasks",
|
|
8810
|
+
snippet: `\`\`\`mindmap
|
|
8811
|
+
# Project
|
|
8812
|
+
## Phase 1: Design
|
|
8813
|
+
- Research
|
|
8814
|
+
- Wireframes
|
|
8815
|
+
## Phase 2: Build
|
|
8816
|
+
- Frontend
|
|
8817
|
+
- Backend
|
|
8818
|
+
## Phase 3: Launch
|
|
8819
|
+
- Testing
|
|
8820
|
+
- Deploy
|
|
8821
|
+
\`\`\`
|
|
8822
|
+
`
|
|
8823
|
+
}
|
|
8824
|
+
], i = new Q(e, {
|
|
8825
|
+
title: "Insert mindmap",
|
|
8826
|
+
theme: this.theme,
|
|
8827
|
+
fields: [],
|
|
8828
|
+
onSubmit: () => {
|
|
8829
|
+
}
|
|
8830
|
+
}), r = i.el.querySelector(".md-editor-popup-body");
|
|
8831
|
+
if (r) {
|
|
8832
|
+
const o = document.createElement("div");
|
|
8833
|
+
o.className = "md-editor-template-grid";
|
|
8834
|
+
for (const c of t) {
|
|
8835
|
+
const l = document.createElement("button");
|
|
8836
|
+
l.type = "button", l.className = "md-editor-template-option", l.innerHTML = `<span class="md-editor-template-label">${c.label}</span><span class="md-editor-template-hint">${c.hint}</span>`, l.addEventListener("click", () => {
|
|
8837
|
+
this.codeEditor.insertAtCursor(c.snippet), i.hide();
|
|
8838
|
+
}), o.appendChild(l);
|
|
8839
|
+
}
|
|
8840
|
+
r.innerHTML = "", r.appendChild(o);
|
|
8687
8841
|
}
|
|
8688
8842
|
const a = i.el.querySelector(".md-editor-popup-footer");
|
|
8689
8843
|
a && a.remove(), this.activePopup = i, this.activePopup.show();
|
|
@@ -8693,21 +8847,21 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8693
8847
|
this.previewPane && this.previewPane.addEventListener("click", (e) => {
|
|
8694
8848
|
const t = e.target.closest(".md-editor-codeblock-copy");
|
|
8695
8849
|
if (!t) return;
|
|
8696
|
-
const i = t.closest(".md-editor-codeblock"),
|
|
8697
|
-
if (!
|
|
8698
|
-
const a =
|
|
8850
|
+
const i = t.closest(".md-editor-codeblock"), r = i == null ? void 0 : i.querySelector("code");
|
|
8851
|
+
if (!r) return;
|
|
8852
|
+
const a = r.textContent ?? "";
|
|
8699
8853
|
this.copyToClipboard(a, t);
|
|
8700
8854
|
});
|
|
8701
8855
|
}
|
|
8702
8856
|
copyToClipboard(e, t) {
|
|
8703
|
-
var
|
|
8857
|
+
var r;
|
|
8704
8858
|
const i = () => {
|
|
8705
8859
|
const a = t.textContent;
|
|
8706
8860
|
t.textContent = "Copied!", t.classList.add("is-copied"), window.setTimeout(() => {
|
|
8707
8861
|
t.textContent = a, t.classList.remove("is-copied");
|
|
8708
8862
|
}, 2e3);
|
|
8709
8863
|
};
|
|
8710
|
-
(
|
|
8864
|
+
(r = navigator.clipboard) != null && r.writeText ? navigator.clipboard.writeText(e).then(i).catch(() => {
|
|
8711
8865
|
this.fallbackCopy(e, i);
|
|
8712
8866
|
}) : this.fallbackCopy(e, i);
|
|
8713
8867
|
}
|
|
@@ -8715,19 +8869,22 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8715
8869
|
try {
|
|
8716
8870
|
const i = document.createElement("textarea");
|
|
8717
8871
|
i.value = e, i.style.position = "fixed", i.style.opacity = "0", document.body.appendChild(i), i.select();
|
|
8718
|
-
const
|
|
8719
|
-
document.body.removeChild(i),
|
|
8872
|
+
const r = document.execCommand("copy");
|
|
8873
|
+
document.body.removeChild(i), r && t();
|
|
8720
8874
|
} catch {
|
|
8721
8875
|
}
|
|
8722
8876
|
}
|
|
8877
|
+
escapeHtml(e) {
|
|
8878
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
8879
|
+
}
|
|
8723
8880
|
// ---------- Snippets ----------
|
|
8724
8881
|
insertSnippet(e) {
|
|
8725
|
-
const [t, i,
|
|
8726
|
-
this.codeEditor.insertAtCursor(`${t}${
|
|
8882
|
+
const [t, i, r] = nt[e];
|
|
8883
|
+
this.codeEditor.insertAtCursor(`${t}${r}${i}`);
|
|
8727
8884
|
}
|
|
8728
8885
|
wrapSnippet(e) {
|
|
8729
|
-
const [t, i,
|
|
8730
|
-
this.codeEditor.wrapSelection(t, i,
|
|
8886
|
+
const [t, i, r] = nt[e];
|
|
8887
|
+
this.codeEditor.wrapSelection(t, i, r);
|
|
8731
8888
|
}
|
|
8732
8889
|
togglePreview() {
|
|
8733
8890
|
var t;
|
|
@@ -8737,22 +8894,28 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8737
8894
|
}
|
|
8738
8895
|
// ---------- Render scheduling (performance core) ----------
|
|
8739
8896
|
requestPreviewRender(e) {
|
|
8740
|
-
var i,
|
|
8741
|
-
const t = this.renderDebounceOpt === !1 ? 0 : this.renderDebounceOpt ??
|
|
8897
|
+
var i, r;
|
|
8898
|
+
const t = this.renderDebounceOpt === !1 ? 0 : this.renderDebounceOpt ?? er(e.length);
|
|
8742
8899
|
if (t === 0) {
|
|
8743
8900
|
(i = this.scheduledRender) == null || i.cancel(), this.scheduledRender = null, this.renderPreview(e);
|
|
8744
8901
|
return;
|
|
8745
8902
|
}
|
|
8746
|
-
(!this.scheduledRender || this.scheduledWait !== t) && ((
|
|
8903
|
+
(!this.scheduledRender || this.scheduledWait !== t) && ((r = this.scheduledRender) == null || r.cancel(), this.scheduledRender = ji((a) => this.renderPreview(a), t), this.scheduledWait = t), this.scheduledRender(e);
|
|
8747
8904
|
}
|
|
8748
8905
|
renderPreview(e) {
|
|
8749
8906
|
if (!this.previewPane || !this.incremental) return;
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8907
|
+
let t = 0;
|
|
8908
|
+
try {
|
|
8909
|
+
t = this.incremental.update(e).totalCount;
|
|
8910
|
+
} catch {
|
|
8911
|
+
this.previewPane.innerHTML = `<pre style="padding:16px;white-space:pre-wrap;word-break:break-word;">${this.escapeHtml(e)}</pre>`;
|
|
8912
|
+
}
|
|
8913
|
+
if (this.renderer.hydrate(this.previewPane).catch(() => {
|
|
8914
|
+
}), this.statusBar) {
|
|
8915
|
+
const { charCount: i, wordCount: r } = tt(e);
|
|
8753
8916
|
this.statusBar.update({
|
|
8754
8917
|
charCount: i,
|
|
8755
|
-
wordCount:
|
|
8918
|
+
wordCount: r,
|
|
8756
8919
|
blockCount: t,
|
|
8757
8920
|
mode: this.mode,
|
|
8758
8921
|
autoPreview: this.autoPreview
|
|
@@ -8760,13 +8923,13 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8760
8923
|
}
|
|
8761
8924
|
}
|
|
8762
8925
|
updateStatusBar(e) {
|
|
8763
|
-
var
|
|
8926
|
+
var r;
|
|
8764
8927
|
if (!this.statusBar) return;
|
|
8765
8928
|
const { charCount: t, wordCount: i } = tt(e);
|
|
8766
8929
|
this.statusBar.update({
|
|
8767
8930
|
charCount: t,
|
|
8768
8931
|
wordCount: i,
|
|
8769
|
-
blockCount: ((
|
|
8932
|
+
blockCount: ((r = this.incremental) == null ? void 0 : r.getBlockCount()) ?? 0,
|
|
8770
8933
|
mode: this.mode,
|
|
8771
8934
|
autoPreview: this.autoPreview
|
|
8772
8935
|
});
|
|
@@ -8790,8 +8953,8 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8790
8953
|
this.autoPreview = e, e && this.renderPreview(this.codeEditor.getValue()), this.updateStatusBar(this.codeEditor.getValue());
|
|
8791
8954
|
}
|
|
8792
8955
|
setMode(e) {
|
|
8793
|
-
var t, i,
|
|
8794
|
-
e !== this.mode && (this.mode = e, this.container.classList.remove("md-editor-mode-simple", "md-editor-mode-complex"), this.container.classList.add(`md-editor-mode-${e}`), this.codeEditor.setLineNumbers(e === "complex"), (t = this.toolbar) == null || t.destroy(), this.toolbar = null, (i = this.statusBar) == null || i.destroy(), this.statusBar = null, (
|
|
8956
|
+
var t, i, r;
|
|
8957
|
+
e !== this.mode && (this.mode = e, this.container.classList.remove("md-editor-mode-simple", "md-editor-mode-complex"), this.container.classList.add(`md-editor-mode-${e}`), this.codeEditor.setLineNumbers(e === "complex"), (t = this.toolbar) == null || t.destroy(), this.toolbar = null, (i = this.statusBar) == null || i.destroy(), this.statusBar = null, (r = this.activePopup) == null || r.destroy(), this.activePopup = null, e === "complex" && (this.buildToolbar(), this.buildStatusBar(), this.updateStatusBar(this.codeEditor.getValue())));
|
|
8795
8958
|
}
|
|
8796
8959
|
setTheme(e) {
|
|
8797
8960
|
var t;
|
|
@@ -8801,33 +8964,33 @@ Your ${c.key.toLowerCase()} content here.
|
|
|
8801
8964
|
this.codeEditor.focus();
|
|
8802
8965
|
}
|
|
8803
8966
|
destroy() {
|
|
8804
|
-
var e, t, i,
|
|
8805
|
-
(e = this.scheduledRender) == null || e.cancel(), this.scheduledRender = null, (t = this.activePopup) == null || t.destroy(), this.activePopup = null, this.codeEditor.destroy(), (i = this.toolbar) == null || i.destroy(), this.toolbar = null, (
|
|
8967
|
+
var e, t, i, r, a;
|
|
8968
|
+
(e = this.scheduledRender) == null || e.cancel(), this.scheduledRender = null, (t = this.activePopup) == null || t.destroy(), this.activePopup = null, this.codeEditor.destroy(), (i = this.toolbar) == null || i.destroy(), this.toolbar = null, (r = this.statusBar) == null || r.destroy(), this.statusBar = null, (a = this.incremental) == null || a.destroy(), this.incremental = null, this.container.innerHTML = "", this.container.classList.remove("md-editor-root", `md-editor-mode-${this.mode}`), this.container.removeAttribute("data-theme");
|
|
8806
8969
|
}
|
|
8807
8970
|
}
|
|
8808
8971
|
export {
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8972
|
+
rn as CodeEditor,
|
|
8973
|
+
tr as DEFAULT_SHORTCUTS,
|
|
8974
|
+
Ji as IncrementalRenderer,
|
|
8975
|
+
mr as MarkdownEditor,
|
|
8976
|
+
Q as Popup,
|
|
8814
8977
|
It as Renderer,
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8978
|
+
Gi as StatusBar,
|
|
8979
|
+
Ki as Toolbar,
|
|
8980
|
+
er as adaptiveDebounceMs,
|
|
8981
|
+
hr as cancelIdle,
|
|
8819
8982
|
tt as countText,
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8983
|
+
ji as debounce,
|
|
8984
|
+
Ri as extractYouTubeId,
|
|
8985
|
+
gr as formatShortcut,
|
|
8986
|
+
nr as formatShortcutHtml,
|
|
8824
8987
|
R as icons,
|
|
8825
8988
|
je as imageMarkdown,
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8989
|
+
Ii as isVideoFile,
|
|
8990
|
+
pr as matchShortcut,
|
|
8991
|
+
dr as renderMarkdown,
|
|
8992
|
+
ur as scheduleIdle,
|
|
8993
|
+
Qi as splitIntoBlocks,
|
|
8994
|
+
Li as videoMarkdown,
|
|
8995
|
+
Oi as youTubeEmbedMarkdown
|
|
8833
8996
|
};
|