xmmath 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +6 -4
- package/dist/xmmath.es.js +350 -339
- package/dist/xmmath.es.js.map +1 -1
- package/dist/xmmath.umd.js +3 -3
- package/dist/xmmath.umd.js.map +1 -1
- package/package.json +1 -3
- package/readme.md +3 -2
- package/src/main.ts +54 -14
package/dist/xmmath.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var yt = Object.defineProperty;
|
|
2
|
-
var wt = (t, n,
|
|
3
|
-
var S = (t, n,
|
|
2
|
+
var wt = (t, n, o) => n in t ? yt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
|
|
3
|
+
var S = (t, n, o) => (wt(t, typeof n != "symbol" ? n + "" : n, o), o);
|
|
4
4
|
const qt = Intl.Segmenter, xt = new qt("emoji", { granularity: "grapheme" }), R = {
|
|
5
5
|
emoji: null
|
|
6
6
|
};
|
|
7
7
|
function _t(t) {
|
|
8
|
-
const n = /[a-zA-Z]/,
|
|
9
|
-
let
|
|
8
|
+
const n = /[a-zA-Z]/, o = /[(){}[\]]/, e = /[({[]/, r = /[)}\]]/, l = /^[ \t\n\r]+$/;
|
|
9
|
+
let u = "", p = !1;
|
|
10
10
|
const c = [], b = [];
|
|
11
11
|
let v = c, w = "";
|
|
12
12
|
t = t.replace(/(\\u\{[\dA-Fa-f]+\})/g, (a) => {
|
|
@@ -20,37 +20,37 @@ function _t(t) {
|
|
|
20
20
|
k = d;
|
|
21
21
|
for (let a = 0; a < k.length; a++) {
|
|
22
22
|
const s = k[a], i = k[a + 1];
|
|
23
|
-
if (s === "/" && i === "/" && (
|
|
23
|
+
if (s === "/" && i === "/" && (p = "line"), p === "line" && s === `
|
|
24
24
|
`) {
|
|
25
|
-
|
|
25
|
+
p = !1;
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
if (s === "/" && i === "*" && (
|
|
29
|
-
a++,
|
|
28
|
+
if (s === "/" && i === "*" && (p = "block"), p === "block" && s === "*" && i === "/") {
|
|
29
|
+
a++, p = !1;
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
|
-
if (!
|
|
33
|
-
if (
|
|
34
|
-
|
|
32
|
+
if (!p) {
|
|
33
|
+
if (u === "blank" && !s.match(l) && (v.push({ type: u, value: "" }), u = ""), s === '"' && k[a - 1] !== "\\") {
|
|
34
|
+
u !== "str" ? u = "str" : (v.push({ type: u, value: w }), u = "", w = "");
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
37
|
+
if (u === "str") {
|
|
38
38
|
w += s;
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
|
-
if (s.match(l) && (
|
|
41
|
+
if (s.match(l) && (u = "blank"), s === "#") {
|
|
42
42
|
v.push({ type: "sharp", value: "" });
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
45
|
+
if (u === "" && (!k[a - 1] || !k[a - 1].match(n)) && (!k[a + 1] || !k[a + 1].match(n)) && !s.match(o)) {
|
|
46
46
|
v.push({ type: "v", value: s });
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (u === "" && !s.match(n) && !s.match(o)) {
|
|
50
50
|
v.push({ type: "v", value: s });
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
-
if ((k[a - 1] && k[a - 1].match(n) || k[a + 1] && k[a + 1].match(n)) && s.match(n) && (
|
|
53
|
+
if ((k[a - 1] && k[a - 1].match(n) || k[a + 1] && k[a + 1].match(n)) && s.match(n) && (u = "f"), u === "f" && (w += s), u === "f" && (!k[a + 1] || !k[a + 1].match(n)) && (v.push({ type: u, value: w }), u = "", w = ""), s.match(e))
|
|
54
54
|
if (k[a - 1] === "\\")
|
|
55
55
|
v.push({ type: "v", value: s, esc: !0 });
|
|
56
56
|
else {
|
|
@@ -3917,21 +3917,21 @@ const jt = `{
|
|
|
3917
3917
|
`, Nt = JSON.parse(At);
|
|
3918
3918
|
function ct(t) {
|
|
3919
3919
|
const n = {};
|
|
3920
|
-
for (const
|
|
3921
|
-
if (typeof t[
|
|
3922
|
-
n[
|
|
3920
|
+
for (const o in t)
|
|
3921
|
+
if (typeof t[o] == "string")
|
|
3922
|
+
n[o] = t[o];
|
|
3923
3923
|
else
|
|
3924
|
-
for (const
|
|
3925
|
-
if (typeof
|
|
3926
|
-
n[
|
|
3924
|
+
for (const e of t[o])
|
|
3925
|
+
if (typeof e == "string")
|
|
3926
|
+
n[o] = e;
|
|
3927
3927
|
else {
|
|
3928
|
-
n[
|
|
3929
|
-
for (const r in
|
|
3930
|
-
n[`${
|
|
3928
|
+
n[o] || (n[o] = e[Object.keys(e)[0]]);
|
|
3929
|
+
for (const r in e) {
|
|
3930
|
+
n[`${o}.${r}`] = e[r];
|
|
3931
3931
|
const l = r.split(".");
|
|
3932
|
-
for (let
|
|
3933
|
-
const
|
|
3934
|
-
|
|
3932
|
+
for (let u = 1; u < l.length; u++) {
|
|
3933
|
+
const p = l.slice(0, u).join(".");
|
|
3934
|
+
e[p] || (n[`${o}.${p}`] = e[r]);
|
|
3935
3935
|
}
|
|
3936
3936
|
}
|
|
3937
3937
|
}
|
|
@@ -4408,12 +4408,12 @@ const B = /* @__PURE__ */ new Set();
|
|
|
4408
4408
|
{
|
|
4409
4409
|
const t = /* @__PURE__ */ new Set();
|
|
4410
4410
|
for (const n in _) {
|
|
4411
|
-
const
|
|
4411
|
+
const o = _[n];
|
|
4412
4412
|
if (!dt.has(n)) {
|
|
4413
|
-
B.has(
|
|
4413
|
+
B.has(o) && t.add(o);
|
|
4414
4414
|
continue;
|
|
4415
4415
|
}
|
|
4416
|
-
B.add(
|
|
4416
|
+
B.add(o);
|
|
4417
4417
|
}
|
|
4418
4418
|
for (const n of t)
|
|
4419
4419
|
B.delete(n);
|
|
@@ -4425,7 +4425,7 @@ function Ct(t) {
|
|
|
4425
4425
|
function Lt() {
|
|
4426
4426
|
return E;
|
|
4427
4427
|
}
|
|
4428
|
-
function
|
|
4428
|
+
function P(t) {
|
|
4429
4429
|
if (t.length === 1) {
|
|
4430
4430
|
const n = t[0];
|
|
4431
4431
|
if (n.type === "f") {
|
|
@@ -4436,8 +4436,8 @@ function Z(t) {
|
|
|
4436
4436
|
return E;
|
|
4437
4437
|
if (n.value.split(".").at(0) === "arrow")
|
|
4438
4438
|
return !0;
|
|
4439
|
-
for (const
|
|
4440
|
-
if (
|
|
4439
|
+
for (const o of ut)
|
|
4440
|
+
if (o.limits && n.value === o.id)
|
|
4441
4441
|
return E;
|
|
4442
4442
|
}
|
|
4443
4443
|
if (n.value === "scripts")
|
|
@@ -4445,8 +4445,8 @@ function Z(t) {
|
|
|
4445
4445
|
if (n.value === "limits")
|
|
4446
4446
|
return !0;
|
|
4447
4447
|
if (n.value === "op") {
|
|
4448
|
-
const { dic:
|
|
4449
|
-
return K(
|
|
4448
|
+
const { dic: o } = mt(n);
|
|
4449
|
+
return K(o.limits) && E;
|
|
4450
4450
|
}
|
|
4451
4451
|
}
|
|
4452
4452
|
if (n.type === "v") {
|
|
@@ -4480,67 +4480,67 @@ function q(t, n) {
|
|
|
4480
4480
|
function D(t, ...n) {
|
|
4481
4481
|
return n.includes(t == null ? void 0 : t.type);
|
|
4482
4482
|
}
|
|
4483
|
-
function
|
|
4483
|
+
function Z(t) {
|
|
4484
4484
|
if (!(t != null && t[0]))
|
|
4485
4485
|
return [];
|
|
4486
|
-
let n = 0,
|
|
4487
|
-
return t[0].type === "blank" && (n = 1), t.at(-1).type === "blank" &&
|
|
4486
|
+
let n = 0, o = t.length;
|
|
4487
|
+
return t[0].type === "blank" && (n = 1), t.at(-1).type === "blank" && o--, t.slice(n, o);
|
|
4488
4488
|
}
|
|
4489
4489
|
function H(t) {
|
|
4490
4490
|
const n = [];
|
|
4491
|
-
for (const
|
|
4492
|
-
n.push({ type: "f", value:
|
|
4493
|
-
for (const
|
|
4494
|
-
nt(
|
|
4495
|
-
n.push(...t[
|
|
4491
|
+
for (const o in t) {
|
|
4492
|
+
n.push({ type: "f", value: o }), n.push({ type: "v", value: ":" });
|
|
4493
|
+
for (const e of t[o])
|
|
4494
|
+
nt(e, $) && (e.esc = !0);
|
|
4495
|
+
n.push(...t[o]), Number(o) + 1 !== Object.keys(t).length && n.push($);
|
|
4496
4496
|
}
|
|
4497
4497
|
return n;
|
|
4498
4498
|
}
|
|
4499
4499
|
function K(t) {
|
|
4500
4500
|
var n;
|
|
4501
|
-
return q((n =
|
|
4501
|
+
return q((n = Z(t)) == null ? void 0 : n[0], { type: "sharp", value: "true" });
|
|
4502
4502
|
}
|
|
4503
4503
|
function ft(t) {
|
|
4504
|
-
var n,
|
|
4504
|
+
var n, o, e;
|
|
4505
4505
|
{
|
|
4506
4506
|
const r = [], l = /[0-9]/;
|
|
4507
|
-
let
|
|
4508
|
-
for (let
|
|
4509
|
-
const c = t[
|
|
4510
|
-
c.value.match(l) || (n = t[
|
|
4507
|
+
let u = "";
|
|
4508
|
+
for (let p = 0; p < t.length; p++) {
|
|
4509
|
+
const c = t[p];
|
|
4510
|
+
c.value.match(l) || (n = t[p - 1]) != null && n.value.match(l) && J(c) && ((o = t[p + 1]) != null && o.value.match(l)) ? u += c.value : r.push(c), c.value.match(l) && (!t[p + 1] || !t[p + 1].value.match(l)) && !(J(t[p + 1]) && ((e = t[p + 2]) != null && e.value.match(l))) && (r.push({ type: "v", value: u }), u = "");
|
|
4511
4511
|
}
|
|
4512
4512
|
t = r;
|
|
4513
4513
|
}
|
|
4514
4514
|
{
|
|
4515
4515
|
const r = [];
|
|
4516
4516
|
for (let l = 0; l < t.length; l++) {
|
|
4517
|
-
const
|
|
4518
|
-
if (q(
|
|
4517
|
+
const u = t[l];
|
|
4518
|
+
if (q(u, y("\\"))) {
|
|
4519
4519
|
if (t != null && t[l + 1]) {
|
|
4520
|
-
const
|
|
4521
|
-
if (nt(
|
|
4520
|
+
const p = t[l + 1];
|
|
4521
|
+
if (nt(p, y("\\")))
|
|
4522
4522
|
r.push({ type: "v", value: "\\", esc: !0 }), l++;
|
|
4523
|
-
else if (
|
|
4523
|
+
else if (p.type === "blank")
|
|
4524
4524
|
r.push({ type: "v", value: "br", esc: !0 }), l++;
|
|
4525
|
-
else if (
|
|
4526
|
-
const c =
|
|
4525
|
+
else if (p.type === "f") {
|
|
4526
|
+
const c = p.value;
|
|
4527
4527
|
r.push({ type: "v", value: c[0] }), r.push({ type: c.length === 2 ? "v" : "f", value: c.slice(1) }), l++;
|
|
4528
|
-
} else if (
|
|
4528
|
+
} else if (p.type === "sharp")
|
|
4529
4529
|
r.push({ type: "v", value: "#" }), l++;
|
|
4530
4530
|
else {
|
|
4531
|
-
const c =
|
|
4531
|
+
const c = p;
|
|
4532
4532
|
c.esc = !0, r.push(c), l++;
|
|
4533
4533
|
}
|
|
4534
4534
|
}
|
|
4535
4535
|
} else
|
|
4536
|
-
r.push(
|
|
4536
|
+
r.push(u);
|
|
4537
4537
|
}
|
|
4538
4538
|
t = r;
|
|
4539
4539
|
}
|
|
4540
4540
|
return t;
|
|
4541
4541
|
}
|
|
4542
4542
|
function bt(t) {
|
|
4543
|
-
var n,
|
|
4543
|
+
var n, o, e, r, l, u, p, c, b, v, w, k;
|
|
4544
4544
|
{
|
|
4545
4545
|
const d = [];
|
|
4546
4546
|
for (let a = 0; a < t.length; a++) {
|
|
@@ -4570,7 +4570,7 @@ function bt(t) {
|
|
|
4570
4570
|
const d = [];
|
|
4571
4571
|
for (let a = 0; a < t.length; a++) {
|
|
4572
4572
|
const s = t[a];
|
|
4573
|
-
s.type === "v" && ((
|
|
4573
|
+
s.type === "v" && ((o = t == null ? void 0 : t[a + 1]) == null ? void 0 : o.type) === "blank" && ((e = t == null ? void 0 : t[a + 2]) == null ? void 0 : e.type) === "str" ? (d.push(s), d.push({ type: "f", value: "space" })) : s.type === "str" && ((r = t == null ? void 0 : t[a + 1]) == null ? void 0 : r.type) === "blank" && ((l = t == null ? void 0 : t[a + 2]) == null ? void 0 : l.type) === "v" ? (d.push(s), d.push({ type: "f", value: "space" })) : d.push(s);
|
|
4574
4574
|
}
|
|
4575
4575
|
t = d;
|
|
4576
4576
|
}
|
|
@@ -4602,7 +4602,7 @@ function bt(t) {
|
|
|
4602
4602
|
let m = a + 1, A = a + 2;
|
|
4603
4603
|
for (; ; ) {
|
|
4604
4604
|
let M = A;
|
|
4605
|
-
for (; ((
|
|
4605
|
+
for (; ((u = t[M]) == null ? void 0 : u.type) === "blank"; )
|
|
4606
4606
|
M++;
|
|
4607
4607
|
const O = t[M];
|
|
4608
4608
|
if (!O)
|
|
@@ -4687,7 +4687,7 @@ function bt(t) {
|
|
|
4687
4687
|
const i = t[s], f = t[s + 1];
|
|
4688
4688
|
if (D(f, "group") && f.kh !== "()" && D(i, "f", "str", "v") && !i.value.match(/[0-9]/) && !z(i) && !N(i) && // `#box(...)` 的名字归下面的「处理#」(它吃 tree[n+1] 的值),
|
|
4689
4689
|
// 这里抢先粘成 group1 会让 sharp 变成空值、名字连同参数被丢掉
|
|
4690
|
-
((
|
|
4690
|
+
((p = t[s - 1]) == null ? void 0 : p.type) !== "sharp" && (!(D(i, "f") && a.includes(i.src) || D(i, "v") && a.includes(i.value)) || i.esc)) {
|
|
4691
4691
|
d.push({ type: "group1", value: "", children: [i, f] }), s++;
|
|
4692
4692
|
continue;
|
|
4693
4693
|
}
|
|
@@ -4760,7 +4760,7 @@ function bt(t) {
|
|
|
4760
4760
|
let f = t[d[0][1]];
|
|
4761
4761
|
for (let m = d[0][1]; m >= d[0][0]; m--) {
|
|
4762
4762
|
if (N(t[m - 1]) && z(t[m - 3])) {
|
|
4763
|
-
const A =
|
|
4763
|
+
const A = P([t[m - 4]]) ? { t: j(f), b: j(t[m - 2]) } : { tr: j(f), br: j(t[m - 2]) };
|
|
4764
4764
|
f = {
|
|
4765
4765
|
type: "f",
|
|
4766
4766
|
value: "attach",
|
|
@@ -4769,7 +4769,7 @@ function bt(t) {
|
|
|
4769
4769
|
continue;
|
|
4770
4770
|
}
|
|
4771
4771
|
if (z(t[m - 1]) && N(t[m - 3])) {
|
|
4772
|
-
const A =
|
|
4772
|
+
const A = P([t[m - 4]]) ? { t: j(t[m - 2]), b: j(f) } : { tr: j(t[m - 2]), br: j(f) };
|
|
4773
4773
|
f = {
|
|
4774
4774
|
type: "f",
|
|
4775
4775
|
value: "attach",
|
|
@@ -4778,7 +4778,7 @@ function bt(t) {
|
|
|
4778
4778
|
continue;
|
|
4779
4779
|
}
|
|
4780
4780
|
if (N(t[m - 1])) {
|
|
4781
|
-
const A =
|
|
4781
|
+
const A = P([t[m - 2]]) ? { t: j(f) } : { tr: j(f) };
|
|
4782
4782
|
f = {
|
|
4783
4783
|
type: "f",
|
|
4784
4784
|
value: "attach",
|
|
@@ -4787,7 +4787,7 @@ function bt(t) {
|
|
|
4787
4787
|
continue;
|
|
4788
4788
|
}
|
|
4789
4789
|
if (z(t[m - 1])) {
|
|
4790
|
-
const A =
|
|
4790
|
+
const A = P([t[m - 2]]) ? { b: j(f) } : { br: j(f) };
|
|
4791
4791
|
f = {
|
|
4792
4792
|
type: "f",
|
|
4793
4793
|
value: "attach",
|
|
@@ -4837,15 +4837,15 @@ function mt(t) {
|
|
|
4837
4837
|
const n = [[]];
|
|
4838
4838
|
for (const c of t.children)
|
|
4839
4839
|
q(c, { type: "v", value: "," }) || q(c, { type: "v", value: ";" }) ? (n.push(c.value), n.push([])) : n.at(-1).push(c);
|
|
4840
|
-
const
|
|
4840
|
+
const o = [], e = [];
|
|
4841
4841
|
for (const c of n)
|
|
4842
|
-
typeof c == "string" ?
|
|
4842
|
+
typeof c == "string" ? e.push(c) : c.find(
|
|
4843
4843
|
(b, v) => D(c[v - 1], "f", "v") && q(b, { type: "v", value: ":" })
|
|
4844
|
-
) ?
|
|
4844
|
+
) ? o.push(c) : e.push(c);
|
|
4845
4845
|
let r = [];
|
|
4846
|
-
for (let c = 0; c <
|
|
4847
|
-
const b =
|
|
4848
|
-
b === "," && v === ";" || b === ";" && v === "," ? (r.push(";"), c++) : r.push(
|
|
4846
|
+
for (let c = 0; c < e.length; c++) {
|
|
4847
|
+
const b = e[c], v = e[c + 1];
|
|
4848
|
+
b === "," && v === ";" || b === ";" && v === "," ? (r.push(";"), c++) : r.push(e[c]);
|
|
4849
4849
|
}
|
|
4850
4850
|
let l;
|
|
4851
4851
|
if (typeof r.at(-1) == "string" && (r = r.slice(0, -1)), r.includes(";")) {
|
|
@@ -4853,10 +4853,10 @@ function mt(t) {
|
|
|
4853
4853
|
c.at(-1)[0].length === 0 && (c = c.slice(0, -1)), l = c.map((b) => b.filter((v) => typeof v != "string"));
|
|
4854
4854
|
} else
|
|
4855
4855
|
l = r.filter((c) => typeof c != "string").map(
|
|
4856
|
-
(c) =>
|
|
4856
|
+
(c) => Z(c)
|
|
4857
4857
|
);
|
|
4858
|
-
const
|
|
4859
|
-
for (const c of
|
|
4858
|
+
const p = {};
|
|
4859
|
+
for (const c of o) {
|
|
4860
4860
|
let b = !1, v = "";
|
|
4861
4861
|
const w = [];
|
|
4862
4862
|
for (const k of c) {
|
|
@@ -4866,15 +4866,15 @@ function mt(t) {
|
|
|
4866
4866
|
}
|
|
4867
4867
|
b ? w.push(k) : v += k.value;
|
|
4868
4868
|
}
|
|
4869
|
-
|
|
4869
|
+
p[v] = bt(ft(w));
|
|
4870
4870
|
}
|
|
4871
|
-
return { attr: l, dic:
|
|
4871
|
+
return { attr: l, dic: p };
|
|
4872
4872
|
}
|
|
4873
4873
|
function Ot(t, n) {
|
|
4874
|
-
const
|
|
4875
|
-
for (const
|
|
4876
|
-
n(
|
|
4877
|
-
return
|
|
4874
|
+
const o = [[]];
|
|
4875
|
+
for (const e of t)
|
|
4876
|
+
n(e) ? o.push([]) : o.at(-1).push(e);
|
|
4877
|
+
return o;
|
|
4878
4878
|
}
|
|
4879
4879
|
class G {
|
|
4880
4880
|
constructor(n) {
|
|
@@ -4892,20 +4892,20 @@ class Dt {
|
|
|
4892
4892
|
}
|
|
4893
4893
|
}
|
|
4894
4894
|
class Et {
|
|
4895
|
-
constructor(n,
|
|
4895
|
+
constructor(n, o, e) {
|
|
4896
4896
|
S(this, "type", "el");
|
|
4897
4897
|
S(this, "attrs", {});
|
|
4898
4898
|
S(this, "style", {});
|
|
4899
4899
|
S(this, "childNodes", []);
|
|
4900
|
-
if (this.tag = n,
|
|
4901
|
-
for (const r in
|
|
4902
|
-
this.attrs[r] =
|
|
4900
|
+
if (this.tag = n, o && this.childNodes.push(new G(o)), e)
|
|
4901
|
+
for (const r in e)
|
|
4902
|
+
this.attrs[r] = e[r];
|
|
4903
4903
|
}
|
|
4904
4904
|
append(...n) {
|
|
4905
4905
|
et(this.childNodes, n);
|
|
4906
4906
|
}
|
|
4907
|
-
setAttribute(n,
|
|
4908
|
-
this.attrs[n] =
|
|
4907
|
+
setAttribute(n, o) {
|
|
4908
|
+
this.attrs[n] = o;
|
|
4909
4909
|
}
|
|
4910
4910
|
getAttribute(n) {
|
|
4911
4911
|
return this.attrs[n] ?? null;
|
|
@@ -4926,26 +4926,26 @@ class Et {
|
|
|
4926
4926
|
this.childNodes.length = 0, this.childNodes.push(new G(n));
|
|
4927
4927
|
}
|
|
4928
4928
|
querySelectorAll(n) {
|
|
4929
|
-
const
|
|
4930
|
-
return Q(this, n,
|
|
4929
|
+
const o = [];
|
|
4930
|
+
return Q(this, n, o), o;
|
|
4931
4931
|
}
|
|
4932
4932
|
}
|
|
4933
4933
|
function et(t, n) {
|
|
4934
|
-
for (const
|
|
4935
|
-
if (
|
|
4936
|
-
if (Array.isArray(
|
|
4937
|
-
et(t,
|
|
4934
|
+
for (const o of n)
|
|
4935
|
+
if (o) {
|
|
4936
|
+
if (Array.isArray(o)) {
|
|
4937
|
+
et(t, o);
|
|
4938
4938
|
continue;
|
|
4939
4939
|
}
|
|
4940
|
-
|
|
4940
|
+
o.type === "frag" ? t.push(...o.childNodes) : t.push(o);
|
|
4941
4941
|
}
|
|
4942
4942
|
}
|
|
4943
|
-
function Q(t, n,
|
|
4944
|
-
for (const
|
|
4945
|
-
|
|
4943
|
+
function Q(t, n, o) {
|
|
4944
|
+
for (const e of t.childNodes)
|
|
4945
|
+
e.type === "el" ? (e.tag === n && o.push(e), Q(e, n, o)) : e.type === "frag" && Q(e, n, o);
|
|
4946
4946
|
}
|
|
4947
|
-
function h(t, n,
|
|
4948
|
-
return new Et(t, n,
|
|
4947
|
+
function h(t, n, o) {
|
|
4948
|
+
return new Et(t, n, o);
|
|
4949
4949
|
}
|
|
4950
4950
|
function gt() {
|
|
4951
4951
|
return new Dt();
|
|
@@ -4965,12 +4965,12 @@ function W(t) {
|
|
|
4965
4965
|
if (t.type === "frag")
|
|
4966
4966
|
return t.childNodes.map(W).join("");
|
|
4967
4967
|
let n = `<${t.tag}`;
|
|
4968
|
-
for (const
|
|
4969
|
-
n += ` ${
|
|
4970
|
-
const
|
|
4971
|
-
if (
|
|
4972
|
-
const
|
|
4973
|
-
n += ` style="${lt(
|
|
4968
|
+
for (const e in t.attrs)
|
|
4969
|
+
n += ` ${e}="${lt(t.attrs[e])}"`;
|
|
4970
|
+
const o = Object.keys(t.style);
|
|
4971
|
+
if (o.length) {
|
|
4972
|
+
const e = o.map((r) => `${Ht(r)}: ${t.style[r]}`).join("; ");
|
|
4973
|
+
n += ` style="${lt(e)}"`;
|
|
4974
4974
|
}
|
|
4975
4975
|
return n += ">", n += t.childNodes.map(W).join(""), n += `</${t.tag}>`, n;
|
|
4976
4976
|
}
|
|
@@ -4982,19 +4982,19 @@ function Y(t, n = globalThis.document) {
|
|
|
4982
4982
|
if (t.type === "text")
|
|
4983
4983
|
return n.createTextNode(t.text);
|
|
4984
4984
|
if (t.type === "frag") {
|
|
4985
|
-
const
|
|
4985
|
+
const e = n.createDocumentFragment();
|
|
4986
4986
|
for (const r of t.childNodes)
|
|
4987
|
-
|
|
4988
|
-
return
|
|
4987
|
+
e.append(Y(r, n));
|
|
4988
|
+
return e;
|
|
4989
4989
|
}
|
|
4990
|
-
const
|
|
4991
|
-
for (const
|
|
4992
|
-
|
|
4993
|
-
for (const
|
|
4994
|
-
|
|
4995
|
-
for (const
|
|
4996
|
-
|
|
4997
|
-
return
|
|
4990
|
+
const o = n.createElementNS(It, t.tag);
|
|
4991
|
+
for (const e in t.attrs)
|
|
4992
|
+
o.setAttribute(e, t.attrs[e]);
|
|
4993
|
+
for (const e in t.style)
|
|
4994
|
+
o.style[e] = t.style[e];
|
|
4995
|
+
for (const e of t.childNodes)
|
|
4996
|
+
o.append(Y(e, n));
|
|
4997
|
+
return o;
|
|
4998
4998
|
}
|
|
4999
4999
|
const C = "mathvariant", Ft = {
|
|
5000
5000
|
"(": ["(", ")"],
|
|
@@ -5004,94 +5004,100 @@ const C = "mathvariant", Ft = {
|
|
|
5004
5004
|
"||": ["‖", "‖"],
|
|
5005
5005
|
"": ["", ""]
|
|
5006
5006
|
};
|
|
5007
|
+
function Vt(t) {
|
|
5008
|
+
const n = t.length === 2 && t[0].type === "f" && t[0].value !== "prime" && t[1].type === "group" && t[1].kh === "()" ? [{ ...t[0], children: t[1].children }] : t;
|
|
5009
|
+
return !!P(n);
|
|
5010
|
+
}
|
|
5007
5011
|
function U(t, n) {
|
|
5008
|
-
const
|
|
5009
|
-
let
|
|
5010
|
-
return
|
|
5012
|
+
const o = L(t, "delim");
|
|
5013
|
+
let e = "";
|
|
5014
|
+
return o !== null && (o === void 0 ? e = n : e = o), Ft[e];
|
|
5011
5015
|
}
|
|
5012
5016
|
const x = {
|
|
5013
|
-
accent: (t, n,
|
|
5014
|
-
const
|
|
5015
|
-
|
|
5017
|
+
accent: (t, n, o) => {
|
|
5018
|
+
const e = h("mrow");
|
|
5019
|
+
e.append(g(t[0], o));
|
|
5016
5020
|
const r = h("mrow");
|
|
5017
|
-
r.append(g(t[1],
|
|
5021
|
+
r.append(g(t[1], o)), r.children[0].innerHTML = Rt(r.children[0].innerHTML);
|
|
5018
5022
|
const l = h("mover");
|
|
5019
|
-
return l.setAttribute("accent", "true"), l.append(
|
|
5023
|
+
return l.setAttribute("accent", "true"), l.append(e, r), l;
|
|
5020
5024
|
},
|
|
5021
|
-
attach: (t, n,
|
|
5022
|
-
const
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
const p = h("mrow");
|
|
5028
|
-
n.bl && p.append(g(n.bl, e));
|
|
5025
|
+
attach: (t, n, o) => {
|
|
5026
|
+
const e = { ...n };
|
|
5027
|
+
Vt(t[0]) || (e.t && !e.tr && (e.tr = e.t, delete e.t), e.b && !e.br && (e.br = e.b, delete e.b));
|
|
5028
|
+
const r = h("mrow");
|
|
5029
|
+
r.append(g(t[0]));
|
|
5030
|
+
let l;
|
|
5029
5031
|
const u = h("mrow");
|
|
5030
|
-
|
|
5032
|
+
e.tl && u.append(g(e.tl, o));
|
|
5033
|
+
const p = h("mrow");
|
|
5034
|
+
e.bl && p.append(g(e.bl, o));
|
|
5031
5035
|
const c = h("mrow");
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
const v = h("
|
|
5036
|
-
|
|
5036
|
+
e.tr && c.append(g(e.tr, o));
|
|
5037
|
+
const b = h("mrow");
|
|
5038
|
+
if (e.br && b.append(g(e.br, o)), (e.tl || e.bl || e.tr || e.br) && (e.tl || e.bl ? (l = h("mmultiscripts"), l.append(r, b, c, h("mprescripts"), p, u)) : e.tr && e.br ? (l = h("msubsup"), l.append(r, b, c)) : e.tr ? (l = h("msup"), l.append(r, c)) : (l = h("msub"), l.append(r, b))), e.t || e.b) {
|
|
5039
|
+
const v = h("munderover");
|
|
5040
|
+
l ? v.append(l) : v.append(r);
|
|
5037
5041
|
const w = h("mrow");
|
|
5038
|
-
|
|
5042
|
+
e.t && w.append(g(e.t, o));
|
|
5043
|
+
const k = h("mrow");
|
|
5044
|
+
e.b && k.append(g(e.b, o)), v.append(k, w), l = v;
|
|
5039
5045
|
}
|
|
5040
|
-
return
|
|
5046
|
+
return l;
|
|
5041
5047
|
},
|
|
5042
|
-
scripts: (t, n,
|
|
5043
|
-
limits: (t, n,
|
|
5044
|
-
binom: (t, n,
|
|
5045
|
-
const
|
|
5046
|
-
r.append(g(t[0],
|
|
5047
|
-
const l = h("mrow"),
|
|
5048
|
+
scripts: (t, n, o) => g(t[0], o),
|
|
5049
|
+
limits: (t, n, o) => g(t[0], o),
|
|
5050
|
+
binom: (t, n, o) => {
|
|
5051
|
+
const e = h("mrow"), r = h("mrow");
|
|
5052
|
+
r.append(g(t[0], o));
|
|
5053
|
+
const l = h("mrow"), u = [];
|
|
5048
5054
|
for (const v of t.slice(1))
|
|
5049
|
-
|
|
5050
|
-
l.append(g(
|
|
5051
|
-
const
|
|
5052
|
-
|
|
5055
|
+
u.push(...v, $);
|
|
5056
|
+
l.append(g(u.slice(0, -1), o));
|
|
5057
|
+
const p = h("mfrac", null, { linethickness: "0" });
|
|
5058
|
+
p.append(r, l);
|
|
5053
5059
|
const c = h("mo", "("), b = h("mo", ")");
|
|
5054
|
-
return
|
|
5060
|
+
return e.append(c, p, b), e;
|
|
5055
5061
|
},
|
|
5056
|
-
cancel: (t, n,
|
|
5057
|
-
const
|
|
5062
|
+
cancel: (t, n, o) => {
|
|
5063
|
+
const e = h("mrow"), r = (u) => `linear-gradient(to ${u ? "left" : "right"} top, transparent 47.75%, currentColor 49.5%, currentColor 50.5%, transparent 52.25%)`;
|
|
5058
5064
|
let l = "";
|
|
5059
|
-
return K(n.cross) ? l = `${r(!0)},${r(!1)}` : K(n.inverted) ? l = r(!1) : l = r(!0),
|
|
5065
|
+
return K(n.cross) ? l = `${r(!0)},${r(!1)}` : K(n.inverted) ? l = r(!1) : l = r(!0), e.style.backgroundImage = l, e.append(g(t[0], o)), e;
|
|
5060
5066
|
},
|
|
5061
|
-
cases: (t, n,
|
|
5062
|
-
const
|
|
5063
|
-
if (l.setAttribute("rowspacing",
|
|
5064
|
-
const
|
|
5065
|
-
|
|
5067
|
+
cases: (t, n, o) => {
|
|
5068
|
+
const e = h("mrow"), r = U(n, "{"), l = x.x_table(t, { cases: [] }, o), u = L(n, "gap") || "0.5em";
|
|
5069
|
+
if (l.setAttribute("rowspacing", u), K(n == null ? void 0 : n.reverse)) {
|
|
5070
|
+
const p = h("mo", r[1]);
|
|
5071
|
+
e.append(l, p);
|
|
5066
5072
|
} else {
|
|
5067
|
-
const
|
|
5068
|
-
|
|
5073
|
+
const p = h("mo", r[0]);
|
|
5074
|
+
e.append(p, l);
|
|
5069
5075
|
}
|
|
5070
|
-
return
|
|
5076
|
+
return e;
|
|
5071
5077
|
},
|
|
5072
|
-
frac: (t, n,
|
|
5073
|
-
const
|
|
5074
|
-
|
|
5078
|
+
frac: (t, n, o) => {
|
|
5079
|
+
const e = h("mrow");
|
|
5080
|
+
e.append(g(t[0], o));
|
|
5075
5081
|
const r = h("mrow");
|
|
5076
|
-
r.append(g(t[1],
|
|
5082
|
+
r.append(g(t[1], o));
|
|
5077
5083
|
const l = h("mfrac");
|
|
5078
|
-
return l.append(
|
|
5084
|
+
return l.append(e, r), l;
|
|
5079
5085
|
},
|
|
5080
|
-
lr: (t, n,
|
|
5081
|
-
const
|
|
5082
|
-
if (
|
|
5083
|
-
const c =
|
|
5086
|
+
lr: (t, n, o) => {
|
|
5087
|
+
const e = vt(t.map((c) => Mt(c))), r = Z(e), l = L(n, "size"), u = g(r, o), p = h("mrow");
|
|
5088
|
+
if (p.append(u), l && l !== "auto") {
|
|
5089
|
+
const c = p.children[0], b = p.children[p.children.length - 1];
|
|
5084
5090
|
c == null || c.setAttribute("maxsize", l), c == null || c.setAttribute("minsize", l), b == null || b.setAttribute("maxsize", l), b == null || b.setAttribute("minsize", l);
|
|
5085
5091
|
}
|
|
5086
|
-
return
|
|
5092
|
+
return p;
|
|
5087
5093
|
},
|
|
5088
5094
|
mid: (t, n) => {
|
|
5089
|
-
var
|
|
5090
|
-
return h("mo", (r = (
|
|
5095
|
+
var e, r;
|
|
5096
|
+
return h("mo", (r = (e = t == null ? void 0 : t[0]) == null ? void 0 : e[0]) == null ? void 0 : r.value, { stretchy: "true" });
|
|
5091
5097
|
},
|
|
5092
|
-
mat: (t, n,
|
|
5098
|
+
mat: (t, n, o) => {
|
|
5093
5099
|
var d;
|
|
5094
|
-
const
|
|
5100
|
+
const e = U(n, "("), r = h("mrow"), l = h("mo", e[0]), u = h("mo", e[1]), p = h("mtable");
|
|
5095
5101
|
let c;
|
|
5096
5102
|
(d = t[0][0]) != null && d.type ? c = [t] : c = t;
|
|
5097
5103
|
const b = L(n, "augment");
|
|
@@ -5101,7 +5107,7 @@ const x = {
|
|
|
5101
5107
|
const i = [];
|
|
5102
5108
|
for (let f = 1; f < c.length; f++)
|
|
5103
5109
|
i.push(f === s);
|
|
5104
|
-
|
|
5110
|
+
p.setAttribute(
|
|
5105
5111
|
"rowlines",
|
|
5106
5112
|
i.map((f) => f ? "solid" : "none").join(" ")
|
|
5107
5113
|
);
|
|
@@ -5110,129 +5116,134 @@ const x = {
|
|
|
5110
5116
|
const i = [];
|
|
5111
5117
|
for (let f = 1; f < c[0].length; f++)
|
|
5112
5118
|
i.push(f === a);
|
|
5113
|
-
|
|
5119
|
+
p.setAttribute(
|
|
5114
5120
|
"columnlines",
|
|
5115
5121
|
i.map((f) => f ? "solid" : "none").join(" ")
|
|
5116
5122
|
);
|
|
5117
5123
|
}
|
|
5118
5124
|
}
|
|
5119
5125
|
const v = L(n, "gap"), w = L(n, "row-gap"), k = L(n, "column-gap");
|
|
5120
|
-
|
|
5126
|
+
p.setAttribute("columnspacing", k || v || "0.5em"), p.setAttribute("rowspacing", w || v || "0.5em");
|
|
5121
5127
|
for (const a of c) {
|
|
5122
5128
|
const s = h("mtr");
|
|
5123
5129
|
for (const i of a) {
|
|
5124
5130
|
const f = h("mtd");
|
|
5125
|
-
f.append(g(i,
|
|
5131
|
+
f.append(g(i, o)), s.append(f);
|
|
5126
5132
|
}
|
|
5127
|
-
|
|
5133
|
+
p.append(s);
|
|
5128
5134
|
}
|
|
5129
|
-
return r.append(l,
|
|
5135
|
+
return r.append(l, p, u), r;
|
|
5130
5136
|
},
|
|
5131
|
-
root: (t, n,
|
|
5132
|
-
const
|
|
5133
|
-
|
|
5137
|
+
root: (t, n, o) => {
|
|
5138
|
+
const e = h("mrow");
|
|
5139
|
+
e.append(g(t[0], o));
|
|
5134
5140
|
const r = h("mrow");
|
|
5135
|
-
r.append(g(t[1],
|
|
5141
|
+
r.append(g(t[1], o));
|
|
5136
5142
|
const l = h("mroot");
|
|
5137
|
-
return l.append(r,
|
|
5143
|
+
return l.append(r, e), l;
|
|
5138
5144
|
},
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5145
|
+
// msqrt(与 typst html 导出一致:<msqrt>…</msqrt>),被开方数直接作为子元素,
|
|
5146
|
+
// 不包 mrow、不走 mroot——空指数的 mroot 会被 MathML 校验/渲染当成错误结构。
|
|
5147
|
+
sqrt: (t, n, o) => {
|
|
5148
|
+
const e = h("msqrt");
|
|
5149
|
+
return e.append(g(t[0], o)), e;
|
|
5143
5150
|
},
|
|
5144
|
-
|
|
5145
|
-
const
|
|
5151
|
+
display: (t, n, o) => {
|
|
5152
|
+
const e = h("mrow", null, { displaystyle: "true" });
|
|
5153
|
+
return e.append(g(t[0], o)), e;
|
|
5154
|
+
},
|
|
5155
|
+
inline: (t, n, o) => {
|
|
5156
|
+
const e = h("mrow", null, {
|
|
5146
5157
|
displaystyle: "false",
|
|
5147
5158
|
scriptlevel: "0"
|
|
5148
5159
|
});
|
|
5149
|
-
return
|
|
5160
|
+
return e.append(g(t[0], o)), e;
|
|
5150
5161
|
},
|
|
5151
|
-
script: (t, n,
|
|
5152
|
-
const
|
|
5162
|
+
script: (t, n, o) => {
|
|
5163
|
+
const e = h("mrow", null, {
|
|
5153
5164
|
displaystyle: "false",
|
|
5154
5165
|
scriptlevel: "1"
|
|
5155
5166
|
});
|
|
5156
|
-
return
|
|
5167
|
+
return e.append(g(t[0], o)), e;
|
|
5157
5168
|
},
|
|
5158
|
-
sscript: (t, n,
|
|
5159
|
-
const
|
|
5169
|
+
sscript: (t, n, o) => {
|
|
5170
|
+
const e = h("mrow", null, {
|
|
5160
5171
|
displaystyle: "false",
|
|
5161
5172
|
scriptlevel: "2"
|
|
5162
5173
|
});
|
|
5163
|
-
return
|
|
5174
|
+
return e.append(g(t[0], o)), e;
|
|
5164
5175
|
},
|
|
5165
|
-
upright: (t, n,
|
|
5166
|
-
const
|
|
5167
|
-
return
|
|
5176
|
+
upright: (t, n, o) => {
|
|
5177
|
+
const e = h("mrow");
|
|
5178
|
+
return e.append(g(t[0], o)), e.querySelectorAll("mi").forEach((r) => {
|
|
5168
5179
|
r.getAttribute(C) || r.setAttribute(C, "normal");
|
|
5169
|
-
}),
|
|
5180
|
+
}), e.querySelectorAll("ms").forEach((r) => {
|
|
5170
5181
|
r.getAttribute(C) || r.setAttribute(C, "normal");
|
|
5171
|
-
}),
|
|
5182
|
+
}), e;
|
|
5172
5183
|
},
|
|
5173
|
-
italic: (t, n,
|
|
5174
|
-
const
|
|
5175
|
-
return
|
|
5184
|
+
italic: (t, n, o) => {
|
|
5185
|
+
const e = h("mrow");
|
|
5186
|
+
return e.append(g(t[0], o)), e.querySelectorAll("mi").forEach((r) => {
|
|
5176
5187
|
r.getAttribute(C) || r.setAttribute(C, "italic");
|
|
5177
|
-
}),
|
|
5188
|
+
}), e.querySelectorAll("ms").forEach((r) => {
|
|
5178
5189
|
r.getAttribute(C) || r.setAttribute(C, "italic");
|
|
5179
|
-
}),
|
|
5190
|
+
}), e;
|
|
5180
5191
|
},
|
|
5181
|
-
bold: (t, n,
|
|
5182
|
-
const
|
|
5183
|
-
return
|
|
5192
|
+
bold: (t, n, o) => {
|
|
5193
|
+
const e = h("mrow");
|
|
5194
|
+
return e.style.fontWeight = "bold", e.append(g(t[0], o)), e;
|
|
5184
5195
|
},
|
|
5185
|
-
op: (t, n,
|
|
5186
|
-
const
|
|
5187
|
-
return r.append(g(t[0],
|
|
5196
|
+
op: (t, n, o) => {
|
|
5197
|
+
const e = h("mrow"), r = h("ms");
|
|
5198
|
+
return r.append(g(t[0], o)), e.append(r), e;
|
|
5188
5199
|
},
|
|
5189
|
-
underline: (t, n,
|
|
5190
|
-
overline: (t, n,
|
|
5191
|
-
underbrace: (t, n,
|
|
5192
|
-
overbrace: (t, n,
|
|
5193
|
-
underbracket: (t, n,
|
|
5194
|
-
overbracket: (t, n,
|
|
5200
|
+
underline: (t, n, o) => at("under", t[0], o),
|
|
5201
|
+
overline: (t, n, o) => at("over", t[0], o),
|
|
5202
|
+
underbrace: (t, n, o) => I("under", t[0], "⏟", t == null ? void 0 : t[1], o),
|
|
5203
|
+
overbrace: (t, n, o) => I("over", t[0], "⏞", t == null ? void 0 : t[1], o),
|
|
5204
|
+
underbracket: (t, n, o) => I("under", t[0], "⎵", t == null ? void 0 : t[1], o),
|
|
5205
|
+
overbracket: (t, n, o) => I("over", t[0], "⎴", t == null ? void 0 : t[1], o),
|
|
5195
5206
|
serif: (t) => g(t[0], "serif"),
|
|
5196
5207
|
sans: (t) => g(t[0], "sans"),
|
|
5197
5208
|
frak: (t) => g(t[0], "frak"),
|
|
5198
5209
|
mono: (t) => g(t[0], "mono"),
|
|
5199
5210
|
bb: (t) => g(t[0], "bb"),
|
|
5200
5211
|
cal: (t) => g(t[0], "cal"),
|
|
5201
|
-
vec: (t, n,
|
|
5202
|
-
const
|
|
5203
|
-
return
|
|
5212
|
+
vec: (t, n, o) => {
|
|
5213
|
+
const e = U(n, "("), r = h("mrow"), l = h("mo", e[0]), u = h("mo", e[1]), p = tt(t, o), c = L(n, "gap") || "0.5em";
|
|
5214
|
+
return p.setAttribute("rowspacing", c), p.setAttribute("columnspacing", "0.5em"), r.append(l, p, u), r;
|
|
5204
5215
|
},
|
|
5205
5216
|
h: (t, n) => h("mspace", "", { width: t[0][0].value }),
|
|
5206
5217
|
// 额外
|
|
5207
5218
|
//
|
|
5208
5219
|
x_table: (t, n) => {
|
|
5209
|
-
const
|
|
5210
|
-
return n.cases &&
|
|
5220
|
+
const o = tt(t);
|
|
5221
|
+
return n.cases && o.setAttribute("columnalign", "left"), o;
|
|
5211
5222
|
}
|
|
5212
5223
|
};
|
|
5213
|
-
function tt(t, n,
|
|
5214
|
-
let
|
|
5224
|
+
function tt(t, n, o) {
|
|
5225
|
+
let e = 0;
|
|
5215
5226
|
const r = h("mtable");
|
|
5216
5227
|
for (const l of t) {
|
|
5217
|
-
const
|
|
5218
|
-
|
|
5228
|
+
const u = l.filter((p) => q(p, y("&"))).length;
|
|
5229
|
+
u > e && (e = u);
|
|
5219
5230
|
}
|
|
5220
5231
|
for (const l of t) {
|
|
5221
|
-
const
|
|
5232
|
+
const u = h("mtr"), p = [[]];
|
|
5222
5233
|
for (let b = 0; b < l.length; b++)
|
|
5223
|
-
q(l[b], y("&")) ?
|
|
5224
|
-
for (const b of
|
|
5234
|
+
q(l[b], y("&")) ? p.push([]) : p.at(-1).push(l[b]);
|
|
5235
|
+
for (const b of p) {
|
|
5225
5236
|
const v = h("mtd");
|
|
5226
|
-
|
|
5237
|
+
u.append(v), v.append(g(b, n));
|
|
5227
5238
|
}
|
|
5228
5239
|
const c = [];
|
|
5229
|
-
for (let b = 0; b <=
|
|
5230
|
-
|
|
5231
|
-
r.setAttribute("columnalign", c.join(" ")), r.setAttribute("columnspacing", "0"), r.append(
|
|
5240
|
+
for (let b = 0; b <= e; b++)
|
|
5241
|
+
e > 0 ? c.push(b % 2 === 0 ? "right" : "left") : c.push(o ? "left" : "center");
|
|
5242
|
+
r.setAttribute("columnalign", c.join(" ")), r.setAttribute("columnspacing", "0"), r.append(u);
|
|
5232
5243
|
}
|
|
5233
5244
|
return r;
|
|
5234
5245
|
}
|
|
5235
|
-
function
|
|
5246
|
+
function Bt(t) {
|
|
5236
5247
|
const n = [
|
|
5237
5248
|
_.prime,
|
|
5238
5249
|
_["prime.double"],
|
|
@@ -5241,18 +5252,18 @@ function Vt(t) {
|
|
|
5241
5252
|
];
|
|
5242
5253
|
return t <= 4 ? n[t - 1] : _.prime.repeat(t);
|
|
5243
5254
|
}
|
|
5244
|
-
function
|
|
5255
|
+
function Kt() {
|
|
5245
5256
|
for (const t of ut)
|
|
5246
|
-
x[t.id] = (n,
|
|
5247
|
-
const r = x.op([[{ type: "str", value: t.str || t.id }]], {},
|
|
5257
|
+
x[t.id] = (n, o, e) => {
|
|
5258
|
+
const r = x.op([[{ type: "str", value: t.str || t.id }]], {}, e);
|
|
5248
5259
|
if (n) {
|
|
5249
5260
|
const l = gt();
|
|
5250
|
-
return l.append(r,
|
|
5261
|
+
return l.append(r, Gt(vt(n))), l;
|
|
5251
5262
|
} else
|
|
5252
5263
|
return r;
|
|
5253
5264
|
};
|
|
5254
5265
|
}
|
|
5255
|
-
|
|
5266
|
+
Kt();
|
|
5256
5267
|
const st = {
|
|
5257
5268
|
quad: "1em",
|
|
5258
5269
|
med: "0.222em",
|
|
@@ -5262,7 +5273,7 @@ const st = {
|
|
|
5262
5273
|
};
|
|
5263
5274
|
for (const t in st)
|
|
5264
5275
|
x[t] = () => x.h([[{ type: "str", value: st[t] }]]);
|
|
5265
|
-
function
|
|
5276
|
+
function Rt(t) {
|
|
5266
5277
|
switch (t) {
|
|
5267
5278
|
case "̀":
|
|
5268
5279
|
case "`":
|
|
@@ -5333,7 +5344,7 @@ function Kt(t) {
|
|
|
5333
5344
|
return t;
|
|
5334
5345
|
}
|
|
5335
5346
|
}
|
|
5336
|
-
function
|
|
5347
|
+
function Jt() {
|
|
5337
5348
|
const t = [
|
|
5338
5349
|
"grave",
|
|
5339
5350
|
"acute",
|
|
@@ -5358,10 +5369,10 @@ function Rt() {
|
|
|
5358
5369
|
"harpoon.lt"
|
|
5359
5370
|
];
|
|
5360
5371
|
for (const n of t)
|
|
5361
|
-
x[n] = (
|
|
5372
|
+
x[n] = (o, e, r) => x.accent([o[0], [{ type: "f", value: n }]], {}, r);
|
|
5362
5373
|
}
|
|
5363
|
-
|
|
5364
|
-
function
|
|
5374
|
+
Jt();
|
|
5375
|
+
function Wt() {
|
|
5365
5376
|
const t = [
|
|
5366
5377
|
{ name: "abs", l: y("|"), r: y("|") },
|
|
5367
5378
|
{ name: "norm", l: y("‖"), r: y("‖") },
|
|
@@ -5370,74 +5381,74 @@ function Jt() {
|
|
|
5370
5381
|
{ name: "round", l: y("⌊"), r: y("⌉") }
|
|
5371
5382
|
];
|
|
5372
5383
|
for (const n of t)
|
|
5373
|
-
x[n.name] = (
|
|
5384
|
+
x[n.name] = (o, e, r) => x.lr([[n.l, ...o[0], n.r]], e, r);
|
|
5374
5385
|
}
|
|
5375
|
-
|
|
5376
|
-
function I(t, n,
|
|
5377
|
-
const l = t === "under" ? h("munder", null, { accentunder: "true" }) : h("mover", null, { accent: "true" }),
|
|
5378
|
-
if (
|
|
5379
|
-
const
|
|
5380
|
-
|
|
5381
|
-
const c = h(t === "under" ? "munder" : "mover"), b = h("mo",
|
|
5382
|
-
c.append(b,
|
|
5386
|
+
Wt();
|
|
5387
|
+
function I(t, n, o, e, r) {
|
|
5388
|
+
const l = t === "under" ? h("munder", null, { accentunder: "true" }) : h("mover", null, { accent: "true" }), u = h("mrow");
|
|
5389
|
+
if (u.append(g(n, r)), e) {
|
|
5390
|
+
const p = h("mrow");
|
|
5391
|
+
p.append(g(e, r));
|
|
5392
|
+
const c = h(t === "under" ? "munder" : "mover"), b = h("mo", o);
|
|
5393
|
+
c.append(b, p), l.append(u, c);
|
|
5383
5394
|
} else {
|
|
5384
|
-
const
|
|
5385
|
-
l.append(
|
|
5395
|
+
const p = h("mo", o);
|
|
5396
|
+
l.append(u, p);
|
|
5386
5397
|
}
|
|
5387
5398
|
return l;
|
|
5388
5399
|
}
|
|
5389
|
-
function at(t, n,
|
|
5390
|
-
const
|
|
5391
|
-
return r.append(g(n,
|
|
5400
|
+
function at(t, n, o) {
|
|
5401
|
+
const e = t === "under" ? h("munder", null, { accentunder: "true" }) : h("mover", null, { accent: "true" }), r = h("mrow");
|
|
5402
|
+
return r.append(g(n, o)), t === "under" && (r.style.borderBottom = "1px solid black"), t === "over" && (r.style.borderTop = "1px solid black"), e.append(r), e;
|
|
5392
5403
|
}
|
|
5393
5404
|
const F = {
|
|
5394
5405
|
"√": x.sqrt,
|
|
5395
|
-
"∛": (t, n,
|
|
5396
|
-
"∜": (t, n,
|
|
5406
|
+
"∛": (t, n, o) => x.root([[y("3")], t[0]], null, o),
|
|
5407
|
+
"∜": (t, n, o) => x.root([[y("4")], t[0]], null, o)
|
|
5397
5408
|
};
|
|
5398
|
-
function Wt(t) {
|
|
5399
|
-
const n = h("mrow"), e = h("mo");
|
|
5400
|
-
e.textContent = "(";
|
|
5401
|
-
const o = g(t), r = h("mo");
|
|
5402
|
-
return r.textContent = ")", n.append(e, o, r), n;
|
|
5403
|
-
}
|
|
5404
5409
|
function Gt(t) {
|
|
5405
|
-
|
|
5410
|
+
const n = h("mrow"), o = h("mo");
|
|
5411
|
+
o.textContent = "(";
|
|
5412
|
+
const e = g(t), r = h("mo");
|
|
5413
|
+
return r.textContent = ")", n.append(o, e, r), n;
|
|
5414
|
+
}
|
|
5415
|
+
function Ut(t) {
|
|
5416
|
+
t = Z(t);
|
|
5406
5417
|
const n = new Object();
|
|
5407
|
-
let
|
|
5418
|
+
let o = "", e = [];
|
|
5408
5419
|
t.push($);
|
|
5409
5420
|
for (let r = 0; r < t.length; r++)
|
|
5410
|
-
!
|
|
5421
|
+
!o && t[r].type !== "blank" ? o = t[r].value : e.length ? q(t[r], $) ? (n[o] = Z(e), o = "", e = []) : e.push(t[r]) : q(t[r], y(":")) && e.push(t[r + 1]);
|
|
5411
5422
|
return n;
|
|
5412
5423
|
}
|
|
5413
5424
|
function L(t, n) {
|
|
5414
|
-
var
|
|
5415
|
-
if (!((
|
|
5425
|
+
var e;
|
|
5426
|
+
if (!((e = t == null ? void 0 : t[n]) != null && e[0]))
|
|
5416
5427
|
return;
|
|
5417
|
-
const
|
|
5418
|
-
if (
|
|
5419
|
-
if (
|
|
5428
|
+
const o = t[n][0];
|
|
5429
|
+
if (o.type === "sharp") {
|
|
5430
|
+
if (o.value === "true")
|
|
5420
5431
|
return !0;
|
|
5421
|
-
if (
|
|
5432
|
+
if (o.value === "false")
|
|
5422
5433
|
return !1;
|
|
5423
|
-
if (
|
|
5434
|
+
if (o.value === "none")
|
|
5424
5435
|
return null;
|
|
5425
|
-
if (
|
|
5426
|
-
return
|
|
5436
|
+
if (o.children)
|
|
5437
|
+
return o.children.find((r) => q(r, y(":"))) ? Ut(o.children) : o.children.map((r) => r.value).join("");
|
|
5427
5438
|
}
|
|
5428
5439
|
return t[n].map((r) => r.value).join("");
|
|
5429
5440
|
}
|
|
5430
5441
|
function vt(t) {
|
|
5431
5442
|
const n = [];
|
|
5432
|
-
for (const
|
|
5433
|
-
n.push(...
|
|
5443
|
+
for (const o of t)
|
|
5444
|
+
n.push(...o, y(","));
|
|
5434
5445
|
return n.slice(0, -1);
|
|
5435
5446
|
}
|
|
5436
5447
|
function it(t, n = "serif") {
|
|
5437
|
-
function
|
|
5448
|
+
function o(r) {
|
|
5438
5449
|
return "abcdefghijklmnopqrstuvwxyz".indexOf(r.toLowerCase());
|
|
5439
5450
|
}
|
|
5440
|
-
const
|
|
5451
|
+
const e = {
|
|
5441
5452
|
sans: {
|
|
5442
5453
|
num: "𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫",
|
|
5443
5454
|
low: "𝖺𝖻𝖼𝖽𝖾𝖿𝗀𝗁𝗂𝗃𝗄𝗅𝗆𝗇𝗈𝗉𝗊𝗋𝗌𝗍𝗎𝗏𝗐𝗑𝗒𝗓",
|
|
@@ -5462,59 +5473,59 @@ function it(t, n = "serif") {
|
|
|
5462
5473
|
up: "𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵"
|
|
5463
5474
|
}
|
|
5464
5475
|
};
|
|
5465
|
-
return n === "serif" || (t = t.replace(/[0-9]/g, (r) => [...
|
|
5476
|
+
return n === "serif" || (t = t.replace(/[0-9]/g, (r) => [...e[n].num][r]), t = t.replace(/[a-z]/g, (r) => [...e[n].low][o(r)]), t = t.replace(/[A-Z]/g, (r) => [...e[n].up][o(r)])), t;
|
|
5466
5477
|
}
|
|
5467
5478
|
function g(t, n) {
|
|
5468
|
-
const
|
|
5479
|
+
const o = gt();
|
|
5469
5480
|
t = ft(t);
|
|
5470
5481
|
{
|
|
5471
|
-
let
|
|
5482
|
+
let e = !1;
|
|
5472
5483
|
for (const r in t) {
|
|
5473
5484
|
const l = t[r];
|
|
5474
5485
|
if (ot(l)) {
|
|
5475
|
-
|
|
5486
|
+
e = !0;
|
|
5476
5487
|
break;
|
|
5477
5488
|
}
|
|
5478
5489
|
}
|
|
5479
|
-
if (
|
|
5490
|
+
if (e) {
|
|
5480
5491
|
const r = [[]];
|
|
5481
5492
|
for (let l = 0; l < t.length; l++) {
|
|
5482
|
-
const
|
|
5483
|
-
ot(
|
|
5493
|
+
const u = t[l];
|
|
5494
|
+
ot(u) ? r.push([]) : r.at(-1).push(u);
|
|
5484
5495
|
}
|
|
5485
5496
|
return tt(r, void 0, !Lt());
|
|
5486
5497
|
}
|
|
5487
5498
|
}
|
|
5488
5499
|
t = bt(t);
|
|
5489
5500
|
{
|
|
5490
|
-
const
|
|
5501
|
+
const e = [];
|
|
5491
5502
|
for (const r of t)
|
|
5492
|
-
r.type === "v" && r.value === "&" && !r.esc ||
|
|
5493
|
-
t =
|
|
5503
|
+
r.type === "v" && r.value === "&" && !r.esc || e.push(r);
|
|
5504
|
+
t = e;
|
|
5494
5505
|
}
|
|
5495
5506
|
{
|
|
5496
|
-
const
|
|
5507
|
+
const e = [];
|
|
5497
5508
|
for (const r of t)
|
|
5498
|
-
r.type === "group1" ?
|
|
5499
|
-
t =
|
|
5509
|
+
r.type === "group1" ? e.push(...r.children) : e.push(r);
|
|
5510
|
+
t = e;
|
|
5500
5511
|
}
|
|
5501
|
-
for (const
|
|
5502
|
-
const r = Number(
|
|
5512
|
+
for (const e in t) {
|
|
5513
|
+
const r = Number(e), l = t[r];
|
|
5503
5514
|
if (l.type === "f") {
|
|
5504
5515
|
if (l.children && (l.kh === "()" || !l.kh)) {
|
|
5505
|
-
const { attr:
|
|
5516
|
+
const { attr: u, dic: p } = mt(l);
|
|
5506
5517
|
if (x[l.value]) {
|
|
5507
|
-
const c = x[l.value](
|
|
5508
|
-
|
|
5518
|
+
const c = x[l.value](u, p, n);
|
|
5519
|
+
o.append(c);
|
|
5509
5520
|
} else if (_[l.value]) {
|
|
5510
5521
|
const c = h("mi", _[l.value]);
|
|
5511
|
-
|
|
5522
|
+
o.append(c, g(St(l.children), n));
|
|
5512
5523
|
} else if (F[l.value]) {
|
|
5513
|
-
const c = F[l.value](
|
|
5514
|
-
|
|
5524
|
+
const c = F[l.value](u, p, n);
|
|
5525
|
+
o.append(c);
|
|
5515
5526
|
}
|
|
5516
5527
|
} else if (_[l.value]) {
|
|
5517
|
-
let
|
|
5528
|
+
let u, p = null;
|
|
5518
5529
|
const c = {
|
|
5519
5530
|
" ": "0.36em",
|
|
5520
5531
|
" ": "0.5em",
|
|
@@ -5528,49 +5539,49 @@ function g(t, n) {
|
|
|
5528
5539
|
" ": "0.17em",
|
|
5529
5540
|
" ": "0.09em"
|
|
5530
5541
|
};
|
|
5531
|
-
_[l.value].match(/[a-zA-Z\u0391-\u03C9]/) ?
|
|
5532
|
-
const b = h(
|
|
5533
|
-
|
|
5542
|
+
_[l.value].match(/[a-zA-Z\u0391-\u03C9]/) ? u = "mi" : c[_[l.value]] ? (u = "mspace", p = { width: c[_[l.value]] }) : u = "mo";
|
|
5543
|
+
const b = h(u, _[l.value], p);
|
|
5544
|
+
o.append(b);
|
|
5534
5545
|
} else if (x[l.value]) {
|
|
5535
|
-
const
|
|
5536
|
-
|
|
5546
|
+
const u = x[l.value](null, null, n);
|
|
5547
|
+
o.append(u);
|
|
5537
5548
|
} else if (F[l.value]) {
|
|
5538
|
-
const
|
|
5539
|
-
|
|
5549
|
+
const u = F[l.value]([l.children], null, n);
|
|
5550
|
+
o.append(u);
|
|
5540
5551
|
}
|
|
5541
5552
|
}
|
|
5542
5553
|
if (l.type === "str") {
|
|
5543
|
-
const
|
|
5544
|
-
|
|
5554
|
+
const u = h("ms", it(l.value, n));
|
|
5555
|
+
o.append(u);
|
|
5545
5556
|
}
|
|
5546
5557
|
if (l.type === "v" || l.type === "sharp") {
|
|
5547
|
-
let
|
|
5548
|
-
l.value.match(/[0-9.]+/) ?
|
|
5549
|
-
const c = h(
|
|
5550
|
-
|
|
5558
|
+
let u, p = l.value;
|
|
5559
|
+
l.value.match(/[0-9.]+/) ? u = "mn" : l.value.match(/[a-zA-Z\u0391-\u03C9]/) ? u = "mi" : (l.value.match(/^'+$/) && (l.esc || (p = Bt(l.value.length))), u = "mo"), l.type === "sharp" && l.value.startsWith("emoji.") && (u = "mi", p = zt[l.value.replace("emoji.", "")]);
|
|
5560
|
+
const c = h(u, it(p, n));
|
|
5561
|
+
o.append(c);
|
|
5551
5562
|
}
|
|
5552
|
-
l.type === "group" && (l.kh && l.kh.length === 1 ? (
|
|
5563
|
+
l.type === "group" && (l.kh && l.kh.length === 1 ? (o.append(h("mo", l.kh, { stretchy: "false" })), o.append(g(l.children, n))) : o.append(x.lr([[l]], null, n)));
|
|
5553
5564
|
}
|
|
5554
|
-
return
|
|
5565
|
+
return o;
|
|
5555
5566
|
}
|
|
5556
|
-
function
|
|
5567
|
+
function Yt(t) {
|
|
5557
5568
|
for (const n in t)
|
|
5558
5569
|
R[n] && (R[n] = t[n]);
|
|
5559
5570
|
}
|
|
5560
5571
|
function kt(t, n) {
|
|
5561
5572
|
Ct(!n);
|
|
5562
|
-
const
|
|
5563
|
-
n ||
|
|
5564
|
-
const r = g(
|
|
5565
|
-
return
|
|
5573
|
+
const o = _t(t), e = h("math");
|
|
5574
|
+
n || e.setAttribute("display", "block");
|
|
5575
|
+
const r = g(o);
|
|
5576
|
+
return e.append(r), e;
|
|
5566
5577
|
}
|
|
5567
|
-
function
|
|
5578
|
+
function tn(t, n) {
|
|
5568
5579
|
return Y(kt(t, n));
|
|
5569
5580
|
}
|
|
5570
|
-
function
|
|
5571
|
-
return Zt(kt(t));
|
|
5581
|
+
function nn(t, n) {
|
|
5582
|
+
return Zt(kt(t, n));
|
|
5572
5583
|
}
|
|
5573
|
-
const
|
|
5584
|
+
const en = {
|
|
5574
5585
|
lan: "0.11.1",
|
|
5575
5586
|
symbol: "0.15.1",
|
|
5576
5587
|
emoji: "0.15.1"
|
|
@@ -5578,10 +5589,10 @@ const nn = {
|
|
|
5578
5589
|
export {
|
|
5579
5590
|
ft as ast2,
|
|
5580
5591
|
bt as ast3,
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5592
|
+
Yt as init,
|
|
5593
|
+
tn as toMML,
|
|
5594
|
+
nn as toMMLHTML,
|
|
5584
5595
|
kt as toMMLV,
|
|
5585
|
-
|
|
5596
|
+
en as version
|
|
5586
5597
|
};
|
|
5587
5598
|
//# sourceMappingURL=xmmath.es.js.map
|