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