@pie-element/shared-math-rendering-mathjax 0.1.7 → 0.1.8-next.20261019145129
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 +312 -284
- package/dist/index.js +328 -300
- package/dist/math-name.d.ts +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -136,75 +136,75 @@ function ae(e, t) {
|
|
|
136
136
|
i.src = n, i.async = !0, i.onload = () => t(!0), i.onerror = () => r(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(i);
|
|
137
137
|
})) : (v("untypeset"), Promise.resolve(!1));
|
|
138
138
|
}
|
|
139
|
-
var oe = globalThis, x = "PIE-MJX-CHTML-styles", se = ["MJX-CHTML-styles", "MJX-SVG-styles"], ce = re,
|
|
140
|
-
function
|
|
139
|
+
var oe = globalThis, x = "PIE-MJX-CHTML-styles", se = ["MJX-CHTML-styles", "MJX-SVG-styles"], ce = re, le = "http://www.w3.org/1998/Math/MathML", ue = /^([a-z_][\w.-]*):math$/, de = /^[a-z][a-z0-9-]*$/;
|
|
140
|
+
function fe(e) {
|
|
141
141
|
for (let t of e.querySelectorAll("*")) {
|
|
142
|
-
let n =
|
|
143
|
-
!n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(
|
|
142
|
+
let n = ue.exec(t.tagName.toLowerCase())?.[1];
|
|
143
|
+
!n || !e.contains(t) || t.closest("mjx-container") || t.replaceWith(pe(t, `${n}:`));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function pe(e, t) {
|
|
147
147
|
let n = e.tagName.toLowerCase().slice(t.length);
|
|
148
|
-
if (!
|
|
149
|
-
let r = e.ownerDocument.createElementNS(
|
|
148
|
+
if (!de.test(n)) return e;
|
|
149
|
+
let r = e.ownerDocument.createElementNS(le, n);
|
|
150
150
|
for (let t of e.attributes) r.setAttribute(t.name, t.value);
|
|
151
151
|
for (let n of [...e.childNodes]) {
|
|
152
152
|
let e = n instanceof Element && n.tagName.toLowerCase().startsWith(t);
|
|
153
|
-
r.appendChild(e ?
|
|
153
|
+
r.appendChild(e ? pe(n, t) : n);
|
|
154
154
|
}
|
|
155
155
|
return r;
|
|
156
156
|
}
|
|
157
157
|
//#endregion
|
|
158
158
|
//#region src/elementary-math.ts
|
|
159
|
-
var
|
|
159
|
+
var me = /* @__PURE__ */ new Set([
|
|
160
160
|
"updiagonalstrike",
|
|
161
161
|
"downdiagonalstrike",
|
|
162
162
|
"verticalstrike",
|
|
163
163
|
"horizontalstrike"
|
|
164
|
-
]),
|
|
164
|
+
]), he = {
|
|
165
165
|
thin: "0.035em",
|
|
166
166
|
medium: "0.07em",
|
|
167
167
|
thick: "0.14em"
|
|
168
|
-
},
|
|
168
|
+
}, ge = {
|
|
169
169
|
tight: "0em",
|
|
170
170
|
medium: "0.1em",
|
|
171
171
|
loose: "0.2em"
|
|
172
|
-
},
|
|
172
|
+
}, _e = /^(\d+(\.\d*)?|\.\d+)(em|ex|px|pt|pc|in|cm|mm)$/, ve = /^(#[0-9a-f]{3,8}|[a-z]+)$/i, ye = /^(\d+(\.\d*)?|\.\d+)$/, be = /* @__PURE__ */ new Set([
|
|
173
173
|
"mn",
|
|
174
174
|
"mo",
|
|
175
175
|
"mi",
|
|
176
176
|
"mtext"
|
|
177
|
-
]),
|
|
177
|
+
]), xe = /* @__PURE__ */ new Set([
|
|
178
178
|
"stackalign",
|
|
179
179
|
"charalign",
|
|
180
180
|
"charspacing",
|
|
181
181
|
"longdivstyle"
|
|
182
182
|
]);
|
|
183
|
-
function
|
|
184
|
-
let i = e.createElementNS(
|
|
183
|
+
function S(e, t, n = [], r = {}) {
|
|
184
|
+
let i = e.createElementNS(le, t);
|
|
185
185
|
for (let [e, t] of Object.entries(r)) i.setAttribute(e, t);
|
|
186
186
|
for (let e of n) e && i.appendChild(e);
|
|
187
187
|
return i;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
let n =
|
|
189
|
+
function C(e, t) {
|
|
190
|
+
let n = S(e.document, "mo");
|
|
191
191
|
return n.textContent = t, n;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
let t =
|
|
195
|
-
return t.textContent = "0",
|
|
193
|
+
function Se(e) {
|
|
194
|
+
let t = S(e.document, "mn");
|
|
195
|
+
return t.textContent = "0", S(e.document, "mphantom", [t]);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function w(e, t) {
|
|
198
198
|
return e.getAttribute(t)?.trim().toLowerCase() || void 0;
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function T(e, t) {
|
|
201
201
|
let n = Number.parseInt(e.getAttribute(t) ?? "", 10);
|
|
202
202
|
return Number.isFinite(n) ? n : 0;
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function E(e) {
|
|
205
205
|
return e.localName === "none" || e.localName === "mrow" && e.children.length === 0 && !e.textContent?.trim();
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function D(e, t, n = e) {
|
|
208
208
|
switch (t) {
|
|
209
209
|
case "left": return 0;
|
|
210
210
|
case "center": return Math.floor(e / 2);
|
|
@@ -212,14 +212,14 @@ function A(e, t, n = e) {
|
|
|
212
212
|
default: return n;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function O(e, t, n) {
|
|
216
216
|
let r = [], i, a, o = (e, t) => {
|
|
217
217
|
let s = (e) => t.reduceRight((e, t) => {
|
|
218
218
|
let n = t.cloneNode(!1);
|
|
219
219
|
return n.appendChild(e), n;
|
|
220
220
|
}, e);
|
|
221
221
|
if (e.localName === "mstyle") for (let n of [...e.children]) o(n, [...t, e]);
|
|
222
|
-
else if (
|
|
222
|
+
else if (E(e)) r.push(null);
|
|
223
223
|
else if (e.localName === "mn" && e.children.length === 0) {
|
|
224
224
|
let t = [...(e.textContent ?? "").trim()];
|
|
225
225
|
for (let a of t) {
|
|
@@ -228,28 +228,28 @@ function j(e, t, n) {
|
|
|
228
228
|
t.textContent = a, r.push(s(t));
|
|
229
229
|
}
|
|
230
230
|
t.length && (a ??= r.length);
|
|
231
|
-
} else
|
|
231
|
+
} else be.has(e.localName) && e.textContent?.trim() === n.decimalPoint && (i ??= r.length), r.push(s(e));
|
|
232
232
|
};
|
|
233
233
|
for (let t of e) o(t, []);
|
|
234
234
|
return {
|
|
235
235
|
kind: "digits",
|
|
236
236
|
cells: r,
|
|
237
|
-
anchor:
|
|
237
|
+
anchor: D(r.length, n.stackAlign, i ?? a),
|
|
238
238
|
position: t
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
function
|
|
242
|
-
return (e ?? "").toLowerCase().split(/\s+/).filter((e) =>
|
|
241
|
+
function k(e) {
|
|
242
|
+
return (e ?? "").toLowerCase().split(/\s+/).filter((e) => me.has(e));
|
|
243
243
|
}
|
|
244
|
-
function
|
|
245
|
-
let n = [...e.children].filter((e) => !
|
|
246
|
-
return n.length <= 1 ? n[0] ?? null :
|
|
244
|
+
function Ce(e, t) {
|
|
245
|
+
let n = [...e.children].filter((e) => !E(e));
|
|
246
|
+
return n.length <= 1 ? n[0] ?? null : S(t.document, "mrow", n);
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
let r =
|
|
250
|
-
content:
|
|
251
|
-
location:
|
|
252
|
-
crossout: e.hasAttribute("crossout") ?
|
|
248
|
+
function we(e, t, n) {
|
|
249
|
+
let r = w(e, "location") ?? "n", i = k(e.getAttribute("crossout")), a = [...e.children].map((e) => E(e) ? null : e.localName === "mscarry" ? {
|
|
250
|
+
content: Ce(e, n),
|
|
251
|
+
location: w(e, "location") ?? r,
|
|
252
|
+
crossout: e.hasAttribute("crossout") ? k(e.getAttribute("crossout")) : i
|
|
253
253
|
} : {
|
|
254
254
|
content: e,
|
|
255
255
|
location: r,
|
|
@@ -258,60 +258,60 @@ function Se(e, t, n) {
|
|
|
258
258
|
return {
|
|
259
259
|
kind: "carries",
|
|
260
260
|
carries: a,
|
|
261
|
-
anchor:
|
|
261
|
+
anchor: D(a.length, n.stackAlign),
|
|
262
262
|
position: t,
|
|
263
|
-
scale:
|
|
263
|
+
scale: ye.test(o) ? o : "0.6"
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
-
function
|
|
267
|
-
let t =
|
|
268
|
-
return `${n} solid ${
|
|
266
|
+
function A(e) {
|
|
267
|
+
let t = w(e, "mslinethickness") ?? "medium", n = he[t] ?? (_e.test(t) ? t : "0.07em"), r = e.getAttribute("mathcolor")?.trim() ?? "";
|
|
268
|
+
return `${n} solid ${ve.test(r) ? r : "currentColor"}`;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
let r = Math.max(0,
|
|
270
|
+
function Te(e, t, n) {
|
|
271
|
+
let r = Math.max(0, T(e, "length"));
|
|
272
272
|
return {
|
|
273
273
|
kind: "line",
|
|
274
274
|
length: r,
|
|
275
|
-
anchor:
|
|
275
|
+
anchor: D(r, n.stackAlign),
|
|
276
276
|
position: t,
|
|
277
|
-
border:
|
|
277
|
+
border: A(e)
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function j(e, t, n, r, i) {
|
|
281
281
|
e.forEach((e, a) => {
|
|
282
|
-
let o = t + a * n +
|
|
282
|
+
let o = t + a * n + T(e, "position");
|
|
283
283
|
switch (e.localName) {
|
|
284
284
|
case "msgroup":
|
|
285
|
-
|
|
285
|
+
j([...e.children], o, T(e, "shift"), r, i);
|
|
286
286
|
break;
|
|
287
287
|
case "msline":
|
|
288
|
-
i.push(
|
|
288
|
+
i.push(Te(e, o, r));
|
|
289
289
|
break;
|
|
290
290
|
case "mscarries":
|
|
291
|
-
i.push(
|
|
291
|
+
i.push(we(e, o, r));
|
|
292
292
|
break;
|
|
293
293
|
case "msrow":
|
|
294
294
|
case "mrow":
|
|
295
|
-
i.push(
|
|
295
|
+
i.push(O([...e.children], o, r));
|
|
296
296
|
break;
|
|
297
|
-
default: i.push(
|
|
297
|
+
default: i.push(O([e], o, r));
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function M(e) {
|
|
302
302
|
return -e.anchor - e.position;
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function N(e) {
|
|
305
305
|
return e.kind === "digits" ? e.cells.length : e.kind === "carries" ? e.carries.length : e.length;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
return
|
|
307
|
+
function P(e) {
|
|
308
|
+
return M(e) + N(e) - 1;
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
let i = (e) =>
|
|
310
|
+
function Ee(e, t, n, r) {
|
|
311
|
+
let i = (e) => S(r.document, "mpadded", [t], {
|
|
312
312
|
width: "0",
|
|
313
313
|
...e ? { lspace: e } : {}
|
|
314
|
-
}), a = (e, t) =>
|
|
314
|
+
}), a = (e, t) => S(r.document, e, t);
|
|
315
315
|
switch (n) {
|
|
316
316
|
case "s": return a("munder", [e, i("-0.5width")]);
|
|
317
317
|
case "ne": return a("msup", [e, i()]);
|
|
@@ -333,49 +333,49 @@ function De(e, t, n, r) {
|
|
|
333
333
|
default: return a("mover", [e, i("-0.5width")]);
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
let r =
|
|
336
|
+
function De(e, t, n) {
|
|
337
|
+
let r = S(n.document, "menclose", [e], {
|
|
338
338
|
notation: t.join(" "),
|
|
339
339
|
"data-padding": "0.1em",
|
|
340
340
|
"data-thickness": "0.067em"
|
|
341
341
|
}), i = t.some((e) => e.endsWith("diagonalstrike")) ? .167 : t.includes("horizontalstrike") ? .1 : 0;
|
|
342
|
-
return i ?
|
|
342
|
+
return i ? S(n.document, "mpadded", [r], {
|
|
343
343
|
lspace: `-${i}em`,
|
|
344
344
|
width: `-${2 * i}em`
|
|
345
345
|
}) : r;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
348
|
-
let a = e && t.crossout.length ?
|
|
347
|
+
function Oe(e, t, n, r, i) {
|
|
348
|
+
let a = e && t.crossout.length ? De(e, t.crossout, i) : e;
|
|
349
349
|
if (!t.content) return a;
|
|
350
|
-
let o =
|
|
351
|
-
return
|
|
350
|
+
let o = S(i.document, "mstyle", [t.content], { scriptsizemultiplier: r });
|
|
351
|
+
return Ee(a ?? Se(i), o, n, i);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
return e.carries[t -
|
|
353
|
+
function ke(e, t) {
|
|
354
|
+
return e.carries[t - M(e)] ?? null;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function Ae(e, t, n, r) {
|
|
357
357
|
let i = e.content;
|
|
358
358
|
n.forEach((e, a) => {
|
|
359
|
-
let o = n.length - 1 - a, s = n[o], c =
|
|
359
|
+
let o = n.length - 1 - a, s = n[o], c = ke(s, t), l = n.slice(0, o).some((e) => ke(e, t));
|
|
360
360
|
if (!c && !l) return;
|
|
361
361
|
let u = c ?? {
|
|
362
|
-
content:
|
|
362
|
+
content: Se(r),
|
|
363
363
|
location: "n",
|
|
364
364
|
crossout: []
|
|
365
365
|
}, d = a === 0 ? u.location : "n";
|
|
366
|
-
i =
|
|
366
|
+
i = Oe(i, u, d, s.scale, r);
|
|
367
367
|
}), e.content = i;
|
|
368
368
|
}
|
|
369
|
-
function
|
|
370
|
-
let n = e.filter((e) =>
|
|
369
|
+
function je(e, t) {
|
|
370
|
+
let n = e.filter((e) => N(e) > 0), r = Math.min(0, ...n.map(M)), i = Math.max(r, ...n.map(P)) - r + 1, a = -r, o = [], s = /* @__PURE__ */ new Map(), c = () => Array.from({ length: i }, () => ({
|
|
371
371
|
content: null,
|
|
372
372
|
borders: {}
|
|
373
|
-
})), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a +
|
|
373
|
+
})), l = (e) => e.length === 0 ? Array.from({ length: i }, (e, t) => t) : Array.from({ length: e.length }, (t, n) => a + M(e) + n), u = [], d = [], f = (e) => {
|
|
374
374
|
let n = c();
|
|
375
375
|
e.cells.forEach((t, r) => {
|
|
376
|
-
n[a +
|
|
376
|
+
n[a + M(e) + r].content = t;
|
|
377
377
|
}), u.length && n.forEach((e, n) => {
|
|
378
|
-
|
|
378
|
+
Ae(e, n - a, u, t);
|
|
379
379
|
});
|
|
380
380
|
for (let e of d) for (let t of l(e)) n[t].borders.top = e.border;
|
|
381
381
|
u = [], d = [], s.set(e, o.length), o.push(n);
|
|
@@ -395,44 +395,44 @@ function Me(e, t) {
|
|
|
395
395
|
origin: a
|
|
396
396
|
};
|
|
397
397
|
}
|
|
398
|
-
function
|
|
399
|
-
let r =
|
|
398
|
+
function Me(e, { rows: t }, n) {
|
|
399
|
+
let r = S(n.document, "mtable", t.map((e) => S(n.document, "mtr", e.map((e) => {
|
|
400
400
|
let t = Object.entries(e.borders).map(([e, t]) => `border-${e}:${t}`).join(";");
|
|
401
|
-
return
|
|
401
|
+
return S(n.document, "mtd", [e.content], {
|
|
402
402
|
...t ? { style: t } : {},
|
|
403
403
|
...e.align ? { columnalign: e.align } : {}
|
|
404
404
|
});
|
|
405
405
|
}))));
|
|
406
|
-
for (let { name: t, value: n } of [...e.attributes])
|
|
407
|
-
let i =
|
|
408
|
-
return r.setAttribute("columnspacing",
|
|
406
|
+
for (let { name: t, value: n } of [...e.attributes]) xe.has(t) || r.setAttribute(t, n);
|
|
407
|
+
let i = w(e, "charspacing") ?? "medium", a = w(e, "charalign");
|
|
408
|
+
return r.setAttribute("columnspacing", ge[i] ?? (_e.test(i) ? i : ge.medium)), r.setAttribute("columnalign", a === "left" || a === "center" ? a : "right"), r.setAttribute("rowspacing", "0"), r.setAttribute("align", e.getAttribute("align") ?? "baseline"), r;
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Ne(e) {
|
|
411
411
|
return {
|
|
412
412
|
document: e.ownerDocument,
|
|
413
|
-
stackAlign:
|
|
413
|
+
stackAlign: w(e, "stackalign") ?? "decimalpoint",
|
|
414
414
|
decimalPoint: e.closest("[decimalpoint]")?.getAttribute("decimalpoint")?.trim().charAt(0) || "."
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
|
-
function
|
|
418
|
-
let t =
|
|
419
|
-
return
|
|
417
|
+
function Pe(e) {
|
|
418
|
+
let t = Ne(e), n = [];
|
|
419
|
+
return j([...e.children], 0, 0, t, n), Me(e, je(n, t), t);
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function F(e, t, n, r, i, a) {
|
|
422
422
|
for (let o = n; o <= r; o++) e[t][o].borders[i] = a;
|
|
423
423
|
}
|
|
424
|
-
function
|
|
425
|
-
let n =
|
|
426
|
-
return n.setAttribute("minsize", "1.2em"), [
|
|
424
|
+
function Fe(e, t) {
|
|
425
|
+
let n = C(t, ")");
|
|
426
|
+
return n.setAttribute("minsize", "1.2em"), [S(t.document, "mrow", [e, S(t.document, "mspace", [], { width: "0.2em" })]), S(t.document, "mpadded", [n], {
|
|
427
427
|
voffset: "0.1em",
|
|
428
428
|
lspace: "-0.15em",
|
|
429
429
|
depth: "-0.2em",
|
|
430
430
|
height: "-0.2em"
|
|
431
431
|
})];
|
|
432
432
|
}
|
|
433
|
-
function
|
|
434
|
-
let t =
|
|
435
|
-
|
|
433
|
+
function Ie(e) {
|
|
434
|
+
let t = Ne(e), [n, r, ...i] = [...e.children], a = n && !E(n) ? n : null, o = r && !E(r) ? r : null, s = w(e, "longdivstyle") ?? "lefttop", c = A(e), l = [];
|
|
435
|
+
j(i, 0, 0, t, l);
|
|
436
436
|
let u = l.find((e) => e.kind === "digits");
|
|
437
437
|
u || (u = {
|
|
438
438
|
kind: "digits",
|
|
@@ -444,51 +444,51 @@ function Le(e) {
|
|
|
444
444
|
u.cells.unshift(...e), u.anchor += e.length;
|
|
445
445
|
}, p = (...e) => {
|
|
446
446
|
let n = e.flatMap((e) => e ? e.localName === "mrow" ? [...e.children] : [e] : []);
|
|
447
|
-
u.cells.push(...
|
|
447
|
+
u.cells.push(...O(n, 0, t).cells);
|
|
448
448
|
};
|
|
449
449
|
switch (s) {
|
|
450
450
|
case "left/\\right":
|
|
451
|
-
f(a,
|
|
451
|
+
f(a, C(t, "/")), p(C(t, "\\"), o);
|
|
452
452
|
break;
|
|
453
453
|
case "left)(right":
|
|
454
|
-
f(a,
|
|
454
|
+
f(a, C(t, ")")), p(C(t, "("), o);
|
|
455
455
|
break;
|
|
456
456
|
case ":right=right":
|
|
457
|
-
p(
|
|
457
|
+
p(C(t, ":"), a, C(t, "="), o);
|
|
458
458
|
break;
|
|
459
459
|
case "righttop":
|
|
460
460
|
case "stackedleftlinetop":
|
|
461
461
|
case "lefttop":
|
|
462
|
-
o &&
|
|
462
|
+
o && j([o], 0, 0, t, d), l.splice(l.indexOf(u), 0, ...d), s === "righttop" ? p(a) : s === "stackedleftlinetop" ? f(a) : f(...Fe(a, t));
|
|
463
463
|
break;
|
|
464
464
|
}
|
|
465
|
-
let m =
|
|
465
|
+
let m = je(l, t), h = m.rows, g = m.rowOf.get(u) ?? 0, _ = (e) => m.origin + M(u) + e, v = Math.max(_(u.cells.length - 1), ...d.map((e) => m.origin + P(e)));
|
|
466
466
|
switch (s) {
|
|
467
467
|
case "left/\\right":
|
|
468
468
|
case "left)(right":
|
|
469
469
|
case ":right=right": break;
|
|
470
470
|
case "righttop": {
|
|
471
471
|
let e = h[g][_(u.cells.length - 1)];
|
|
472
|
-
e.borders.left = c, e.borders.bottom = c,
|
|
472
|
+
e.borders.left = c, e.borders.bottom = c, F(h, g, _(0), _(u.cells.length - 1), "top", c);
|
|
473
473
|
break;
|
|
474
474
|
}
|
|
475
475
|
case "stackedleftlinetop": {
|
|
476
476
|
let e = h[g][_(0)];
|
|
477
|
-
e.borders.right = c, e.borders.bottom = c,
|
|
477
|
+
e.borders.right = c, e.borders.bottom = c, F(h, g, _(1), v, "top", c);
|
|
478
478
|
break;
|
|
479
479
|
}
|
|
480
480
|
case "stackedrightright":
|
|
481
481
|
case "mediumstackedrightright":
|
|
482
482
|
case "shortstackedrightright":
|
|
483
483
|
case "stackedleftleft":
|
|
484
|
-
|
|
484
|
+
Le(h, g, s, a, o, c, t);
|
|
485
485
|
break;
|
|
486
|
-
default:
|
|
486
|
+
default: F(h, g, _(1), v, "top", c);
|
|
487
487
|
}
|
|
488
|
-
return
|
|
488
|
+
return Me(e, m, t);
|
|
489
489
|
}
|
|
490
|
-
function
|
|
491
|
-
let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e &&
|
|
490
|
+
function Le(e, t, n, r, i, a, o) {
|
|
491
|
+
let s = n === "stackedleftleft", c = s ? "right" : "left", l = (e) => e && S(o.document, "mpadded", [e], {
|
|
492
492
|
lspace: "0.2em",
|
|
493
493
|
width: "+0.4em"
|
|
494
494
|
});
|
|
@@ -507,55 +507,55 @@ function Re(e, t, n, r, i, a, o) {
|
|
|
507
507
|
}) : 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);
|
|
508
508
|
});
|
|
509
509
|
}
|
|
510
|
-
function
|
|
511
|
-
for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ?
|
|
510
|
+
function Re(e) {
|
|
511
|
+
for (let t of [...e.querySelectorAll("mstack, mlongdiv")]) !t.closest("math") || t.closest("mjx-container") || t.replaceWith(t.localName === "mstack" ? Pe(t) : Ie(t));
|
|
512
512
|
}
|
|
513
513
|
//#endregion
|
|
514
514
|
//#region src/explorer-styles.ts
|
|
515
|
-
var
|
|
515
|
+
var ze = "PIE-MJX-explorer-styles", I = "var(--pie-text, black)", Be = "var(--pie-background, #ffffff)", Ve = "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)`, He = `
|
|
516
516
|
:root mjx-container [data-sre-highlight-1]:not([data-mjx-collapsed], rect) {
|
|
517
|
-
color: ${
|
|
518
|
-
fill: ${
|
|
517
|
+
color: ${I} !important;
|
|
518
|
+
fill: ${I} !important;
|
|
519
519
|
}
|
|
520
520
|
:root mjx-container:not([data-mjx-clone-container]) [data-sre-highlight-1]:not([data-sre-enclosed], rect) {
|
|
521
|
-
background-color: ${
|
|
521
|
+
background-color: ${R} !important;
|
|
522
522
|
}
|
|
523
523
|
:root mjx-container rect[data-sre-highlight-1]:not([data-sre-enclosed]) {
|
|
524
|
-
fill: ${
|
|
524
|
+
fill: ${R} !important;
|
|
525
525
|
}
|
|
526
526
|
:root mjx-container .mjx-selected {
|
|
527
|
-
outline: 2px solid ${
|
|
527
|
+
outline: 2px solid ${L} !important;
|
|
528
528
|
}
|
|
529
529
|
:root mjx-container [data-sre-highlight-2] {
|
|
530
|
-
color: ${
|
|
530
|
+
color: ${I} !important;
|
|
531
531
|
background-color: transparent !important;
|
|
532
|
-
fill: ${
|
|
533
|
-
outline: 2px dashed ${
|
|
532
|
+
fill: ${I} !important;
|
|
533
|
+
outline: 2px dashed ${L} !important;
|
|
534
534
|
}
|
|
535
535
|
:root mjx-container rect[data-sre-highlight-2] {
|
|
536
536
|
fill: transparent !important;
|
|
537
|
-
stroke: ${
|
|
537
|
+
stroke: ${L} !important;
|
|
538
538
|
stroke-width: 2px !important;
|
|
539
539
|
vector-effect: non-scaling-stroke;
|
|
540
540
|
}
|
|
541
541
|
:root .MJX_LiveRegion, :root .MJX_HoverRegion, :root .MJX_ToolTip {
|
|
542
|
-
color: ${
|
|
543
|
-
background-color: ${
|
|
544
|
-
border-color: ${
|
|
542
|
+
color: ${I} !important;
|
|
543
|
+
background-color: ${Be} !important;
|
|
544
|
+
border-color: ${Ve} !important;
|
|
545
545
|
}
|
|
546
546
|
:root .MJX_LiveRegion > div, :root .MJX_HoverRegion > div {
|
|
547
|
-
color: ${
|
|
548
|
-
background-color: ${
|
|
547
|
+
color: ${I} !important;
|
|
548
|
+
background-color: ${R} !important;
|
|
549
549
|
}
|
|
550
550
|
`;
|
|
551
|
-
function
|
|
551
|
+
function Ue(e = document) {
|
|
552
552
|
if (e.getElementById("PIE-MJX-explorer-styles")) return;
|
|
553
553
|
let t = e.createElement("style");
|
|
554
|
-
t.id =
|
|
554
|
+
t.id = ze, t.textContent = He, e.head.appendChild(t);
|
|
555
555
|
}
|
|
556
556
|
//#endregion
|
|
557
557
|
//#region src/math-speech.ts
|
|
558
|
-
var
|
|
558
|
+
var We = /[-]/g, Ge = {
|
|
559
559
|
"+": "positive",
|
|
560
560
|
"-": "negative",
|
|
561
561
|
"−": "negative",
|
|
@@ -568,20 +568,20 @@ var Ge = /[-]/g, R = {
|
|
|
568
568
|
"⟨": "open angle bracket",
|
|
569
569
|
"⌊": "open floor",
|
|
570
570
|
"⌈": "open ceiling"
|
|
571
|
-
},
|
|
571
|
+
}, qe = {
|
|
572
572
|
")": "close parenthesis",
|
|
573
573
|
"]": "close bracket",
|
|
574
574
|
"}": "close brace",
|
|
575
575
|
"⟩": "close angle bracket",
|
|
576
576
|
"⌋": "close floor",
|
|
577
577
|
"⌉": "close ceiling"
|
|
578
|
-
},
|
|
578
|
+
}, z = {
|
|
579
579
|
"!": "factorial",
|
|
580
580
|
"%": "percent",
|
|
581
581
|
"°": "degrees",
|
|
582
582
|
"′": "prime",
|
|
583
583
|
"″": "double prime"
|
|
584
|
-
},
|
|
584
|
+
}, Je = {
|
|
585
585
|
"+": "plus",
|
|
586
586
|
"-": "minus",
|
|
587
587
|
"−": "minus",
|
|
@@ -626,15 +626,15 @@ var Ge = /[-]/g, R = {
|
|
|
626
626
|
"|": "vertical bar",
|
|
627
627
|
"‖": "double vertical bar",
|
|
628
628
|
...Ke,
|
|
629
|
-
...
|
|
630
|
-
...
|
|
631
|
-
},
|
|
629
|
+
...qe,
|
|
630
|
+
...z
|
|
631
|
+
}, Ye = /* @__PURE__ */ new Set(["|", "‖"]), Xe = /* @__PURE__ */ new Set([
|
|
632
632
|
"∑",
|
|
633
633
|
"∏",
|
|
634
634
|
"∫",
|
|
635
635
|
"∪",
|
|
636
636
|
"∩"
|
|
637
|
-
]),
|
|
637
|
+
]), Ze = {
|
|
638
638
|
α: "alpha",
|
|
639
639
|
β: "beta",
|
|
640
640
|
γ: "gamma",
|
|
@@ -661,7 +661,7 @@ var Ge = /[-]/g, R = {
|
|
|
661
661
|
cot: "cotangent",
|
|
662
662
|
ln: "natural log",
|
|
663
663
|
lim: "limit"
|
|
664
|
-
},
|
|
664
|
+
}, Qe = {
|
|
665
665
|
"¯": "bar",
|
|
666
666
|
"‾": "bar",
|
|
667
667
|
"―": "bar",
|
|
@@ -672,139 +672,139 @@ var Ge = /[-]/g, R = {
|
|
|
672
672
|
"→": "vector",
|
|
673
673
|
"⃗": "vector",
|
|
674
674
|
"˙": "dot"
|
|
675
|
-
},
|
|
676
|
-
function
|
|
675
|
+
}, B = (e) => (e.textContent ?? "").replace(We, "").replace(/\s+/g, " ").trim(), V = (e) => e.replace(/\s+/g, " ").trim(), H = (e) => [...e.children];
|
|
676
|
+
function U(e) {
|
|
677
677
|
return !e || [
|
|
678
678
|
"mn",
|
|
679
679
|
"mi",
|
|
680
680
|
"mtext",
|
|
681
681
|
"mo"
|
|
682
|
-
].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ?
|
|
682
|
+
].includes(e.localName) ? !0 : ["mrow", "mstyle"].includes(e.localName) && e.children.length === 1 ? U(e.children[0]) : !1;
|
|
683
683
|
}
|
|
684
|
-
function
|
|
685
|
-
let t = e ?
|
|
684
|
+
function $e(e) {
|
|
685
|
+
let t = e ? B(e) : "";
|
|
686
686
|
return /^\d{1,3}$/.test(t) ? Number(t) : void 0;
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function et(e) {
|
|
689
689
|
return `${e}${e % 100 >= 11 && e % 100 <= 13 ? "th" : {
|
|
690
690
|
1: "st",
|
|
691
691
|
2: "nd",
|
|
692
692
|
3: "rd"
|
|
693
693
|
}[e % 10] ?? "th"}`;
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return
|
|
695
|
+
function tt(e) {
|
|
696
|
+
return Ze[e] ?? e;
|
|
697
697
|
}
|
|
698
|
-
function
|
|
699
|
-
return
|
|
698
|
+
function W(e) {
|
|
699
|
+
return Je[e] ?? e;
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function G(e) {
|
|
702
702
|
let t = [], n = !1;
|
|
703
703
|
for (let r of e) {
|
|
704
704
|
if (r.localName !== "mo") {
|
|
705
|
-
t.push(
|
|
705
|
+
t.push(K(r)), n = !0;
|
|
706
706
|
continue;
|
|
707
707
|
}
|
|
708
|
-
let e =
|
|
709
|
-
e && (!n &&
|
|
708
|
+
let e = B(r);
|
|
709
|
+
e && (!n && Ge[e] ? t.push(Ge[e]) : e in z ? t.push(z[e]) : (t.push(W(e)), n = e in qe || Ye.has(e) && n));
|
|
710
710
|
}
|
|
711
711
|
return t.filter(Boolean).join(" ");
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(
|
|
715
|
-
if (a.length && i(t) && i(r) &&
|
|
716
|
-
let e =
|
|
717
|
-
return
|
|
713
|
+
function nt(e) {
|
|
714
|
+
let [t, ...n] = e, r = n[n.length - 1], i = (e) => e?.localName === "mo" && ["|", "‖"].includes(B(e)), a = n.slice(0, -1);
|
|
715
|
+
if (a.length && i(t) && i(r) && B(t) === B(r) && !a.some(i)) {
|
|
716
|
+
let e = V(G(a));
|
|
717
|
+
return B(t) === "|" ? `absolute value of ${e} end absolute value` : `norm of ${e} end norm`;
|
|
718
718
|
}
|
|
719
|
-
return
|
|
719
|
+
return G(e);
|
|
720
720
|
}
|
|
721
|
-
function
|
|
722
|
-
let n = e ?
|
|
723
|
-
return
|
|
721
|
+
function rt(e, t) {
|
|
722
|
+
let n = e ? K(e) : "", r = t ? K(t) : "";
|
|
723
|
+
return U(e) && U(t) ? `${n} over ${r}` : `the fraction with numerator ${n} and denominator ${r}`;
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function it(e, t, n) {
|
|
726
726
|
return n ? `${t} of ${e}` : `${t} of ${e} end root`;
|
|
727
727
|
}
|
|
728
|
-
function
|
|
729
|
-
let n = t ?
|
|
730
|
-
if (t &&
|
|
728
|
+
function at(e, t) {
|
|
729
|
+
let n = t ? B(t) : "";
|
|
730
|
+
if (t && U(t)) {
|
|
731
731
|
if (n === "2") return `${e} squared`;
|
|
732
732
|
if (n === "3") return `${e} cubed`;
|
|
733
|
-
if (n in
|
|
733
|
+
if (n in z) return `${e} ${z[n]}`;
|
|
734
734
|
}
|
|
735
|
-
let r = t ?
|
|
736
|
-
return
|
|
735
|
+
let r = t ? K(t) : "";
|
|
736
|
+
return U(t) ? `${e} to the power of ${r}` : `${e} to the power of ${r} end power`;
|
|
737
737
|
}
|
|
738
|
-
function
|
|
739
|
-
let n = t ?
|
|
740
|
-
return
|
|
741
|
-
}
|
|
742
|
-
function
|
|
743
|
-
let r =
|
|
744
|
-
if (r === "lim") return `limit as ${t ?
|
|
745
|
-
if (!
|
|
746
|
-
let i = t ? `from ${
|
|
747
|
-
return `${
|
|
748
|
-
}
|
|
749
|
-
function st(e) {
|
|
750
|
-
let t = U(e).filter((e) => ["mtr", "mlabeledtr"].includes(e.localName)), n = t.map((e) => U(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) => H(K(U(e)))).join(", ")}`);
|
|
751
|
-
return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
|
|
738
|
+
function ot(e, t) {
|
|
739
|
+
let n = t ? K(t) : "";
|
|
740
|
+
return U(t) ? `${e} sub ${n}` : `${e} sub ${n} end sub`;
|
|
741
|
+
}
|
|
742
|
+
function st(e, t, n) {
|
|
743
|
+
let r = B(e);
|
|
744
|
+
if (r === "lim") return `limit as ${t ? K(t) : ""} of`;
|
|
745
|
+
if (!Xe.has(r)) return;
|
|
746
|
+
let i = t ? `from ${K(t)}` : "", a = n ? `to ${K(n)}` : "";
|
|
747
|
+
return `${W(r)} ${i} ${a} of`;
|
|
752
748
|
}
|
|
753
749
|
function ct(e) {
|
|
754
|
-
let t = e.
|
|
750
|
+
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(", ")}`);
|
|
751
|
+
return `table with ${t.length} ${t.length === 1 ? "row" : "rows"} and ${r} ${r === 1 ? "column" : "columns"}. ${i.join(". ")}`;
|
|
752
|
+
}
|
|
753
|
+
function lt(e) {
|
|
754
|
+
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));
|
|
755
755
|
return [
|
|
756
|
-
|
|
756
|
+
W(t),
|
|
757
757
|
...i,
|
|
758
|
-
|
|
758
|
+
W(n)
|
|
759
759
|
].filter(Boolean).join(" ");
|
|
760
760
|
}
|
|
761
|
-
function
|
|
762
|
-
let t =
|
|
761
|
+
function K(e) {
|
|
762
|
+
let t = H(e);
|
|
763
763
|
switch (e.localName) {
|
|
764
|
-
case "mi": return
|
|
764
|
+
case "mi": return tt(B(e));
|
|
765
765
|
case "mn":
|
|
766
766
|
case "mtext":
|
|
767
|
-
case "ms": return
|
|
768
|
-
case "mo": return
|
|
767
|
+
case "ms": return B(e);
|
|
768
|
+
case "mo": return W(B(e));
|
|
769
769
|
case "mspace":
|
|
770
770
|
case "mphantom":
|
|
771
771
|
case "annotation":
|
|
772
772
|
case "annotation-xml": return "";
|
|
773
|
-
case "semantics": return t[0] ?
|
|
774
|
-
case "mfrac": return
|
|
775
|
-
case "msqrt": return
|
|
773
|
+
case "semantics": return t[0] ? K(t[0]) : "";
|
|
774
|
+
case "mfrac": return rt(t[0], t[1]);
|
|
775
|
+
case "msqrt": return it(V(G(t)), "square root", t.length === 1 && U(t[0]));
|
|
776
776
|
case "mroot": {
|
|
777
|
-
let e =
|
|
778
|
-
return
|
|
777
|
+
let e = $e(t[1]), n = e === 2 ? "square root" : e === 3 ? "cube root" : e ? `${et(e)} root` : `root with index ${t[1] ? K(t[1]) : ""}`;
|
|
778
|
+
return it(t[0] ? K(t[0]) : "", n, U(t[0]));
|
|
779
779
|
}
|
|
780
|
-
case "msup": return
|
|
781
|
-
case "msub": return
|
|
782
|
-
case "msubsup": return (t[0] ?
|
|
780
|
+
case "msup": return at(t[0] ? K(t[0]) : "", t[1]);
|
|
781
|
+
case "msub": return ot(t[0] ? K(t[0]) : "", t[1]);
|
|
782
|
+
case "msubsup": return (t[0] ? st(t[0], t[1], t[2]) : void 0) || at(ot(t[0] ? K(t[0]) : "", t[1]), t[2]);
|
|
783
783
|
case "munder":
|
|
784
784
|
case "mover":
|
|
785
785
|
case "munderover": {
|
|
786
|
-
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 ?
|
|
786
|
+
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 ? st(n, a, o) : void 0;
|
|
787
787
|
if (s) return s;
|
|
788
|
-
let c = n ?
|
|
788
|
+
let c = n ? K(n) : "", l = e.localName === "mover" && r ? Qe[B(r)] : void 0;
|
|
789
789
|
return l ? l === "vector" ? `vector ${c}` : `${c} ${l}` : [
|
|
790
790
|
c,
|
|
791
|
-
a ? `with ${
|
|
792
|
-
o ? `with ${
|
|
791
|
+
a ? `with ${K(a)} below` : "",
|
|
792
|
+
o ? `with ${K(o)} above` : ""
|
|
793
793
|
].filter(Boolean).join(" ");
|
|
794
794
|
}
|
|
795
|
-
case "mfenced": return
|
|
796
|
-
case "mtable": return
|
|
795
|
+
case "mfenced": return lt(e);
|
|
796
|
+
case "mtable": return ct(e);
|
|
797
797
|
case "mrow":
|
|
798
|
-
case "math": return
|
|
799
|
-
default: return t.length ?
|
|
798
|
+
case "math": return nt(t);
|
|
799
|
+
default: return t.length ? G(t) : B(e);
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
|
-
function
|
|
803
|
-
return
|
|
802
|
+
function ut(e) {
|
|
803
|
+
return V(K(e));
|
|
804
804
|
}
|
|
805
805
|
//#endregion
|
|
806
806
|
//#region src/math-name.ts
|
|
807
|
-
var
|
|
807
|
+
var dt = [
|
|
808
808
|
"a[href]",
|
|
809
809
|
"button",
|
|
810
810
|
"label",
|
|
@@ -823,40 +823,68 @@ var ut = [
|
|
|
823
823
|
"tab",
|
|
824
824
|
"treeitem"
|
|
825
825
|
].map((e) => `[role="${e}"]`)
|
|
826
|
-
].join(", ");
|
|
827
|
-
function
|
|
828
|
-
if (e.
|
|
829
|
-
let t = e
|
|
830
|
-
|
|
826
|
+
].join(", "), q = "data-pie-math-name";
|
|
827
|
+
function ft(e) {
|
|
828
|
+
if (e.localName !== "label") return e;
|
|
829
|
+
let t = e;
|
|
830
|
+
if (t.control) return t.control;
|
|
831
|
+
let n = t.getAttribute("for"), r = t.getRootNode();
|
|
832
|
+
return (n ? r.getElementById?.(n) : null) ?? t.querySelector("input, select, textarea, button");
|
|
833
|
+
}
|
|
834
|
+
function pt(e, t) {
|
|
835
|
+
let n = e.getRootNode();
|
|
836
|
+
return "getElementById" in n && typeof n.getElementById == "function" ? n.getElementById(t) : n instanceof Element ? (n.id === t ? n : null) ?? n.querySelector(`[id="${CSS.escape(t)}"]`) : null;
|
|
837
|
+
}
|
|
838
|
+
function mt(e, t) {
|
|
839
|
+
let n = ft(e)?.getAttribute("aria-labelledby")?.split(/\s+/).filter(Boolean);
|
|
840
|
+
if (!n?.length) return !1;
|
|
841
|
+
let r = n.map((e) => pt(t, e)).filter((e) => e !== null);
|
|
842
|
+
return r.length > 0 && !r.some((e) => e.contains(t));
|
|
843
|
+
}
|
|
844
|
+
function ht(e) {
|
|
845
|
+
let t = e.getAttribute(q);
|
|
846
|
+
t !== null && (e.getAttribute("aria-label") === t && e.removeAttribute("aria-label"), e.removeAttribute(q));
|
|
847
|
+
}
|
|
848
|
+
function gt(e) {
|
|
849
|
+
if (e.hasAttribute("aria-label") && !e.hasAttribute(q)) return;
|
|
850
|
+
let t = e.closest(dt);
|
|
851
|
+
if (!t) return;
|
|
852
|
+
if (mt(t, e)) {
|
|
853
|
+
ht(e);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
if (e.hasAttribute("aria-label")) return;
|
|
857
|
+
let n = e.querySelector("math"), r = n ? ut(n) : "";
|
|
858
|
+
r && (e.setAttribute("aria-label", r), e.setAttribute(q, r));
|
|
831
859
|
}
|
|
832
860
|
function J(e) {
|
|
833
|
-
for (let t of e.querySelectorAll("mjx-container"))
|
|
861
|
+
for (let t of e.querySelectorAll("mjx-container")) gt(t);
|
|
834
862
|
}
|
|
835
863
|
//#endregion
|
|
836
864
|
//#region src/speech-worker.ts
|
|
837
|
-
var
|
|
838
|
-
function
|
|
865
|
+
var _t = Symbol.for("@pie-element/shared-math-rendering-mathjax/speech-worker-failed");
|
|
866
|
+
function vt() {
|
|
839
867
|
let e = globalThis;
|
|
840
|
-
e[
|
|
868
|
+
e[_t] || (e[_t] = !0, console.warn(`[math-rendering] MathJax's speech worker did not start, so speech, braille and the explorer are off. A content security policy must allow blob: workers, and scripts and fetches from the asset root. See ${t}`));
|
|
841
869
|
}
|
|
842
|
-
function
|
|
870
|
+
function yt(e) {
|
|
843
871
|
let t = e.webworker;
|
|
844
872
|
if (!t || t.ready) return;
|
|
845
873
|
e.options ??= {};
|
|
846
874
|
let n = e.options;
|
|
847
|
-
n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(),
|
|
875
|
+
n.enableSpeech = !1, n.enableBraille = !1, n.speechError = () => {}, t.Post = () => Promise.reject(/* @__PURE__ */ Error("The speech worker did not start")), t.Terminate(), vt();
|
|
848
876
|
}
|
|
849
|
-
function
|
|
877
|
+
function bt(e) {
|
|
850
878
|
let t = e?.adaptor, n = t?.createWorker;
|
|
851
879
|
!e || !t || !n || (t.createWorker = async (r, i) => {
|
|
852
880
|
let a = await n.call(t, r, i);
|
|
853
|
-
return a.addEventListener("error", () =>
|
|
881
|
+
return a.addEventListener("error", () => yt(e), { once: !0 }), a;
|
|
854
882
|
});
|
|
855
883
|
}
|
|
856
884
|
`${i}`;
|
|
857
885
|
//#endregion
|
|
858
886
|
//#region src/tex-dialect.ts
|
|
859
|
-
var
|
|
887
|
+
var xt = {
|
|
860
888
|
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
861
889
|
overarc: "\\overparen",
|
|
862
890
|
napprox: "\\not\\approx",
|
|
@@ -864,46 +892,46 @@ var gt = {
|
|
|
864
892
|
abs: ["\\left|#1\\right|", 1],
|
|
865
893
|
perpendicular: "\\perp",
|
|
866
894
|
divide: "\\div"
|
|
867
|
-
},
|
|
895
|
+
}, St = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, Ct = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, wt = /\\embed\{newLine\}\[\]/g, Tt = [
|
|
868
896
|
["$$", "$$"],
|
|
869
897
|
["$", "$"],
|
|
870
898
|
["\\[", "\\]"],
|
|
871
899
|
["\\(", "\\)"]
|
|
872
900
|
];
|
|
873
|
-
function
|
|
874
|
-
for (let [t, n] of
|
|
901
|
+
function Et(e) {
|
|
902
|
+
for (let [t, n] of Tt) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
|
|
875
903
|
return e;
|
|
876
904
|
}
|
|
877
|
-
function
|
|
878
|
-
return `\\(${
|
|
905
|
+
function Dt(e) {
|
|
906
|
+
return `\\(${Et(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e)}\\)`.replace(wt, "\\newline ");
|
|
879
907
|
}
|
|
880
|
-
var
|
|
908
|
+
var Ot = "mathjax_ignore", kt = "mathjax_process", At = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", jt = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), Mt = "MJX-CHTML-styles", Nt = "PIE-MJX-SVG-styles", Y = "PIE-MathJax-Menu-Settings", Pt = { "mjx-container[overflow=\"linebreak\"][display]": {
|
|
881
909
|
overflow: "auto clip",
|
|
882
910
|
"min-width": "initial !important"
|
|
883
|
-
} },
|
|
911
|
+
} }, Ft = 200, It = 201, Lt = 202;
|
|
884
912
|
function X(e) {
|
|
885
913
|
let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
|
|
886
914
|
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");
|
|
887
915
|
}
|
|
888
|
-
function
|
|
889
|
-
let n = e.closest(`.${
|
|
916
|
+
function Rt(e, t) {
|
|
917
|
+
let n = e.closest(`.${Ot}, .${kt}`);
|
|
890
918
|
return n !== null && t.contains(n) && !n.classList.contains("mathjax_process");
|
|
891
919
|
}
|
|
892
|
-
function
|
|
920
|
+
function zt(e) {
|
|
893
921
|
for (let t of e.querySelectorAll("[data-latex]")) {
|
|
894
|
-
if (t.dataset.mathHandled || t.closest("mjx-container") ||
|
|
922
|
+
if (t.dataset.mathHandled || t.closest("mjx-container") || Rt(t, e)) continue;
|
|
895
923
|
let n = t.textContent;
|
|
896
|
-
n && (t.textContent =
|
|
924
|
+
n && (t.textContent = Dt(n), t.dataset.mathHandled = "true");
|
|
897
925
|
}
|
|
898
926
|
}
|
|
899
|
-
function
|
|
927
|
+
function Bt(e) {
|
|
900
928
|
for (let t of e.querySelectorAll("math")) t.closest("mjx-container") || t.setAttribute("displaystyle", "true");
|
|
901
929
|
}
|
|
902
|
-
function
|
|
930
|
+
function Vt(e, t) {
|
|
903
931
|
for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
|
|
904
|
-
return (t ?
|
|
932
|
+
return (t ? Ct : St).test(e.textContent ?? "");
|
|
905
933
|
}
|
|
906
|
-
function
|
|
934
|
+
function Ht(e) {
|
|
907
935
|
return new Promise((t, n) => {
|
|
908
936
|
let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = e, s = f(e, import.meta.url), l = c(), u = {
|
|
909
937
|
loader: {
|
|
@@ -911,17 +939,17 @@ function Lt(e) {
|
|
|
911
939
|
failed: (e) => n(e),
|
|
912
940
|
"output/svg": { ready: (e) => {
|
|
913
941
|
let t = b();
|
|
914
|
-
return
|
|
942
|
+
return Ut(t) && Wt(t), e;
|
|
915
943
|
} }
|
|
916
944
|
},
|
|
917
945
|
startup: {
|
|
918
946
|
typeset: !1,
|
|
919
947
|
ready: () => {
|
|
920
|
-
let e = b(), r = e?.startup, i =
|
|
921
|
-
i && (
|
|
948
|
+
let e = b(), r = e?.startup, i = Ut(e);
|
|
949
|
+
i && (Wt(e), Gt(e, s.speechLocales), p(e?._?.a11y?.sre_ts?.locales, s.speechLocales)), r?.defaultReady?.(), i && (Kt(r?.document), qt(r?.document), r?.document?.addStyles?.(Pt), bt(r?.document)), Promise.resolve(r?.promise).then(() => t(), n);
|
|
922
950
|
}
|
|
923
951
|
},
|
|
924
|
-
tex: { macros: { ...
|
|
952
|
+
tex: { macros: { ...xt } },
|
|
925
953
|
output: { displayOverflow: "linebreak" },
|
|
926
954
|
options: {
|
|
927
955
|
enableMenu: i,
|
|
@@ -933,7 +961,7 @@ function Lt(e) {
|
|
|
933
961
|
a11y: { inTabOrder: l }
|
|
934
962
|
}
|
|
935
963
|
};
|
|
936
|
-
r && u.tex && (console.warn(
|
|
964
|
+
r && u.tex && (console.warn(At), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), a || (u.chtml = { fontURL: "" });
|
|
937
965
|
let d = m(s.speechLocales);
|
|
938
966
|
d && u.options && (u.options.sre = { locale: d }), ae(u, {
|
|
939
967
|
...s,
|
|
@@ -943,16 +971,16 @@ function Lt(e) {
|
|
|
943
971
|
}, n);
|
|
944
972
|
});
|
|
945
973
|
}
|
|
946
|
-
function
|
|
974
|
+
function Ut(e) {
|
|
947
975
|
return !!e?.version?.startsWith("4.");
|
|
948
976
|
}
|
|
949
|
-
function
|
|
977
|
+
function Wt(e) {
|
|
950
978
|
let t = e?._?.output, n = t?.chtml_ts?.CHTML;
|
|
951
979
|
n && (n.STYLESHEETID = x);
|
|
952
980
|
let r = t?.svg_ts?.SVG;
|
|
953
|
-
r && (r.STYLESHEETID =
|
|
981
|
+
r && (r.STYLESHEETID = Nt);
|
|
954
982
|
}
|
|
955
|
-
function
|
|
983
|
+
function Gt(e, t) {
|
|
956
984
|
let n = e?._?.ui?.menu?.Menu?.Menu;
|
|
957
985
|
if (n) {
|
|
958
986
|
n.MENU_STORAGE = Y;
|
|
@@ -965,13 +993,13 @@ function Bt(e, t) {
|
|
|
965
993
|
} catch {}
|
|
966
994
|
}
|
|
967
995
|
}
|
|
968
|
-
function
|
|
996
|
+
function Kt(e) {
|
|
969
997
|
if (!e) return;
|
|
970
998
|
let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
|
|
971
999
|
let n = e.typesetRoot;
|
|
972
1000
|
!n || t.has(n) || (X(n), t.add(n));
|
|
973
1001
|
};
|
|
974
|
-
e.addRenderAction?.("pie-strip-latex",
|
|
1002
|
+
e.addRenderAction?.("pie-strip-latex", It, (e) => {
|
|
975
1003
|
for (let t of e.math ?? []) n(t);
|
|
976
1004
|
return !1;
|
|
977
1005
|
}, (e) => {
|
|
@@ -979,50 +1007,50 @@ function Vt(e) {
|
|
|
979
1007
|
return t && X(t), !1;
|
|
980
1008
|
});
|
|
981
1009
|
let r = e.outputJax?.chtmlStyles;
|
|
982
|
-
r?.id ===
|
|
1010
|
+
r?.id === Mt && (r.id = x), Yt();
|
|
983
1011
|
}
|
|
984
|
-
function
|
|
1012
|
+
function qt(e) {
|
|
985
1013
|
let t = (e) => {
|
|
986
|
-
e.typesetRoot &&
|
|
1014
|
+
e.typesetRoot && gt(e.typesetRoot);
|
|
987
1015
|
};
|
|
988
|
-
e?.addRenderAction?.("pie-name-math",
|
|
1016
|
+
e?.addRenderAction?.("pie-name-math", Lt, (e) => {
|
|
989
1017
|
for (let n of e.math ?? []) t(n);
|
|
990
1018
|
return !1;
|
|
991
1019
|
}, (e) => (t(e), !1));
|
|
992
1020
|
}
|
|
993
|
-
function
|
|
1021
|
+
function Jt(e) {
|
|
994
1022
|
return e instanceof HTMLStyleElement && se.includes(e.id);
|
|
995
1023
|
}
|
|
996
|
-
function
|
|
1024
|
+
function Z(e) {
|
|
997
1025
|
ne("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
|
|
998
1026
|
}
|
|
999
|
-
function
|
|
1000
|
-
let e = document.head, t = [...e.children].find(
|
|
1027
|
+
function Yt() {
|
|
1028
|
+
let e = document.head, t = [...e.children].find(Jt);
|
|
1001
1029
|
if (t) {
|
|
1002
|
-
|
|
1030
|
+
Z(t);
|
|
1003
1031
|
return;
|
|
1004
1032
|
}
|
|
1005
1033
|
let n = new MutationObserver((e) => {
|
|
1006
1034
|
for (let t of e) {
|
|
1007
|
-
let e = [...t.addedNodes].find(
|
|
1035
|
+
let e = [...t.addedNodes].find(Jt);
|
|
1008
1036
|
if (e) {
|
|
1009
|
-
|
|
1037
|
+
Z(e), n.disconnect();
|
|
1010
1038
|
return;
|
|
1011
1039
|
}
|
|
1012
1040
|
}
|
|
1013
1041
|
});
|
|
1014
1042
|
n.observe(e, { childList: !0 });
|
|
1015
1043
|
}
|
|
1016
|
-
function
|
|
1044
|
+
function Xt(e) {
|
|
1017
1045
|
let t = e?.math;
|
|
1018
1046
|
if (!t?.remove) return;
|
|
1019
|
-
let n = [...t].filter((e) => (e.state?.() ?? 0) >=
|
|
1047
|
+
let n = [...t].filter((e) => (e.state?.() ?? 0) >= Ft && e.typesetRoot?.isConnected === !1);
|
|
1020
1048
|
if (n.length !== 0) {
|
|
1021
1049
|
for (let e of [...n].reverse()) e.clear?.();
|
|
1022
1050
|
t.remove(...n);
|
|
1023
1051
|
}
|
|
1024
1052
|
}
|
|
1025
|
-
function
|
|
1053
|
+
function Zt(e) {
|
|
1026
1054
|
return new Promise((t, n) => {
|
|
1027
1055
|
let r = e.startup ?? {};
|
|
1028
1056
|
e.startup = r;
|
|
@@ -1033,35 +1061,35 @@ function qt(e) {
|
|
|
1033
1061
|
};
|
|
1034
1062
|
});
|
|
1035
1063
|
}
|
|
1036
|
-
function
|
|
1064
|
+
function Qt(e) {
|
|
1037
1065
|
let t = b();
|
|
1038
|
-
return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() :
|
|
1066
|
+
return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : Zt(t) : Ht(e);
|
|
1039
1067
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return
|
|
1068
|
+
function $t(e) {
|
|
1069
|
+
return Qt(e).then(() => {
|
|
1042
1070
|
let e = b();
|
|
1043
1071
|
e && typeof e.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
|
|
1044
1072
|
});
|
|
1045
1073
|
}
|
|
1046
|
-
function
|
|
1047
|
-
let t = oe, n = t[
|
|
1048
|
-
return n || (n =
|
|
1074
|
+
function en(e) {
|
|
1075
|
+
let t = oe, n = t[jt];
|
|
1076
|
+
return n || (n = $t(e), t[jt] = n), n;
|
|
1049
1077
|
}
|
|
1050
|
-
function
|
|
1078
|
+
function tn(e = {}) {
|
|
1051
1079
|
let t = e.useSingleDollar ?? !1;
|
|
1052
1080
|
return async (n) => {
|
|
1053
1081
|
if (typeof window > "u") return;
|
|
1054
1082
|
let r = ce();
|
|
1055
|
-
r && ne("mathjax-3-global", `window.MathJax is MathJax ${r}`),
|
|
1056
|
-
let i =
|
|
1057
|
-
if (!
|
|
1058
|
-
i.catch(() => {});
|
|
1083
|
+
r && ne("mathjax-3-global", `window.MathJax is MathJax ${r}`), zt(n), fe(n), Bt(n), Re(n);
|
|
1084
|
+
let i = en(e);
|
|
1085
|
+
if (!Vt(n, t)) {
|
|
1086
|
+
i.catch(() => {}), J(n);
|
|
1059
1087
|
return;
|
|
1060
1088
|
}
|
|
1061
1089
|
await i;
|
|
1062
1090
|
let a = b();
|
|
1063
1091
|
if (await a?.startup?.promise, typeof a?.typesetPromise == "function") {
|
|
1064
|
-
|
|
1092
|
+
Ue(), Xt(a.startup?.document);
|
|
1065
1093
|
try {
|
|
1066
1094
|
await a.typesetPromise([n]);
|
|
1067
1095
|
} catch (e) {
|
|
@@ -1071,44 +1099,44 @@ function Z(e = {}) {
|
|
|
1071
1099
|
}
|
|
1072
1100
|
};
|
|
1073
1101
|
}
|
|
1074
|
-
function
|
|
1102
|
+
function nn() {
|
|
1075
1103
|
return [];
|
|
1076
1104
|
}
|
|
1077
1105
|
//#endregion
|
|
1078
1106
|
//#region src/render-math.ts
|
|
1079
|
-
var
|
|
1080
|
-
function
|
|
1081
|
-
return !!window[
|
|
1107
|
+
var rn = "@pie-lib/math-rendering", an = "@pie-lib/math-rendering@2", on = "pie-print", sn = 50, cn = 1e4, ln = null;
|
|
1108
|
+
function un() {
|
|
1109
|
+
return !!window[an]?.opts?.useSingleDollar;
|
|
1082
1110
|
}
|
|
1083
|
-
function
|
|
1084
|
-
return
|
|
1111
|
+
function dn() {
|
|
1112
|
+
return ln ||= tn({ useSingleDollar: un() }), ln;
|
|
1085
1113
|
}
|
|
1086
1114
|
function Q() {
|
|
1087
1115
|
if (typeof window > "u") return null;
|
|
1088
|
-
let e = window[
|
|
1116
|
+
let e = window[rn];
|
|
1089
1117
|
return typeof e?.renderMath == "function" && e.renderMath !== $ ? e : null;
|
|
1090
1118
|
}
|
|
1091
|
-
function
|
|
1119
|
+
function fn(e) {
|
|
1092
1120
|
let t = e;
|
|
1093
1121
|
for (; t;) {
|
|
1094
|
-
if (t instanceof Element && t.localName ===
|
|
1122
|
+
if (t instanceof Element && t.localName === on) return t;
|
|
1095
1123
|
t = t instanceof ShadowRoot ? t.host : t.parentNode;
|
|
1096
1124
|
}
|
|
1097
1125
|
return null;
|
|
1098
1126
|
}
|
|
1099
|
-
function
|
|
1127
|
+
function pn() {
|
|
1100
1128
|
let e = window.renderMath;
|
|
1101
1129
|
return typeof e == "function" ? e : null;
|
|
1102
1130
|
}
|
|
1103
|
-
async function
|
|
1104
|
-
let t =
|
|
1131
|
+
async function mn(e) {
|
|
1132
|
+
let t = fn(e);
|
|
1105
1133
|
if (!t) return null;
|
|
1106
|
-
let n =
|
|
1134
|
+
let n = pn();
|
|
1107
1135
|
if (n || t.mathRenderingModuleUrlImported !== !0) return n;
|
|
1108
|
-
let r = Date.now() +
|
|
1136
|
+
let r = Date.now() + cn;
|
|
1109
1137
|
for (; Date.now() < r;) {
|
|
1110
|
-
await new Promise((e) => setTimeout(e,
|
|
1111
|
-
let e =
|
|
1138
|
+
await new Promise((e) => setTimeout(e, sn));
|
|
1139
|
+
let e = pn();
|
|
1112
1140
|
if (e) return e;
|
|
1113
1141
|
}
|
|
1114
1142
|
return null;
|
|
@@ -1117,14 +1145,14 @@ var $ = async (e) => {
|
|
|
1117
1145
|
if (typeof window > "u") return;
|
|
1118
1146
|
let t = typeof e == "string", n;
|
|
1119
1147
|
t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
|
|
1120
|
-
let r = Q(), i = r || t ? null : await
|
|
1121
|
-
return r ? (await r.renderMath?.(n), J(n)) : i && i !== $ ? (await i(n), J(n)) : await
|
|
1122
|
-
},
|
|
1148
|
+
let r = Q(), i = r || t ? null : await mn(n);
|
|
1149
|
+
return r ? (await r.renderMath?.(n), J(n)) : i && i !== $ ? (await i(n), J(n)) : await dn()(n), t ? n.innerHTML : void 0;
|
|
1150
|
+
}, hn = (e, t) => {
|
|
1123
1151
|
let n = Q()?.wrapMath?.(e, t);
|
|
1124
1152
|
if (n != null) return n;
|
|
1125
1153
|
let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
|
|
1126
|
-
return `${r}${
|
|
1127
|
-
},
|
|
1154
|
+
return `${r}${Et(e)}${i}`;
|
|
1155
|
+
}, gn = (e) => {
|
|
1128
1156
|
let t = e.trim();
|
|
1129
1157
|
return t.startsWith("\\[") && t.endsWith("\\]") ? {
|
|
1130
1158
|
unwrapped: t.slice(2, -2).trim(),
|
|
@@ -1151,6 +1179,6 @@ var $ = async (e) => {
|
|
|
1151
1179
|
close: "$"
|
|
1152
1180
|
}
|
|
1153
1181
|
} : { unwrapped: t };
|
|
1154
|
-
},
|
|
1182
|
+
}, _n = (e) => Q()?.mmlToLatex?.(e) ?? e;
|
|
1155
1183
|
//#endregion
|
|
1156
|
-
export { ee as MATHJAX_CONFLICT_EVENT, h as NO_ASSET_ROOT_EVENT, y as UNSUPPORTED_PAGE_DOCS_URL,
|
|
1184
|
+
export { ee as MATHJAX_CONFLICT_EVENT, h as NO_ASSET_ROOT_EVENT, y as UNSUPPORTED_PAGE_DOCS_URL, tn as createMathjaxRenderer, nn as getMathjaxCssUrls, _n as mmlToLatex, $ as renderMath, ut as speakMathml, gn as unWrapMath, hn as wrapMath };
|