@pie-element/shared-math-rendering-mathjax 0.1.4-next.20261007064237 → 0.1.4-next.20261007201108
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/browser/index.js +457 -169
- package/dist/index.d.ts +1 -0
- package/dist/index.js +529 -241
- package/dist/math-name.d.ts +11 -0
- package/dist/math-speech.d.ts +10 -0
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -19,32 +19,32 @@ var f = d(), p = `PIE-MJX-CHTML-styles-${f}`, m = ["MJX-CHTML-styles"], h = "htt
|
|
|
19
19
|
function v(e) {
|
|
20
20
|
for (let t of e.querySelectorAll("*")) {
|
|
21
21
|
let n = g.exec(t.tagName.toLowerCase())?.[1];
|
|
22
|
-
!n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(
|
|
22
|
+
!n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(y(t, `${n}:`));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function y(e, t) {
|
|
26
26
|
let n = e.tagName.toLowerCase().slice(t.length);
|
|
27
27
|
if (!_.test(n)) return e;
|
|
28
28
|
let r = e.ownerDocument.createElementNS(h, n);
|
|
29
29
|
for (let t of e.attributes) r.setAttribute(t.name, t.value);
|
|
30
30
|
for (let n of [...e.childNodes]) {
|
|
31
31
|
let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
|
|
32
|
-
r.appendChild(e ?
|
|
32
|
+
r.appendChild(e ? y(n, t) : n);
|
|
33
33
|
}
|
|
34
34
|
return r;
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/elementary-math.ts
|
|
38
|
-
var
|
|
38
|
+
var ee = /* @__PURE__ */ new Set([
|
|
39
39
|
"updiagonalstrike",
|
|
40
40
|
"downdiagonalstrike",
|
|
41
41
|
"verticalstrike",
|
|
42
42
|
"horizontalstrike"
|
|
43
|
-
]),
|
|
43
|
+
]), te = {
|
|
44
44
|
thin: "0.035em",
|
|
45
45
|
medium: "0.07em",
|
|
46
46
|
thick: "0.14em"
|
|
47
|
-
},
|
|
47
|
+
}, ne = {
|
|
48
48
|
tight: "0em",
|
|
49
49
|
medium: "0.1em",
|
|
50
50
|
loose: "0.2em"
|
|
@@ -117,18 +117,18 @@ function D(e, t, n) {
|
|
|
117
117
|
position: t
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
return (e ?? "").toLowerCase().split(/\s+/).filter((e) =>
|
|
120
|
+
function ce(e) {
|
|
121
|
+
return (e ?? "").toLowerCase().split(/\s+/).filter((e) => ee.has(e));
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function le(e, t) {
|
|
124
124
|
let n = [...e.children].filter((e) => !T(e));
|
|
125
125
|
return n.length <= 1 ? n[0] ?? null : b(t.document, "mrow", n);
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
let r = C(e, "location") ?? "n", i =
|
|
129
|
-
content:
|
|
127
|
+
function ue(e, t, n) {
|
|
128
|
+
let r = C(e, "location") ?? "n", i = ce(e.getAttribute("crossout")), a = [...e.children].map((e) => T(e) ? null : e.localName === "mscarry" ? {
|
|
129
|
+
content: le(e, n),
|
|
130
130
|
location: C(e, "location") ?? r,
|
|
131
|
-
crossout: e.hasAttribute("crossout") ?
|
|
131
|
+
crossout: e.hasAttribute("crossout") ? ce(e.getAttribute("crossout")) : i
|
|
132
132
|
} : {
|
|
133
133
|
content: e,
|
|
134
134
|
location: r,
|
|
@@ -142,32 +142,32 @@ function le(e, t, n) {
|
|
|
142
142
|
scale: ae.test(o) ? o : "0.6"
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
let t = C(e, "mslinethickness") ?? "medium", n =
|
|
145
|
+
function de(e) {
|
|
146
|
+
let t = C(e, "mslinethickness") ?? "medium", n = te[t] ?? (re.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
|
|
147
147
|
return `${n} solid ${ie.test(r) ? r : "currentColor"}`;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function fe(e, t, n) {
|
|
150
150
|
let r = Math.max(0, w(e, "length"));
|
|
151
151
|
return {
|
|
152
152
|
kind: "line",
|
|
153
153
|
length: r,
|
|
154
154
|
anchor: E(r, n.stackAlign),
|
|
155
155
|
position: t,
|
|
156
|
-
border:
|
|
156
|
+
border: de(e)
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function O(e, t, n, r, i) {
|
|
160
160
|
e.forEach((e, a) => {
|
|
161
161
|
let o = t + a * n + w(e, "position");
|
|
162
162
|
switch (e.localName) {
|
|
163
163
|
case "msgroup":
|
|
164
|
-
|
|
164
|
+
O([...e.children], o, w(e, "shift"), r, i);
|
|
165
165
|
break;
|
|
166
166
|
case "msline":
|
|
167
|
-
i.push(
|
|
167
|
+
i.push(fe(e, o, r));
|
|
168
168
|
break;
|
|
169
169
|
case "mscarries":
|
|
170
|
-
i.push(
|
|
170
|
+
i.push(ue(e, o, r));
|
|
171
171
|
break;
|
|
172
172
|
case "msrow":
|
|
173
173
|
case "mrow":
|
|
@@ -177,16 +177,16 @@ function A(e, t, n, r, i) {
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function k(e) {
|
|
181
181
|
return -e.anchor - e.position;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function pe(e) {
|
|
184
184
|
return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
return
|
|
186
|
+
function me(e) {
|
|
187
|
+
return k(e) + pe(e) - 1;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function he(e, t, n, r) {
|
|
190
190
|
let i = (e) => b(r.document, "mpadded", [t], {
|
|
191
191
|
width: "0",
|
|
192
192
|
...e ? { lspace: e } : {}
|
|
@@ -212,7 +212,7 @@ function pe(e, t, n, r) {
|
|
|
212
212
|
default: return a("mover", [e, i("-0.5width")]);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function ge(e, t, n) {
|
|
216
216
|
let r = b(n.document, "menclose", [e], {
|
|
217
217
|
notation: t.join(" "),
|
|
218
218
|
"data-padding": "0.1em",
|
|
@@ -223,38 +223,38 @@ function me(e, t, n) {
|
|
|
223
223
|
width: `-${2 * i}em`
|
|
224
224
|
}) : r;
|
|
225
225
|
}
|
|
226
|
-
function
|
|
227
|
-
let a = e && t.crossout.length ?
|
|
226
|
+
function _e(e, t, n, r, i) {
|
|
227
|
+
let a = e && t.crossout.length ? ge(e, t.crossout, i) : e;
|
|
228
228
|
if (!t.content) return a;
|
|
229
229
|
let o = b(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
|
|
230
|
-
return
|
|
230
|
+
return he(a ?? S(i), o, n, i);
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
return e.carries[t -
|
|
232
|
+
function A(e, t) {
|
|
233
|
+
return e.carries[t - k(e)] ?? null;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function ve(e, t, n, r) {
|
|
236
236
|
let i = e.content;
|
|
237
237
|
n.forEach((e, a) => {
|
|
238
|
-
let o = n.length - 1 - a, s = n[o], c =
|
|
238
|
+
let o = n.length - 1 - a, s = n[o], c = A(s, t), l = n.slice(0, o).some((e) => A(e, t));
|
|
239
239
|
if (!c && !l) return;
|
|
240
240
|
let u = c ?? {
|
|
241
241
|
content: S(r),
|
|
242
242
|
location: "n",
|
|
243
243
|
crossout: []
|
|
244
244
|
}, d = a === 0 ? u.location : "n";
|
|
245
|
-
i =
|
|
245
|
+
i = _e(i, u, d, s.scale, r);
|
|
246
246
|
}), e.content = i;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
let n = e.filter((e) =>
|
|
248
|
+
function j(e, t) {
|
|
249
|
+
let n = e.filter((e) => pe(e) > 0), r = Math.min(0, ...n.map(k)), i = Math.max(r, ...n.map(me)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
|
|
250
250
|
content: null,
|
|
251
251
|
borders: {}
|
|
252
|
-
})), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a +
|
|
252
|
+
})), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + k(e) + n), u = [], d = [], f = (e) => {
|
|
253
253
|
let n = c();
|
|
254
254
|
e.cells.forEach((t, r) => {
|
|
255
|
-
n[a +
|
|
255
|
+
n[a + k(e) + r].content = t;
|
|
256
256
|
}), u.length && n.forEach((e, n) => {
|
|
257
|
-
|
|
257
|
+
ve(e, n - a, u, t);
|
|
258
258
|
});
|
|
259
259
|
for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
|
|
260
260
|
u = [], d = [], s.set(e, o.length), o.push(n);
|
|
@@ -274,7 +274,7 @@ function N(e, t) {
|
|
|
274
274
|
origin: a
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function M(e, { rows: t }, n) {
|
|
278
278
|
let r = b(n.document, "mtable", t.map((e) => b(n.document, "mtr", e.map((e) => {
|
|
279
279
|
let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
|
|
280
280
|
return b(n.document, "mtd", [e.content], {
|
|
@@ -284,23 +284,23 @@ function P(e, { rows: t }, n) {
|
|
|
284
284
|
}))));
|
|
285
285
|
for (let { name: t, value: n } of [...e.attributes]) se.has(t) || r.setAttribute(t, n);
|
|
286
286
|
let i = C(e, "charspacing") ?? "medium", a = C(e, "charalign");
|
|
287
|
-
return r.setAttribute("columnspacing",
|
|
287
|
+
return r.setAttribute("columnspacing", ne[i] ?? (re.test(i) ? i : ne.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function N(e) {
|
|
290
290
|
return {
|
|
291
291
|
document: e.ownerDocument,
|
|
292
292
|
stackAlign: C(e, "stackalign") ?? "decimalpoint",
|
|
293
293
|
decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
|
-
function
|
|
297
|
-
let t =
|
|
298
|
-
return
|
|
296
|
+
function ye(e) {
|
|
297
|
+
let t = N(e), n = [];
|
|
298
|
+
return O([...e.children], 0, 0, t, n), M(e, j(n, t), t);
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function P(e, t, n, r, i, a) {
|
|
301
301
|
for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function be(e, t) {
|
|
304
304
|
let n = x(t, ")");
|
|
305
305
|
return n.setAttribute("minsize", "1.2em"), [b(t.document, "mrow", [e, b(t.document, "mspace", [], { width: "0.2em" })]), b(t.document, "mpadded", [n], {
|
|
306
306
|
voffset: "0.1em",
|
|
@@ -309,9 +309,9 @@ function ve(e, t) {
|
|
|
309
309
|
height: "-0.2em"
|
|
310
310
|
})];
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
let t =
|
|
314
|
-
|
|
312
|
+
function xe(e) {
|
|
313
|
+
let t = N(e), [n, r, ...i] = [...e.children], a = n && !T(n) ? n : null, o = r && !T(r) ? r : null, s = C(e, "longdivstyle") ?? "lefttop", c = de(e), l = [];
|
|
314
|
+
O(i, 0, 0, t, l);
|
|
315
315
|
let u = l.find((e) => e.kind === "digits");
|
|
316
316
|
u || (u = {
|
|
317
317
|
kind: "digits",
|
|
@@ -338,35 +338,35 @@ function ye(e) {
|
|
|
338
338
|
case "righttop":
|
|
339
339
|
case "stackedleftlinetop":
|
|
340
340
|
case "lefttop":
|
|
341
|
-
o &&
|
|
341
|
+
o && O([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...be(a, t));
|
|
342
342
|
break;
|
|
343
343
|
}
|
|
344
|
-
let m =
|
|
344
|
+
let m = j(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + k(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + me(e)));
|
|
345
345
|
switch (s) {
|
|
346
346
|
case "left/\\right":
|
|
347
347
|
case "left)(right":
|
|
348
348
|
case ":right=right": break;
|
|
349
349
|
case "righttop": {
|
|
350
350
|
let e = h[g][_(u.cells.length - 1)];
|
|
351
|
-
e.borders.left = c, e.borders.bottom = c,
|
|
351
|
+
e.borders.left = c, e.borders.bottom = c, P(h, g, _(0), _(u.cells.length - 1), "top", c);
|
|
352
352
|
break;
|
|
353
353
|
}
|
|
354
354
|
case "stackedleftlinetop": {
|
|
355
355
|
let e = h[g][_(0)];
|
|
356
|
-
e.borders.right = c, e.borders.bottom = c,
|
|
356
|
+
e.borders.right = c, e.borders.bottom = c, P(h, g, _(1), v, "top", c);
|
|
357
357
|
break;
|
|
358
358
|
}
|
|
359
359
|
case "stackedrightright":
|
|
360
360
|
case "mediumstackedrightright":
|
|
361
361
|
case "shortstackedrightright":
|
|
362
362
|
case "stackedleftleft":
|
|
363
|
-
|
|
363
|
+
Se(h, g, s, a, o, c, t);
|
|
364
364
|
break;
|
|
365
|
-
default:
|
|
365
|
+
default: P(h, g, _(1), v, "top", c);
|
|
366
366
|
}
|
|
367
|
-
return
|
|
367
|
+
return M(e, m, t);
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function Se(e, t, n, r, i, a, o) {
|
|
370
370
|
let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && b(o.document, "mpadded", [e], {
|
|
371
371
|
lspace: "0.2em",
|
|
372
372
|
width: "+0.4em"
|
|
@@ -386,120 +386,399 @@ function be(e, t, n, r, i, a, o) {
|
|
|
386
386
|
}) : o === t + 1 ? (u.content = l(i), n !== "shortstackedrightright" && (u.borders[c] = a)) : o > t + 1 && (n === "stackedrightright" || s) && (u.borders[c] = a), s ? e.unshift(u) : e.push(u);
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
|
-
function
|
|
390
|
-
for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ?
|
|
389
|
+
function Ce(e) {
|
|
390
|
+
for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? ye(t) : xe(t));
|
|
391
391
|
}
|
|
392
392
|
//#endregion
|
|
393
393
|
//#region src/explorer-styles.ts
|
|
394
|
-
var
|
|
394
|
+
var we = "PIE-MJX-explorer-styles", F = "var(--pie-text, black)", Te = "var(--pie-background, #ffffff)", Ee = "var(--pie-border-dark, #66686A)", I = "var(--pie-focus-outline, var(--pie-button-focus-outline, var(--pie-focus-checked-border, #1565C0)))", L = `color-mix(in srgb, ${I} 15%, transparent)`, De = `
|
|
395
395
|
:root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
|
|
396
|
-
color: ${
|
|
397
|
-
fill: ${
|
|
396
|
+
color: ${F} !important;
|
|
397
|
+
fill: ${F} !important;
|
|
398
398
|
}
|
|
399
399
|
:root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
|
|
400
|
-
background-color: ${
|
|
400
|
+
background-color: ${L} !important;
|
|
401
401
|
}
|
|
402
402
|
:root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
|
|
403
|
-
fill: ${
|
|
403
|
+
fill: ${L} !important;
|
|
404
404
|
}
|
|
405
405
|
:root mjx-container .mjx-selected {
|
|
406
|
-
outline: 2px solid ${
|
|
406
|
+
outline: 2px solid ${I} !important;
|
|
407
407
|
}
|
|
408
408
|
:root mjx-container [data-sre-highlight-2] {
|
|
409
|
-
color: ${
|
|
409
|
+
color: ${F} !important;
|
|
410
410
|
background-color: transparent !important;
|
|
411
|
-
fill: ${
|
|
412
|
-
outline: 2px dashed ${
|
|
411
|
+
fill: ${F} !important;
|
|
412
|
+
outline: 2px dashed ${I} !important;
|
|
413
413
|
}
|
|
414
414
|
:root mjx-container rect[data-sre-highlight-2] {
|
|
415
415
|
fill: transparent !important;
|
|
416
|
-
stroke: ${
|
|
416
|
+
stroke: ${I} !important;
|
|
417
417
|
stroke-width: 2px !important;
|
|
418
418
|
vector-effect: non-scaling-stroke;
|
|
419
419
|
}
|
|
420
420
|
:root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
|
|
421
|
-
color: ${
|
|
422
|
-
background-color: ${
|
|
423
|
-
border-color: ${
|
|
421
|
+
color: ${F} !important;
|
|
422
|
+
background-color: ${Te} !important;
|
|
423
|
+
border-color: ${Ee} !important;
|
|
424
424
|
}
|
|
425
425
|
:root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
|
|
426
|
-
color: ${
|
|
427
|
-
background-color: ${
|
|
426
|
+
color: ${F} !important;
|
|
427
|
+
background-color: ${L} !important;
|
|
428
428
|
}
|
|
429
429
|
`;
|
|
430
|
-
function
|
|
430
|
+
function Oe(e = document) {
|
|
431
431
|
if (e.getElementById("PIE-MJX-explorer-styles")) return;
|
|
432
432
|
let t = e.createElement("style");
|
|
433
|
-
t.id =
|
|
433
|
+
t.id = we, t.textContent = De, e.head.appendChild(t);
|
|
434
|
+
}
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/math-speech.ts
|
|
437
|
+
var ke = /[-]/g, R = {
|
|
438
|
+
"+": "positive",
|
|
439
|
+
"-": "negative",
|
|
440
|
+
"−": "negative",
|
|
441
|
+
"±": "plus or minus",
|
|
442
|
+
"∓": "minus or plus"
|
|
443
|
+
}, Ae = {
|
|
444
|
+
"(": "open parenthesis",
|
|
445
|
+
"[": "open bracket",
|
|
446
|
+
"{": "open brace",
|
|
447
|
+
"⟨": "open angle bracket",
|
|
448
|
+
"⌊": "open floor",
|
|
449
|
+
"⌈": "open ceiling"
|
|
450
|
+
}, je = {
|
|
451
|
+
")": "close parenthesis",
|
|
452
|
+
"]": "close bracket",
|
|
453
|
+
"}": "close brace",
|
|
454
|
+
"⟩": "close angle bracket",
|
|
455
|
+
"⌋": "close floor",
|
|
456
|
+
"⌉": "close ceiling"
|
|
457
|
+
}, z = {
|
|
458
|
+
"!": "factorial",
|
|
459
|
+
"%": "percent",
|
|
460
|
+
"°": "degrees",
|
|
461
|
+
"′": "prime",
|
|
462
|
+
"″": "double prime"
|
|
463
|
+
}, Me = {
|
|
464
|
+
"+": "plus",
|
|
465
|
+
"-": "minus",
|
|
466
|
+
"−": "minus",
|
|
467
|
+
"±": "plus or minus",
|
|
468
|
+
"∓": "minus or plus",
|
|
469
|
+
"×": "times",
|
|
470
|
+
"⋅": "times",
|
|
471
|
+
"·": "times",
|
|
472
|
+
"*": "times",
|
|
473
|
+
"÷": "divided by",
|
|
474
|
+
"/": "divided by",
|
|
475
|
+
"=": "equals",
|
|
476
|
+
"≠": "does not equal",
|
|
477
|
+
"<": "is less than",
|
|
478
|
+
">": "is greater than",
|
|
479
|
+
"≤": "is less than or equal to",
|
|
480
|
+
"≥": "is greater than or equal to",
|
|
481
|
+
"≈": "is approximately equal to",
|
|
482
|
+
"≡": "is equivalent to",
|
|
483
|
+
"∝": "is proportional to",
|
|
484
|
+
"∈": "is an element of",
|
|
485
|
+
"∉": "is not an element of",
|
|
486
|
+
"⊂": "is a subset of",
|
|
487
|
+
"⊆": "is a subset of or equal to",
|
|
488
|
+
"∪": "union",
|
|
489
|
+
"∩": "intersection",
|
|
490
|
+
"→": "right arrow",
|
|
491
|
+
"←": "left arrow",
|
|
492
|
+
"⇒": "implies",
|
|
493
|
+
"⇔": "if and only if",
|
|
494
|
+
"∑": "sum",
|
|
495
|
+
"∏": "product",
|
|
496
|
+
"∫": "integral",
|
|
497
|
+
"∞": "infinity",
|
|
498
|
+
"∠": "angle",
|
|
499
|
+
"⊥": "is perpendicular to",
|
|
500
|
+
"∥": "is parallel to",
|
|
501
|
+
"∴": "therefore",
|
|
502
|
+
",": "comma",
|
|
503
|
+
";": "semicolon",
|
|
504
|
+
":": "colon",
|
|
505
|
+
"|": "vertical bar",
|
|
506
|
+
"‖": "double vertical bar",
|
|
507
|
+
...Ae,
|
|
508
|
+
...je,
|
|
509
|
+
...z
|
|
510
|
+
}, Ne = /* @__PURE__ */ new Set(["|", "‖"]), Pe = /* @__PURE__ */ new Set([
|
|
511
|
+
"∑",
|
|
512
|
+
"∏",
|
|
513
|
+
"∫",
|
|
514
|
+
"∪",
|
|
515
|
+
"∩"
|
|
516
|
+
]), Fe = {
|
|
517
|
+
α: "alpha",
|
|
518
|
+
β: "beta",
|
|
519
|
+
γ: "gamma",
|
|
520
|
+
δ: "delta",
|
|
521
|
+
ε: "epsilon",
|
|
522
|
+
θ: "theta",
|
|
523
|
+
λ: "lambda",
|
|
524
|
+
μ: "mu",
|
|
525
|
+
π: "pi",
|
|
526
|
+
ρ: "rho",
|
|
527
|
+
σ: "sigma",
|
|
528
|
+
τ: "tau",
|
|
529
|
+
φ: "phi",
|
|
530
|
+
ω: "omega",
|
|
531
|
+
Δ: "capital delta",
|
|
532
|
+
Σ: "capital sigma",
|
|
533
|
+
Ω: "capital omega",
|
|
534
|
+
"∞": "infinity",
|
|
535
|
+
sin: "sine",
|
|
536
|
+
cos: "cosine",
|
|
537
|
+
tan: "tangent",
|
|
538
|
+
sec: "secant",
|
|
539
|
+
csc: "cosecant",
|
|
540
|
+
cot: "cotangent",
|
|
541
|
+
ln: "natural log",
|
|
542
|
+
lim: "limit"
|
|
543
|
+
}, Ie = {
|
|
544
|
+
"¯": "bar",
|
|
545
|
+
"‾": "bar",
|
|
546
|
+
"―": "bar",
|
|
547
|
+
"^": "hat",
|
|
548
|
+
ˆ: "hat",
|
|
549
|
+
"~": "tilde",
|
|
550
|
+
"˜": "tilde",
|
|
551
|
+
"→": "vector",
|
|
552
|
+
"⃗": "vector",
|
|
553
|
+
"˙": "dot"
|
|
554
|
+
}, B = (e) => (e.textContent ?? "").replace(ke, "").replace(/\s+/g, " ").trim(), V = (e) => e.replace(/\s+/g, " ").trim(), H = (e) => [...e.children];
|
|
555
|
+
function U(e) {
|
|
556
|
+
return !e || [
|
|
557
|
+
"mn",
|
|
558
|
+
"mi",
|
|
559
|
+
"mtext",
|
|
560
|
+
"mo"
|
|
561
|
+
].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? U(e.children[0]) : !1;
|
|
562
|
+
}
|
|
563
|
+
function Le(e) {
|
|
564
|
+
let t = e ? B(e) : "";
|
|
565
|
+
return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
|
|
566
|
+
}
|
|
567
|
+
function Re(e) {
|
|
568
|
+
return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
|
|
569
|
+
1: "st",
|
|
570
|
+
2: "nd",
|
|
571
|
+
3: "rd"
|
|
572
|
+
}[e % 10] ?? "th"}`;
|
|
573
|
+
}
|
|
574
|
+
function ze(e) {
|
|
575
|
+
return Fe[e] ?? e;
|
|
576
|
+
}
|
|
577
|
+
function W(e) {
|
|
578
|
+
return Me[e] ?? e;
|
|
579
|
+
}
|
|
580
|
+
function G(e) {
|
|
581
|
+
let t = [], n = !1;
|
|
582
|
+
for (let r of e) {
|
|
583
|
+
if (r.localName !== "mo") {
|
|
584
|
+
t.push(K(r)), n = !0;
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
let e = B(r);
|
|
588
|
+
e && (!n && R[e] ? t.push(R[e]) : e in z ? t.push(z[e]) : (t.push(W(e)), n = e in je || Ne.has(e) && n));
|
|
589
|
+
}
|
|
590
|
+
return t.filter(Boolean).join(" ");
|
|
591
|
+
}
|
|
592
|
+
function Be(e) {
|
|
593
|
+
let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(B(e)), a = n.slice(0, -1);
|
|
594
|
+
if (a.length && i(t) && i(r) && B(t) === B(r) && !a.some(i)) {
|
|
595
|
+
let e = V(G(a));
|
|
596
|
+
return B(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
|
|
597
|
+
}
|
|
598
|
+
return G(e);
|
|
599
|
+
}
|
|
600
|
+
function Ve(e, t) {
|
|
601
|
+
let n = e ? K(e) : "", r = t ? K(t) : "";
|
|
602
|
+
return U(e) && U(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
|
|
603
|
+
}
|
|
604
|
+
function He(e, t, n) {
|
|
605
|
+
return n ? `${t} of ${e}` : `${t} of ${e} end root`;
|
|
606
|
+
}
|
|
607
|
+
function Ue(e, t) {
|
|
608
|
+
let n = t ? B(t) : "";
|
|
609
|
+
if (t && U(t)) {
|
|
610
|
+
if (n === "2") return `${e} squared`;
|
|
611
|
+
if (n === "3") return `${e} cubed`;
|
|
612
|
+
if (n in z) return `${e} ${z[n]}`;
|
|
613
|
+
}
|
|
614
|
+
let r = t ? K(t) : "";
|
|
615
|
+
return U(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
|
|
616
|
+
}
|
|
617
|
+
function We(e, t) {
|
|
618
|
+
let n = t ? K(t) : "";
|
|
619
|
+
return U(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
|
|
620
|
+
}
|
|
621
|
+
function Ge(e, t, n) {
|
|
622
|
+
let r = B(e);
|
|
623
|
+
if (r === "lim") return `limit as ${t ? K(t) : ""} of`;
|
|
624
|
+
if (!Pe.has(r)) return;
|
|
625
|
+
let i = t ? `from ${K(t)}` : "", a = n ? `to ${K(n)}` : "";
|
|
626
|
+
return `${W(r)} ${i} ${a} of`;
|
|
627
|
+
}
|
|
628
|
+
function Ke(e) {
|
|
629
|
+
let t = H(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => H(e).filter((e) => e.localName === "mtd")), r = Math.max(0, ...n.map((e) => e.length)), i = n.map((e, t) => `row ${t + 1}: ${e.map((e) => V(G(H(e)))).join(", ")}`);
|
|
630
|
+
return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
|
|
631
|
+
}
|
|
632
|
+
function qe(e) {
|
|
633
|
+
let t = e.getAttribute("open") ?? "(", n = e.getAttribute("close") ?? ")", r = (e.getAttribute("separators") ?? ",").replace(/\s+/g, "").split(""), i = H(e).map((e, t, n) => t < n.length - 1 ? `${K(e)} ${W(r[Math.min(t, r.length - 1)] ?? ",")}` : K(e));
|
|
634
|
+
return [
|
|
635
|
+
W(t),
|
|
636
|
+
...i,
|
|
637
|
+
W(n)
|
|
638
|
+
].filter(Boolean).join(" ");
|
|
639
|
+
}
|
|
640
|
+
function K(e) {
|
|
641
|
+
let t = H(e);
|
|
642
|
+
switch (e.localName) {
|
|
643
|
+
case "mi": return ze(B(e));
|
|
644
|
+
case "mn":
|
|
645
|
+
case "mtext":
|
|
646
|
+
case "ms": return B(e);
|
|
647
|
+
case "mo": return W(B(e));
|
|
648
|
+
case "mspace":
|
|
649
|
+
case "mphantom":
|
|
650
|
+
case "annotation":
|
|
651
|
+
case "annotation-xml": return "";
|
|
652
|
+
case "semantics": return t[0] ? K(t[0]) : "";
|
|
653
|
+
case "mfrac": return Ve(t[0], t[1]);
|
|
654
|
+
case "msqrt": return He(V(G(t)), "square root", t.length === 1 && U(t[0]));
|
|
655
|
+
case "mroot": {
|
|
656
|
+
let e = Le(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${Re(e)} root` : `root with index ${t[1] ? K(t[1]) : ""}`;
|
|
657
|
+
return He(t[0] ? K(t[0]) : "", n, U(t[0]));
|
|
658
|
+
}
|
|
659
|
+
case "msup": return Ue(t[0] ? K(t[0]) : "", t[1]);
|
|
660
|
+
case "msub": return We(t[0] ? K(t[0]) : "", t[1]);
|
|
661
|
+
case "msubsup": return (t[0] ? Ge(t[0], t[1], t[2]) : void 0) || Ue(We(t[0] ? K(t[0]) : "", t[1]), t[2]);
|
|
662
|
+
case "munder":
|
|
663
|
+
case "mover":
|
|
664
|
+
case "munderover": {
|
|
665
|
+
let [n, r, i] = t, a = e.localName === "mover" ? void 0 : r, o = e.localName === "munder" ? void 0 : e.localName === "mover" ? r : i, s = n ? Ge(n, a, o) : void 0;
|
|
666
|
+
if (s) return s;
|
|
667
|
+
let c = n ? K(n) : "", l = e.localName === "mover" && r ? Ie[B(r)] : void 0;
|
|
668
|
+
return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
|
|
669
|
+
c,
|
|
670
|
+
a ? `with ${K(a)} below` : "",
|
|
671
|
+
o ? `with ${K(o)} above` : ""
|
|
672
|
+
].filter(Boolean).join(" ");
|
|
673
|
+
}
|
|
674
|
+
case "mfenced": return qe(e);
|
|
675
|
+
case "mtable": return Ke(e);
|
|
676
|
+
case "mrow":
|
|
677
|
+
case "math": return Be(t);
|
|
678
|
+
default: return t.length ? G(t) : B(e);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function Je(e) {
|
|
682
|
+
return V(K(e));
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/math-name.ts
|
|
686
|
+
var Ye = [
|
|
687
|
+
"a[href]",
|
|
688
|
+
"button",
|
|
689
|
+
"label",
|
|
690
|
+
"summary",
|
|
691
|
+
...[
|
|
692
|
+
"button",
|
|
693
|
+
"checkbox",
|
|
694
|
+
"combobox",
|
|
695
|
+
"link",
|
|
696
|
+
"menuitem",
|
|
697
|
+
"menuitemcheckbox",
|
|
698
|
+
"menuitemradio",
|
|
699
|
+
"option",
|
|
700
|
+
"radio",
|
|
701
|
+
"switch",
|
|
702
|
+
"tab",
|
|
703
|
+
"treeitem"
|
|
704
|
+
].map((e) => `[role="${e}"]`)
|
|
705
|
+
].join(", ");
|
|
706
|
+
function Xe(e) {
|
|
707
|
+
if (e.hasAttribute("aria-label") || !e.closest(Ye)) return;
|
|
708
|
+
let t = e.querySelector("math"), n = t ? Je(t) : "";
|
|
709
|
+
n && e.setAttribute("aria-label", n);
|
|
710
|
+
}
|
|
711
|
+
function q(e) {
|
|
712
|
+
for (let t of e.querySelectorAll("mjx-container")) Xe(t);
|
|
434
713
|
}
|
|
435
714
|
//#endregion
|
|
436
715
|
//#region src/unsupported-page.ts
|
|
437
|
-
var
|
|
438
|
-
function
|
|
716
|
+
var J = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", Ze = "pie-mathjax-version-conflict", Qe = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
|
|
717
|
+
function $e(e, t) {
|
|
439
718
|
if (typeof window > "u") return;
|
|
440
719
|
let n = globalThis;
|
|
441
|
-
n[
|
|
720
|
+
n[Qe] ??= {
|
|
442
721
|
logged: !1,
|
|
443
722
|
conditions: []
|
|
444
723
|
};
|
|
445
|
-
let r = n[
|
|
724
|
+
let r = n[Qe];
|
|
446
725
|
if (r.conditions.includes(e)) return;
|
|
447
726
|
r.conditions.push(e);
|
|
448
|
-
let i = `[math-rendering] Unsupported page (${e}): ${t}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${
|
|
449
|
-
r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(
|
|
727
|
+
let i = `[math-rendering] Unsupported page (${e}): ${t}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${J}`;
|
|
728
|
+
r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(Ze, { detail: {
|
|
450
729
|
condition: e,
|
|
451
730
|
message: i,
|
|
452
|
-
docsUrl:
|
|
731
|
+
docsUrl: J
|
|
453
732
|
} }));
|
|
454
733
|
}
|
|
455
734
|
//#endregion
|
|
456
735
|
//#region src/adapter.ts
|
|
457
|
-
var
|
|
736
|
+
var et = {
|
|
458
737
|
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
459
738
|
overarc: "\\overparen",
|
|
460
739
|
napprox: "\\not\\approx",
|
|
461
740
|
longdiv: "\\enclose{longdiv}",
|
|
462
741
|
abs: ["\\left|#1\\right|", 1]
|
|
463
|
-
},
|
|
742
|
+
}, tt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", nt = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, rt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, it = /\\embed\{newLine\}\[\]/g, at = [
|
|
464
743
|
["$$", "$$"],
|
|
465
744
|
["$", "$"],
|
|
466
745
|
["\\[", "\\]"],
|
|
467
746
|
["\\(", "\\)"]
|
|
468
|
-
],
|
|
747
|
+
], ot = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), st = "MJX-CHTML-styles", ct = "PIE-MJX-SVG-styles", Y = "PIE-MathJax-Menu-Settings", lt = { "mjx-container[overflow=\"linebreak\"][display]": {
|
|
469
748
|
overflow: "auto clip",
|
|
470
749
|
"min-width": "initial !important"
|
|
471
|
-
} },
|
|
472
|
-
function
|
|
750
|
+
} }, ut = 200, dt = 201, ft = 202;
|
|
751
|
+
function X(e) {
|
|
473
752
|
let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
|
|
474
753
|
for (let e of t) for (let t of [e, ...e.querySelectorAll("[data-latex],[data-latex-item]")]) t.removeAttribute("data-latex"), t.removeAttribute("data-latex-item");
|
|
475
754
|
}
|
|
476
|
-
function
|
|
477
|
-
for (let [t, n] of
|
|
755
|
+
function pt(e) {
|
|
756
|
+
for (let [t, n] of at) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
|
|
478
757
|
return e;
|
|
479
758
|
}
|
|
480
|
-
function
|
|
481
|
-
return
|
|
759
|
+
function mt(e) {
|
|
760
|
+
return pt(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
|
|
482
761
|
}
|
|
483
|
-
var
|
|
484
|
-
function
|
|
485
|
-
let n = e.closest(`.${
|
|
486
|
-
return n !== null && t.contains(n) && !n.classList.contains(
|
|
762
|
+
var ht = "mathjax_ignore", gt = "mathjax_process";
|
|
763
|
+
function _t(e, t) {
|
|
764
|
+
let n = e.closest(`.${ht}, .${gt}`);
|
|
765
|
+
return n !== null && t.contains(n) && !n.classList.contains(gt);
|
|
487
766
|
}
|
|
488
|
-
function
|
|
767
|
+
function vt(e) {
|
|
489
768
|
for (let t of e.querySelectorAll("[data-latex]")) {
|
|
490
|
-
if (t.dataset.mathHandled || t.closest("mjx-container") ||
|
|
769
|
+
if (t.dataset.mathHandled || t.closest("mjx-container") || _t(t, e)) continue;
|
|
491
770
|
let n = t.textContent;
|
|
492
|
-
n && (t.textContent = `\\(${
|
|
771
|
+
n && (t.textContent = `\\(${mt(n)}\\)`.replace(it, "\\newline "), t.dataset.mathHandled = "true");
|
|
493
772
|
}
|
|
494
773
|
}
|
|
495
|
-
function
|
|
774
|
+
function yt(e) {
|
|
496
775
|
for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
|
|
497
776
|
}
|
|
498
|
-
function
|
|
777
|
+
function bt(e, t) {
|
|
499
778
|
for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
|
|
500
|
-
return (t ?
|
|
779
|
+
return (t ? rt : nt).test(e.textContent ?? "");
|
|
501
780
|
}
|
|
502
|
-
function
|
|
781
|
+
function xt(e) {
|
|
503
782
|
return new Promise((a, s) => {
|
|
504
783
|
let { useSingleDollar: l = !1, accessibility: u = !0, loadFonts: d = !0, srcUrl: f } = e, p = i(e, import.meta.url), m = {
|
|
505
784
|
loader: {
|
|
@@ -507,17 +786,17 @@ function Ge(e) {
|
|
|
507
786
|
failed: (e) => s(e),
|
|
508
787
|
"output/svg": { ready: (e) => {
|
|
509
788
|
let t = o();
|
|
510
|
-
return
|
|
789
|
+
return St(t) && Ct(t), e;
|
|
511
790
|
} }
|
|
512
791
|
},
|
|
513
792
|
startup: {
|
|
514
793
|
typeset: !1,
|
|
515
794
|
ready: () => {
|
|
516
|
-
let e = o(), n = e?.startup, i =
|
|
517
|
-
i && (
|
|
795
|
+
let e = o(), n = e?.startup, i = St(e);
|
|
796
|
+
i && (Ct(e), wt(e, p.speechLocales), t(e?._?.a11y?.sre_ts?.locales, p.speechLocales)), n?.defaultReady?.(), i && (Tt(n?.document), Et(n?.document), n?.document?.addStyles?.(lt), r(n?.document)), Promise.resolve(n?.promise).then(() => a(), s);
|
|
518
797
|
}
|
|
519
798
|
},
|
|
520
|
-
tex: { macros: { ...
|
|
799
|
+
tex: { macros: { ...et } },
|
|
521
800
|
output: { displayOverflow: "linebreak" },
|
|
522
801
|
options: {
|
|
523
802
|
enableMenu: u,
|
|
@@ -529,7 +808,7 @@ function Ge(e) {
|
|
|
529
808
|
a11y: { inTabOrder: !1 }
|
|
530
809
|
}
|
|
531
810
|
};
|
|
532
|
-
l && m.tex && (console.warn(
|
|
811
|
+
l && m.tex && (console.warn(tt), m.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], m.tex.processEscapes = !0), d || (m.chtml = { fontURL: "" });
|
|
533
812
|
let h = n(p.speechLocales);
|
|
534
813
|
h && m.options && (m.options.sre = { locale: h }), c(m, {
|
|
535
814
|
...p,
|
|
@@ -539,77 +818,86 @@ function Ge(e) {
|
|
|
539
818
|
}, s);
|
|
540
819
|
});
|
|
541
820
|
}
|
|
542
|
-
function
|
|
821
|
+
function St(e) {
|
|
543
822
|
return !!e?.version?.startsWith("4.");
|
|
544
823
|
}
|
|
545
|
-
function
|
|
824
|
+
function Ct(e) {
|
|
546
825
|
let t = e?._?.output, n = t?.chtml_ts?.CHTML;
|
|
547
826
|
n && (n.STYLESHEETID = p);
|
|
548
827
|
let r = t?.svg_ts?.SVG;
|
|
549
|
-
r && (r.STYLESHEETID =
|
|
828
|
+
r && (r.STYLESHEETID = ct);
|
|
550
829
|
}
|
|
551
|
-
function
|
|
830
|
+
function wt(e, t) {
|
|
552
831
|
let n = e?._?.ui?.menu?.Menu?.Menu;
|
|
553
832
|
if (n) {
|
|
554
|
-
n.MENU_STORAGE =
|
|
833
|
+
n.MENU_STORAGE = Y;
|
|
555
834
|
try {
|
|
556
|
-
let e = localStorage.getItem(
|
|
835
|
+
let e = localStorage.getItem(Y);
|
|
557
836
|
if (!e) return;
|
|
558
837
|
let { assistiveMml: n, locale: r, ...i } = JSON.parse(e), a = r === void 0 || !t || t.has(r);
|
|
559
838
|
if (n === void 0 && a) return;
|
|
560
|
-
a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(
|
|
839
|
+
a && r !== void 0 && (i.locale = r), Object.keys(i).length ? localStorage.setItem(Y, JSON.stringify(i)) : localStorage.removeItem(Y);
|
|
561
840
|
} catch {}
|
|
562
841
|
}
|
|
563
842
|
}
|
|
564
|
-
function
|
|
843
|
+
function Tt(e) {
|
|
565
844
|
if (!e) return;
|
|
566
845
|
let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
|
|
567
846
|
let n = e.typesetRoot;
|
|
568
|
-
!n || t.has(n) || (
|
|
847
|
+
!n || t.has(n) || (X(n), t.add(n));
|
|
569
848
|
};
|
|
570
|
-
e.addRenderAction?.("pie-strip-latex",
|
|
849
|
+
e.addRenderAction?.("pie-strip-latex", dt, (e) => {
|
|
571
850
|
for (let t of e.math ?? []) n(t);
|
|
572
851
|
return !1;
|
|
573
852
|
}, (e) => {
|
|
574
853
|
let t = e.typesetRoot;
|
|
575
|
-
return t &&
|
|
854
|
+
return t && X(t), !1;
|
|
576
855
|
});
|
|
577
856
|
let r = e.outputJax?.chtmlStyles;
|
|
578
|
-
r?.id ===
|
|
857
|
+
r?.id === st && (r.id = p), Ot();
|
|
579
858
|
}
|
|
580
|
-
function
|
|
859
|
+
function Et(e) {
|
|
860
|
+
let t = (e) => {
|
|
861
|
+
e.typesetRoot && Xe(e.typesetRoot);
|
|
862
|
+
};
|
|
863
|
+
e?.addRenderAction?.("pie-name-math", ft, (e) => {
|
|
864
|
+
for (let n of e.math ?? []) t(n);
|
|
865
|
+
return !1;
|
|
866
|
+
}, (e) => (t(e), !1));
|
|
867
|
+
}
|
|
868
|
+
function Dt(e) {
|
|
581
869
|
return e instanceof HTMLStyleElement && m.includes(e.id);
|
|
582
870
|
}
|
|
583
|
-
function
|
|
584
|
-
|
|
871
|
+
function Z(e) {
|
|
872
|
+
$e("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
|
|
585
873
|
}
|
|
586
|
-
function
|
|
587
|
-
let e = document.head, t = [...e.children].find(
|
|
874
|
+
function Ot() {
|
|
875
|
+
let e = document.head, t = [...e.children].find(Dt);
|
|
588
876
|
if (t) {
|
|
589
|
-
|
|
877
|
+
Z(t);
|
|
590
878
|
return;
|
|
591
879
|
}
|
|
592
880
|
let n = new MutationObserver((e) => {
|
|
593
881
|
for (let t of e) {
|
|
594
|
-
let e = [...t.addedNodes].find(
|
|
882
|
+
let e = [...t.addedNodes].find(Dt);
|
|
595
883
|
if (e) {
|
|
596
|
-
|
|
884
|
+
Z(e), n.disconnect();
|
|
597
885
|
return;
|
|
598
886
|
}
|
|
599
887
|
}
|
|
600
888
|
});
|
|
601
889
|
n.observe(e, { childList: !0 });
|
|
602
890
|
}
|
|
603
|
-
function
|
|
891
|
+
function kt(e) {
|
|
604
892
|
let t = e?.math;
|
|
605
893
|
if (!t?.remove) return;
|
|
606
|
-
let n = [...t].filter((e) => (e.state?.() ?? 0) >=
|
|
894
|
+
let n = [...t].filter((e) => (e.state?.() ?? 0) >= ut && e.typesetRoot?.isConnected === !1);
|
|
607
895
|
if (n.length !== 0) {
|
|
608
896
|
for (let e of [...n].reverse()) e.clear?.();
|
|
609
897
|
t.remove(...n);
|
|
610
898
|
}
|
|
611
899
|
}
|
|
612
|
-
function
|
|
900
|
+
function At(e) {
|
|
613
901
|
return new Promise((t, n) => {
|
|
614
902
|
let r = e.startup ?? {};
|
|
615
903
|
e.startup = r;
|
|
@@ -620,81 +908,81 @@ function Ze(e) {
|
|
|
620
908
|
};
|
|
621
909
|
});
|
|
622
910
|
}
|
|
623
|
-
function
|
|
911
|
+
function jt(e) {
|
|
624
912
|
let t = o();
|
|
625
|
-
return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() :
|
|
913
|
+
return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : At(t) : xt(e);
|
|
626
914
|
}
|
|
627
|
-
function
|
|
628
|
-
return
|
|
915
|
+
function Mt(e) {
|
|
916
|
+
return jt(e).then(() => {
|
|
629
917
|
let e = o();
|
|
630
918
|
e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
|
|
631
919
|
});
|
|
632
920
|
}
|
|
633
|
-
function
|
|
634
|
-
let t = l, n = t[
|
|
635
|
-
return n || (n =
|
|
921
|
+
function Nt(e) {
|
|
922
|
+
let t = l, n = t[ot];
|
|
923
|
+
return n || (n = Mt(e), t[ot] = n), n;
|
|
636
924
|
}
|
|
637
|
-
function
|
|
925
|
+
function Pt(e = {}) {
|
|
638
926
|
let t = e.useSingleDollar ?? !1;
|
|
639
927
|
return async (n) => {
|
|
640
928
|
if (typeof window > "u") return;
|
|
641
|
-
|
|
642
|
-
let r =
|
|
643
|
-
if (!
|
|
929
|
+
vt(n), v(n), yt(n), Ce(n);
|
|
930
|
+
let r = Nt(e);
|
|
931
|
+
if (!bt(n, t)) {
|
|
644
932
|
r.catch(() => {});
|
|
645
933
|
return;
|
|
646
934
|
}
|
|
647
935
|
await r;
|
|
648
936
|
let i = o();
|
|
649
937
|
if (await i?.startup?.promise, typeof i?.typesetPromise == "function") {
|
|
650
|
-
|
|
938
|
+
Oe(), kt(i.startup?.document);
|
|
651
939
|
try {
|
|
652
940
|
await i.typesetPromise([n]);
|
|
653
941
|
} catch (e) {
|
|
654
942
|
throw i.typesetClear?.([n]), e;
|
|
655
943
|
}
|
|
656
|
-
|
|
944
|
+
X(n), q(n);
|
|
657
945
|
}
|
|
658
946
|
};
|
|
659
947
|
}
|
|
660
|
-
function
|
|
948
|
+
function Ft() {
|
|
661
949
|
return [];
|
|
662
950
|
}
|
|
663
951
|
//#endregion
|
|
664
952
|
//#region src/render-math.ts
|
|
665
|
-
var
|
|
666
|
-
function
|
|
667
|
-
return !!window[
|
|
953
|
+
var It = "@pie-lib/math-rendering", Lt = "@pie-lib/math-rendering@2", Rt = "pie-print", zt = 50, Bt = 1e4, Vt = null;
|
|
954
|
+
function Ht() {
|
|
955
|
+
return !!window[Lt]?.opts?.useSingleDollar;
|
|
668
956
|
}
|
|
669
|
-
function
|
|
670
|
-
return
|
|
957
|
+
function Ut() {
|
|
958
|
+
return Vt ||= Pt({ useSingleDollar: Ht() }), Vt;
|
|
671
959
|
}
|
|
672
960
|
function Q() {
|
|
673
961
|
if (typeof window > "u") return null;
|
|
674
|
-
let e = window[
|
|
962
|
+
let e = window[It];
|
|
675
963
|
return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
|
|
676
964
|
}
|
|
677
|
-
function
|
|
965
|
+
function Wt(e) {
|
|
678
966
|
let t = e;
|
|
679
967
|
for (; t;) {
|
|
680
|
-
if (t instanceof Element && t.localName ===
|
|
968
|
+
if (t instanceof Element && t.localName === Rt) return t;
|
|
681
969
|
t = t instanceof ShadowRoot ? t.host : t.parentNode;
|
|
682
970
|
}
|
|
683
971
|
return null;
|
|
684
972
|
}
|
|
685
|
-
function
|
|
973
|
+
function Gt() {
|
|
686
974
|
let e = window.renderMath;
|
|
687
975
|
return typeof e == "function" ? e : null;
|
|
688
976
|
}
|
|
689
|
-
async function
|
|
690
|
-
let t =
|
|
977
|
+
async function Kt(e) {
|
|
978
|
+
let t = Wt(e);
|
|
691
979
|
if (!t) return null;
|
|
692
|
-
let n =
|
|
980
|
+
let n = Gt();
|
|
693
981
|
if (n || t.mathRenderingModuleUrlImported !== !0) return n;
|
|
694
|
-
let r = Date.now() +
|
|
982
|
+
let r = Date.now() + Bt;
|
|
695
983
|
for (; Date.now() < r;) {
|
|
696
|
-
await new Promise((e) => setTimeout(e,
|
|
697
|
-
let e =
|
|
984
|
+
await new Promise((e) => setTimeout(e, zt));
|
|
985
|
+
let e = Gt();
|
|
698
986
|
if (e) return e;
|
|
699
987
|
}
|
|
700
988
|
return null;
|
|
@@ -703,14 +991,14 @@ var $ = async (e) => {
|
|
|
703
991
|
if (typeof window > "u") return;
|
|
704
992
|
let t = typeof e == "string", n;
|
|
705
993
|
t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
|
|
706
|
-
let r = Q(), i = r || t ? null : await
|
|
707
|
-
return r ? await r.renderMath?.(n) : i && i !== $ ? await i(n) : await
|
|
708
|
-
},
|
|
994
|
+
let r = Q(), i = r || t ? null : await Kt(n);
|
|
995
|
+
return r ? (await r.renderMath?.(n), q(n)) : i && i !== $ ? (await i(n), q(n)) : await Ut()(n), t ? n.innerHTML : void 0;
|
|
996
|
+
}, qt = (e, t) => {
|
|
709
997
|
let n = Q()?.wrapMath?.(e, t);
|
|
710
998
|
if (n != null) return n;
|
|
711
999
|
let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
|
|
712
|
-
return `${r}${
|
|
713
|
-
},
|
|
1000
|
+
return `${r}${pt(e)}${i}`;
|
|
1001
|
+
}, Jt = (e) => {
|
|
714
1002
|
let t = e.trim();
|
|
715
1003
|
return t.startsWith("\\[") && t.endsWith("\\]") ? {
|
|
716
1004
|
unwrapped: t.slice(2, -2).trim(),
|
|
@@ -737,6 +1025,6 @@ var $ = async (e) => {
|
|
|
737
1025
|
close: "$"
|
|
738
1026
|
}
|
|
739
1027
|
} : { unwrapped: t };
|
|
740
|
-
},
|
|
1028
|
+
}, Yt = (e) => Q()?.mmlToLatex?.(e) ?? e;
|
|
741
1029
|
//#endregion
|
|
742
|
-
export {
|
|
1030
|
+
export { Ze as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, J as UNSUPPORTED_PAGE_DOCS_URL, Pt as createMathjaxRenderer, Ft as getMathjaxCssUrls, Yt as mmlToLatex, $ as renderMath, Je as speakMathml, Jt as unWrapMath, qt as wrapMath };
|