xmmath 1.1.1 → 1.1.3
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 +458 -433
- package/dist/xmmath.es.js.map +1 -1
- package/dist/xmmath.umd.js +4 -4
- package/dist/xmmath.umd.js.map +1 -1
- package/package.json +1 -3
- package/readme.md +3 -2
- package/src/main.ts +108 -44
package/dist/xmmath.es.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var S = (t, n,
|
|
4
|
-
const
|
|
1
|
+
var xt = Object.defineProperty;
|
|
2
|
+
var _t = (t, n, o) => n in t ? xt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
|
|
3
|
+
var S = (t, n, o) => (_t(t, typeof n != "symbol" ? n + "" : n, o), o);
|
|
4
|
+
const jt = Intl.Segmenter, At = new jt("emoji", { granularity: "grapheme" }), J = {
|
|
5
5
|
emoji: null
|
|
6
6
|
};
|
|
7
|
-
function
|
|
8
|
-
const n = /[a-zA-Z]/,
|
|
9
|
-
let
|
|
7
|
+
function Nt(t) {
|
|
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) => {
|
|
13
13
|
const s = parseInt(a.slice(3, -1), 16);
|
|
14
14
|
return String.fromCodePoint(s);
|
|
15
15
|
});
|
|
16
|
-
let k =
|
|
16
|
+
let k = J.emoji ? J.emoji(t) : Array.from(At.segment(t)).map((a) => a.segment);
|
|
17
17
|
const d = [];
|
|
18
18
|
for (const a of k)
|
|
19
19
|
a.length > 1 && a.includes(",") ? d.push(...a) : d.push(a);
|
|
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 {
|
|
@@ -62,7 +62,7 @@ function _t(t) {
|
|
|
62
62
|
}
|
|
63
63
|
return c;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
65
|
+
const zt = `{
|
|
66
66
|
"abacus": "🧮",
|
|
67
67
|
"abc": "🔤",
|
|
68
68
|
"abcd": "🔡",
|
|
@@ -2186,7 +2186,7 @@ const jt = `{
|
|
|
2186
2186
|
"zombie": "🧟",
|
|
2187
2187
|
"zzz": "💤"
|
|
2188
2188
|
}
|
|
2189
|
-
`,
|
|
2189
|
+
`, $t = `{
|
|
2190
2190
|
"wj": "",
|
|
2191
2191
|
"zwj": "",
|
|
2192
2192
|
"zwnj": "",
|
|
@@ -3914,30 +3914,30 @@ const jt = `{
|
|
|
3914
3914
|
}
|
|
3915
3915
|
]
|
|
3916
3916
|
}
|
|
3917
|
-
`,
|
|
3918
|
-
function
|
|
3917
|
+
`, Mt = JSON.parse($t);
|
|
3918
|
+
function pt(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
|
}
|
|
3938
3938
|
return n;
|
|
3939
3939
|
}
|
|
3940
|
-
const _ =
|
|
3940
|
+
const _ = pt(Mt), St = pt(JSON.parse(zt)), B = {
|
|
3941
3941
|
"->": "arrow.r",
|
|
3942
3942
|
"|->": "arrow.r.bar",
|
|
3943
3943
|
"=>": "arrow.r.double",
|
|
@@ -3981,10 +3981,10 @@ const _ = ct(Nt), zt = ct(JSON.parse(jt)), V = {
|
|
|
3981
3981
|
"'": "prime",
|
|
3982
3982
|
"~": "space.nobreak"
|
|
3983
3983
|
};
|
|
3984
|
-
let
|
|
3985
|
-
for (const t in
|
|
3986
|
-
t.length >
|
|
3987
|
-
const
|
|
3984
|
+
let Q = 0;
|
|
3985
|
+
for (const t in B)
|
|
3986
|
+
t.length > Q && (Q = t.length);
|
|
3987
|
+
const Ct = ["√", "∛", "∜"], dt = [
|
|
3988
3988
|
{ id: "arccos" },
|
|
3989
3989
|
{ id: "arcsin" },
|
|
3990
3990
|
{ id: "arctan" },
|
|
@@ -4028,7 +4028,7 @@ const $t = ["√", "∛", "∜"], ut = [
|
|
|
4028
4028
|
{ id: "limsup", str: "lim sup", limits: !0 },
|
|
4029
4029
|
{ id: "dif", str: "d" },
|
|
4030
4030
|
{ id: "Dif", str: "D" }
|
|
4031
|
-
],
|
|
4031
|
+
], ht = [], ft = /* @__PURE__ */ new Set([
|
|
4032
4032
|
"angle.azimuth",
|
|
4033
4033
|
"angzarr",
|
|
4034
4034
|
"approx",
|
|
@@ -4354,7 +4354,7 @@ const $t = ["√", "∛", "∜"], ut = [
|
|
|
4354
4354
|
"tilde.rev",
|
|
4355
4355
|
"tilde.rev.equiv",
|
|
4356
4356
|
"tilde.triple"
|
|
4357
|
-
]),
|
|
4357
|
+
]), bt = [
|
|
4358
4358
|
// 大算符:0.11.1 实测 inline 走角标、block(display) 才走上下
|
|
4359
4359
|
"∏",
|
|
4360
4360
|
"∐",
|
|
@@ -4381,15 +4381,15 @@ const $t = ["√", "∛", "∜"], ut = [
|
|
|
4381
4381
|
"⨊"
|
|
4382
4382
|
];
|
|
4383
4383
|
for (const t in _)
|
|
4384
|
-
for (const n of
|
|
4385
|
-
_[t] === n &&
|
|
4384
|
+
for (const n of bt)
|
|
4385
|
+
_[t] === n && ht.push(t);
|
|
4386
4386
|
function j(t) {
|
|
4387
4387
|
return t.type === "group" ? t.kh === "()" ? t.children : [t] : [t];
|
|
4388
4388
|
}
|
|
4389
|
-
function
|
|
4389
|
+
function Lt(t) {
|
|
4390
4390
|
return t.length === 1 && t[0].type === "group" && t[0].kh.length > 1 && (t = [y(t[0].kh[0]), ...t[0].children, y(t[0].kh[1])]), t;
|
|
4391
4391
|
}
|
|
4392
|
-
function
|
|
4392
|
+
function Tt(t) {
|
|
4393
4393
|
return [{ type: "group", value: "", children: t, kh: "()" }];
|
|
4394
4394
|
}
|
|
4395
4395
|
function N(t) {
|
|
@@ -4401,43 +4401,43 @@ function z(t) {
|
|
|
4401
4401
|
function T(t) {
|
|
4402
4402
|
return q(t, { type: "v", value: "/" });
|
|
4403
4403
|
}
|
|
4404
|
-
function
|
|
4404
|
+
function lt(t) {
|
|
4405
4405
|
return t && t.value === "br" && t.esc;
|
|
4406
4406
|
}
|
|
4407
|
-
const
|
|
4407
|
+
const K = /* @__PURE__ */ new Set();
|
|
4408
4408
|
{
|
|
4409
4409
|
const t = /* @__PURE__ */ new Set();
|
|
4410
4410
|
for (const n in _) {
|
|
4411
|
-
const
|
|
4412
|
-
if (!
|
|
4413
|
-
|
|
4411
|
+
const o = _[n];
|
|
4412
|
+
if (!ft.has(n)) {
|
|
4413
|
+
K.has(o) && t.add(o);
|
|
4414
4414
|
continue;
|
|
4415
4415
|
}
|
|
4416
|
-
|
|
4416
|
+
K.add(o);
|
|
4417
4417
|
}
|
|
4418
4418
|
for (const n of t)
|
|
4419
|
-
|
|
4419
|
+
K.delete(n);
|
|
4420
4420
|
}
|
|
4421
4421
|
let E = !0;
|
|
4422
|
-
function
|
|
4422
|
+
function Y(t) {
|
|
4423
4423
|
E = t;
|
|
4424
4424
|
}
|
|
4425
|
-
function
|
|
4425
|
+
function mt() {
|
|
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") {
|
|
4432
4432
|
if (!n.children || n.children.length === 0) {
|
|
4433
|
-
if (
|
|
4433
|
+
if (ft.has(n.value))
|
|
4434
4434
|
return !0;
|
|
4435
|
-
if (
|
|
4435
|
+
if (ht.includes(n.value))
|
|
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 dt)
|
|
4440
|
+
if (o.limits && n.value === o.id)
|
|
4441
4441
|
return E;
|
|
4442
4442
|
}
|
|
4443
4443
|
if (n.value === "scripts")
|
|
@@ -4445,33 +4445,33 @@ function Z(t) {
|
|
|
4445
4445
|
if (n.value === "limits")
|
|
4446
4446
|
return !0;
|
|
4447
4447
|
if (n.value === "op") {
|
|
4448
|
-
const { dic:
|
|
4449
|
-
return
|
|
4448
|
+
const { dic: o } = kt(n);
|
|
4449
|
+
return R(o.limits) && E;
|
|
4450
4450
|
}
|
|
4451
4451
|
}
|
|
4452
4452
|
if (n.type === "v") {
|
|
4453
|
-
if (
|
|
4453
|
+
if (K.has(n.value))
|
|
4454
4454
|
return !0;
|
|
4455
|
-
if (
|
|
4455
|
+
if (bt.includes(n.value))
|
|
4456
4456
|
return E;
|
|
4457
4457
|
}
|
|
4458
4458
|
} else
|
|
4459
4459
|
return !1;
|
|
4460
4460
|
}
|
|
4461
|
-
function
|
|
4462
|
-
return
|
|
4461
|
+
function W(t) {
|
|
4462
|
+
return ot(t, { type: "v", value: "." });
|
|
4463
4463
|
}
|
|
4464
|
-
function
|
|
4464
|
+
function st(t) {
|
|
4465
4465
|
return t && (t.type === "f" || t.type === "v" && t.value.match(/[a-z]/));
|
|
4466
4466
|
}
|
|
4467
|
-
function
|
|
4467
|
+
function Ot(t) {
|
|
4468
4468
|
return t && t.type === "v" && t.value === "!" && !t.esc;
|
|
4469
4469
|
}
|
|
4470
4470
|
const $ = { type: "v", value: "," };
|
|
4471
4471
|
function y(t) {
|
|
4472
4472
|
return { type: "v", value: t };
|
|
4473
4473
|
}
|
|
4474
|
-
function
|
|
4474
|
+
function ot(t, n) {
|
|
4475
4475
|
return !t || !n ? !1 : t.type === n.type && t.value === n.value;
|
|
4476
4476
|
}
|
|
4477
4477
|
function q(t, n) {
|
|
@@ -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
|
-
|
|
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
|
+
ot(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
|
-
function
|
|
4499
|
+
function R(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
|
-
function
|
|
4504
|
-
var n,
|
|
4503
|
+
function gt(t) {
|
|
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) && W(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)) && !(W(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 (
|
|
4520
|
+
const p = t[l + 1];
|
|
4521
|
+
if (ot(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
|
-
function
|
|
4543
|
-
var n,
|
|
4542
|
+
function vt(t) {
|
|
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++) {
|
|
@@ -4550,12 +4550,12 @@ function bt(t) {
|
|
|
4550
4550
|
else if (s.type === "v") {
|
|
4551
4551
|
let i = a, f = s.value;
|
|
4552
4552
|
const m = [];
|
|
4553
|
-
for (
|
|
4554
|
-
f += t[i + 1].value,
|
|
4553
|
+
for (B[f] && m.push(f); ((n = t == null ? void 0 : t[i + 1]) == null ? void 0 : n.type) === "v" && f.length <= Q; )
|
|
4554
|
+
f += t[i + 1].value, B[f] && m.push(f), i++;
|
|
4555
4555
|
if (m.length) {
|
|
4556
4556
|
const A = {
|
|
4557
4557
|
type: "f",
|
|
4558
|
-
value:
|
|
4558
|
+
value: B[m.at(-1)],
|
|
4559
4559
|
src: m.at(-1)
|
|
4560
4560
|
};
|
|
4561
4561
|
d.push(A), a += m.at(-1).length - 1;
|
|
@@ -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
|
}
|
|
@@ -4579,7 +4579,7 @@ function bt(t) {
|
|
|
4579
4579
|
let a = [];
|
|
4580
4580
|
for (let s = 0; s < t.length; s++) {
|
|
4581
4581
|
const i = t[s];
|
|
4582
|
-
|
|
4582
|
+
Ot(t == null ? void 0 : t[s + 1]) && !N(i) && !z(i) && !T(i) ? a.push(i) : a.length ? (a.push(i), d.push({ type: "group1", value: "", children: a }), a = []) : d.push(i);
|
|
4583
4583
|
}
|
|
4584
4584
|
t = d;
|
|
4585
4585
|
}
|
|
@@ -4588,7 +4588,7 @@ function bt(t) {
|
|
|
4588
4588
|
let a = "";
|
|
4589
4589
|
for (let s = 0; s < t.length; s++) {
|
|
4590
4590
|
const i = t[s];
|
|
4591
|
-
|
|
4591
|
+
st(i) && W(t[s + 1]) ? a || !a && i.type === "f" ? (a += `${i.value}.`, s++) : d.push(i) : a && st(i) ? (a += i.value, W(t[s + 1]) || (d.push({ type: "f", value: a }), a = "")) : d.push(i);
|
|
4592
4592
|
}
|
|
4593
4593
|
t = d;
|
|
4594
4594
|
}
|
|
@@ -4596,13 +4596,13 @@ function bt(t) {
|
|
|
4596
4596
|
const d = [];
|
|
4597
4597
|
for (let a = 0; a < t.length; a++) {
|
|
4598
4598
|
const s = t[a];
|
|
4599
|
-
if (s.type === "v" &&
|
|
4599
|
+
if (s.type === "v" && Ct.includes(s.value) && t[a + 1]) {
|
|
4600
4600
|
s.type = "f";
|
|
4601
4601
|
const i = t[a + 1], f = [];
|
|
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",
|
|
@@ -4833,30 +4833,30 @@ function bt(t) {
|
|
|
4833
4833
|
}
|
|
4834
4834
|
return t;
|
|
4835
4835
|
}
|
|
4836
|
-
function
|
|
4836
|
+
function kt(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(";")) {
|
|
4852
|
-
let c =
|
|
4852
|
+
let c = Dt(r, (b) => b === ";");
|
|
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,46 +4866,46 @@ function mt(t) {
|
|
|
4866
4866
|
}
|
|
4867
4867
|
b ? w.push(k) : v += k.value;
|
|
4868
4868
|
}
|
|
4869
|
-
|
|
4869
|
+
p[v] = vt(gt(w));
|
|
4870
4870
|
}
|
|
4871
|
-
return { attr: l, dic:
|
|
4871
|
+
return { attr: l, dic: p };
|
|
4872
4872
|
}
|
|
4873
|
-
function
|
|
4874
|
-
const
|
|
4875
|
-
for (const
|
|
4876
|
-
n(
|
|
4877
|
-
return
|
|
4873
|
+
function Dt(t, n) {
|
|
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
|
-
class
|
|
4879
|
+
class U {
|
|
4880
4880
|
constructor(n) {
|
|
4881
4881
|
S(this, "type", "text");
|
|
4882
4882
|
this.text = n;
|
|
4883
4883
|
}
|
|
4884
4884
|
}
|
|
4885
|
-
class
|
|
4885
|
+
class Et {
|
|
4886
4886
|
constructor() {
|
|
4887
4887
|
S(this, "type", "frag");
|
|
4888
4888
|
S(this, "childNodes", []);
|
|
4889
4889
|
}
|
|
4890
4890
|
append(...n) {
|
|
4891
|
-
|
|
4891
|
+
rt(this.childNodes, n);
|
|
4892
4892
|
}
|
|
4893
4893
|
}
|
|
4894
|
-
class
|
|
4895
|
-
constructor(n,
|
|
4894
|
+
class Ht {
|
|
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 U(o)), e)
|
|
4901
|
+
for (const r in e)
|
|
4902
|
+
this.attrs[r] = e[r];
|
|
4903
4903
|
}
|
|
4904
4904
|
append(...n) {
|
|
4905
|
-
|
|
4905
|
+
rt(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;
|
|
@@ -4917,86 +4917,86 @@ class Et {
|
|
|
4917
4917
|
return this.childNodes.filter((n) => n.type === "text").map((n) => n.text).join("");
|
|
4918
4918
|
}
|
|
4919
4919
|
set textContent(n) {
|
|
4920
|
-
this.childNodes.length = 0, n && this.childNodes.push(new
|
|
4920
|
+
this.childNodes.length = 0, n && this.childNodes.push(new U(n));
|
|
4921
4921
|
}
|
|
4922
4922
|
get innerHTML() {
|
|
4923
|
-
return this.childNodes.map(
|
|
4923
|
+
return this.childNodes.map(G).join("");
|
|
4924
4924
|
}
|
|
4925
4925
|
set innerHTML(n) {
|
|
4926
|
-
this.childNodes.length = 0, this.childNodes.push(new
|
|
4926
|
+
this.childNodes.length = 0, this.childNodes.push(new U(n));
|
|
4927
4927
|
}
|
|
4928
4928
|
querySelectorAll(n) {
|
|
4929
|
-
const
|
|
4930
|
-
return
|
|
4929
|
+
const o = [];
|
|
4930
|
+
return tt(this, n, o), o;
|
|
4931
4931
|
}
|
|
4932
4932
|
}
|
|
4933
|
-
function
|
|
4934
|
-
for (const
|
|
4935
|
-
if (
|
|
4936
|
-
if (Array.isArray(
|
|
4937
|
-
|
|
4933
|
+
function rt(t, n) {
|
|
4934
|
+
for (const o of n)
|
|
4935
|
+
if (o) {
|
|
4936
|
+
if (Array.isArray(o)) {
|
|
4937
|
+
rt(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
|
|
4944
|
-
for (const
|
|
4945
|
-
|
|
4943
|
+
function tt(t, n, o) {
|
|
4944
|
+
for (const e of t.childNodes)
|
|
4945
|
+
e.type === "el" ? (e.tag === n && o.push(e), tt(e, n, o)) : e.type === "frag" && tt(e, n, o);
|
|
4946
4946
|
}
|
|
4947
|
-
function h(t, n,
|
|
4948
|
-
return new
|
|
4947
|
+
function h(t, n, o) {
|
|
4948
|
+
return new Ht(t, n, o);
|
|
4949
4949
|
}
|
|
4950
|
-
function
|
|
4951
|
-
return new
|
|
4950
|
+
function yt() {
|
|
4951
|
+
return new Et();
|
|
4952
4952
|
}
|
|
4953
|
-
function
|
|
4953
|
+
function Pt(t) {
|
|
4954
4954
|
return t.replace(/[A-Z]/g, (n) => "-" + n.toLowerCase());
|
|
4955
4955
|
}
|
|
4956
|
-
function
|
|
4956
|
+
function Zt(t) {
|
|
4957
4957
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\u00A0/g, " ");
|
|
4958
4958
|
}
|
|
4959
|
-
function
|
|
4959
|
+
function at(t) {
|
|
4960
4960
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\u00A0/g, " ");
|
|
4961
4961
|
}
|
|
4962
|
-
function
|
|
4962
|
+
function G(t) {
|
|
4963
4963
|
if (t.type === "text")
|
|
4964
|
-
return
|
|
4964
|
+
return Zt(t.text);
|
|
4965
4965
|
if (t.type === "frag")
|
|
4966
|
-
return t.childNodes.map(
|
|
4966
|
+
return t.childNodes.map(G).join("");
|
|
4967
4967
|
let n = `<${t.tag}`;
|
|
4968
|
-
for (const
|
|
4969
|
-
n += ` ${
|
|
4970
|
-
const
|
|
4971
|
-
if (
|
|
4972
|
-
const
|
|
4973
|
-
n += ` style="${
|
|
4968
|
+
for (const e in t.attrs)
|
|
4969
|
+
n += ` ${e}="${at(t.attrs[e])}"`;
|
|
4970
|
+
const o = Object.keys(t.style);
|
|
4971
|
+
if (o.length) {
|
|
4972
|
+
const e = o.map((r) => `${Pt(r)}: ${t.style[r]}`).join("; ");
|
|
4973
|
+
n += ` style="${at(e)}"`;
|
|
4974
4974
|
}
|
|
4975
|
-
return n += ">", n += t.childNodes.map(
|
|
4975
|
+
return n += ">", n += t.childNodes.map(G).join(""), n += `</${t.tag}>`, n;
|
|
4976
4976
|
}
|
|
4977
|
-
function
|
|
4978
|
-
return
|
|
4977
|
+
function It(t) {
|
|
4978
|
+
return G(t);
|
|
4979
4979
|
}
|
|
4980
|
-
const
|
|
4981
|
-
function
|
|
4980
|
+
const Ft = "http://www.w3.org/1998/Math/MathML";
|
|
4981
|
+
function nt(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(nt(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(Ft, 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(nt(e, n));
|
|
4997
|
+
return o;
|
|
4998
4998
|
}
|
|
4999
|
-
const C = "mathvariant",
|
|
4999
|
+
const C = "mathvariant", Vt = {
|
|
5000
5000
|
"(": ["(", ")"],
|
|
5001
5001
|
"[": ["[", "]"],
|
|
5002
5002
|
"{": ["{", "}"],
|
|
@@ -5004,94 +5004,109 @@ const C = "mathvariant", Ft = {
|
|
|
5004
5004
|
"||": ["‖", "‖"],
|
|
5005
5005
|
"": ["", ""]
|
|
5006
5006
|
};
|
|
5007
|
-
function
|
|
5008
|
-
const
|
|
5009
|
-
|
|
5010
|
-
|
|
5007
|
+
function Bt(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
|
+
}
|
|
5011
|
+
function I(t, n) {
|
|
5012
|
+
const o = mt();
|
|
5013
|
+
Y(t);
|
|
5014
|
+
try {
|
|
5015
|
+
return n();
|
|
5016
|
+
} finally {
|
|
5017
|
+
Y(o);
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
5020
|
+
function X(t, n) {
|
|
5021
|
+
const o = L(t, "delim");
|
|
5022
|
+
let e = "";
|
|
5023
|
+
return o !== null && (o === void 0 ? e = n : e = o), Vt[e];
|
|
5011
5024
|
}
|
|
5012
5025
|
const x = {
|
|
5013
|
-
accent: (t, n,
|
|
5014
|
-
const
|
|
5015
|
-
|
|
5026
|
+
accent: (t, n, o) => {
|
|
5027
|
+
const e = h("mrow");
|
|
5028
|
+
e.append(g(t[0], o));
|
|
5016
5029
|
const r = h("mrow");
|
|
5017
|
-
r.append(g(t[1],
|
|
5030
|
+
r.append(g(t[1], o)), r.children[0].innerHTML = Jt(r.children[0].innerHTML);
|
|
5018
5031
|
const l = h("mover");
|
|
5019
|
-
return l.setAttribute("accent", "true"), l.append(
|
|
5032
|
+
return l.setAttribute("accent", "true"), l.append(e, r), l;
|
|
5020
5033
|
},
|
|
5021
|
-
attach: (t, n,
|
|
5022
|
-
const
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
const p = h("mrow");
|
|
5028
|
-
n.bl && p.append(g(n.bl, e));
|
|
5034
|
+
attach: (t, n, o) => {
|
|
5035
|
+
const e = { ...n };
|
|
5036
|
+
Bt(t[0]) || (e.t && !e.tr && (e.tr = e.t, delete e.t), e.b && !e.br && (e.br = e.b, delete e.b));
|
|
5037
|
+
const r = h("mrow");
|
|
5038
|
+
r.append(g(t[0]));
|
|
5039
|
+
let l;
|
|
5029
5040
|
const u = h("mrow");
|
|
5030
|
-
|
|
5041
|
+
e.tl && u.append(g(e.tl, o));
|
|
5042
|
+
const p = h("mrow");
|
|
5043
|
+
e.bl && p.append(g(e.bl, o));
|
|
5031
5044
|
const c = h("mrow");
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
const v = h("
|
|
5036
|
-
|
|
5045
|
+
e.tr && c.append(g(e.tr, o));
|
|
5046
|
+
const b = h("mrow");
|
|
5047
|
+
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) {
|
|
5048
|
+
const v = h("munderover");
|
|
5049
|
+
l ? v.append(l) : v.append(r);
|
|
5037
5050
|
const w = h("mrow");
|
|
5038
|
-
|
|
5051
|
+
e.t && w.append(g(e.t, o));
|
|
5052
|
+
const k = h("mrow");
|
|
5053
|
+
e.b && k.append(g(e.b, o)), v.append(k, w), l = v;
|
|
5039
5054
|
}
|
|
5040
|
-
return
|
|
5055
|
+
return l;
|
|
5041
5056
|
},
|
|
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"),
|
|
5057
|
+
scripts: (t, n, o) => g(t[0], o),
|
|
5058
|
+
limits: (t, n, o) => g(t[0], o),
|
|
5059
|
+
binom: (t, n, o) => {
|
|
5060
|
+
const e = h("mrow"), r = h("mrow");
|
|
5061
|
+
r.append(g(t[0], o));
|
|
5062
|
+
const l = h("mrow"), u = [];
|
|
5048
5063
|
for (const v of t.slice(1))
|
|
5049
|
-
|
|
5050
|
-
l.append(g(
|
|
5051
|
-
const
|
|
5052
|
-
|
|
5064
|
+
u.push(...v, $);
|
|
5065
|
+
l.append(g(u.slice(0, -1), o));
|
|
5066
|
+
const p = h("mfrac", null, { linethickness: "0" });
|
|
5067
|
+
p.append(r, l);
|
|
5053
5068
|
const c = h("mo", "("), b = h("mo", ")");
|
|
5054
|
-
return
|
|
5069
|
+
return e.append(c, p, b), e;
|
|
5055
5070
|
},
|
|
5056
|
-
cancel: (t, n,
|
|
5057
|
-
const
|
|
5071
|
+
cancel: (t, n, o) => {
|
|
5072
|
+
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
5073
|
let l = "";
|
|
5059
|
-
return
|
|
5074
|
+
return R(n.cross) ? l = `${r(!0)},${r(!1)}` : R(n.inverted) ? l = r(!1) : l = r(!0), e.style.backgroundImage = l, e.append(g(t[0], o)), e;
|
|
5060
5075
|
},
|
|
5061
|
-
cases: (t, n,
|
|
5062
|
-
const
|
|
5063
|
-
if (l.setAttribute("rowspacing",
|
|
5064
|
-
const
|
|
5065
|
-
|
|
5076
|
+
cases: (t, n, o) => {
|
|
5077
|
+
const e = h("mrow"), r = X(n, "{"), l = x.x_table(t, { cases: [] }, o), u = L(n, "gap") || "0.5em";
|
|
5078
|
+
if (l.setAttribute("rowspacing", u), R(n == null ? void 0 : n.reverse)) {
|
|
5079
|
+
const p = h("mo", r[1]);
|
|
5080
|
+
e.append(l, p);
|
|
5066
5081
|
} else {
|
|
5067
|
-
const
|
|
5068
|
-
|
|
5082
|
+
const p = h("mo", r[0]);
|
|
5083
|
+
e.append(p, l);
|
|
5069
5084
|
}
|
|
5070
|
-
return
|
|
5085
|
+
return e;
|
|
5071
5086
|
},
|
|
5072
|
-
frac: (t, n,
|
|
5073
|
-
const
|
|
5074
|
-
|
|
5087
|
+
frac: (t, n, o) => {
|
|
5088
|
+
const e = h("mrow");
|
|
5089
|
+
e.append(g(t[0], o));
|
|
5075
5090
|
const r = h("mrow");
|
|
5076
|
-
r.append(g(t[1],
|
|
5091
|
+
r.append(g(t[1], o));
|
|
5077
5092
|
const l = h("mfrac");
|
|
5078
|
-
return l.append(
|
|
5093
|
+
return l.append(e, r), l;
|
|
5079
5094
|
},
|
|
5080
|
-
lr: (t, n,
|
|
5081
|
-
const
|
|
5082
|
-
if (
|
|
5083
|
-
const c =
|
|
5095
|
+
lr: (t, n, o) => {
|
|
5096
|
+
const e = wt(t.map((c) => Lt(c))), r = Z(e), l = L(n, "size"), u = g(r, o), p = h("mrow");
|
|
5097
|
+
if (p.append(u), l && l !== "auto") {
|
|
5098
|
+
const c = p.children[0], b = p.children[p.children.length - 1];
|
|
5084
5099
|
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
5100
|
}
|
|
5086
|
-
return
|
|
5101
|
+
return p;
|
|
5087
5102
|
},
|
|
5088
5103
|
mid: (t, n) => {
|
|
5089
|
-
var
|
|
5090
|
-
return h("mo", (r = (
|
|
5104
|
+
var e, r;
|
|
5105
|
+
return h("mo", (r = (e = t == null ? void 0 : t[0]) == null ? void 0 : e[0]) == null ? void 0 : r.value, { stretchy: "true" });
|
|
5091
5106
|
},
|
|
5092
|
-
mat: (t, n,
|
|
5107
|
+
mat: (t, n, o) => {
|
|
5093
5108
|
var d;
|
|
5094
|
-
const
|
|
5109
|
+
const e = X(n, "("), r = h("mrow"), l = h("mo", e[0]), u = h("mo", e[1]), p = h("mtable");
|
|
5095
5110
|
let c;
|
|
5096
5111
|
(d = t[0][0]) != null && d.type ? c = [t] : c = t;
|
|
5097
5112
|
const b = L(n, "augment");
|
|
@@ -5101,7 +5116,7 @@ const x = {
|
|
|
5101
5116
|
const i = [];
|
|
5102
5117
|
for (let f = 1; f < c.length; f++)
|
|
5103
5118
|
i.push(f === s);
|
|
5104
|
-
|
|
5119
|
+
p.setAttribute(
|
|
5105
5120
|
"rowlines",
|
|
5106
5121
|
i.map((f) => f ? "solid" : "none").join(" ")
|
|
5107
5122
|
);
|
|
@@ -5110,129 +5125,139 @@ const x = {
|
|
|
5110
5125
|
const i = [];
|
|
5111
5126
|
for (let f = 1; f < c[0].length; f++)
|
|
5112
5127
|
i.push(f === a);
|
|
5113
|
-
|
|
5128
|
+
p.setAttribute(
|
|
5114
5129
|
"columnlines",
|
|
5115
5130
|
i.map((f) => f ? "solid" : "none").join(" ")
|
|
5116
5131
|
);
|
|
5117
5132
|
}
|
|
5118
5133
|
}
|
|
5119
5134
|
const v = L(n, "gap"), w = L(n, "row-gap"), k = L(n, "column-gap");
|
|
5120
|
-
|
|
5135
|
+
p.setAttribute("columnspacing", k || v || "0.5em"), p.setAttribute("rowspacing", w || v || "0.5em");
|
|
5121
5136
|
for (const a of c) {
|
|
5122
5137
|
const s = h("mtr");
|
|
5123
5138
|
for (const i of a) {
|
|
5124
5139
|
const f = h("mtd");
|
|
5125
|
-
f.append(g(i,
|
|
5140
|
+
f.append(g(i, o)), s.append(f);
|
|
5126
5141
|
}
|
|
5127
|
-
|
|
5142
|
+
p.append(s);
|
|
5128
5143
|
}
|
|
5129
|
-
return r.append(l,
|
|
5144
|
+
return r.append(l, p, u), r;
|
|
5130
5145
|
},
|
|
5131
|
-
root: (t, n,
|
|
5132
|
-
const
|
|
5133
|
-
|
|
5146
|
+
root: (t, n, o) => {
|
|
5147
|
+
const e = h("mrow");
|
|
5148
|
+
e.append(g(t[0], o));
|
|
5134
5149
|
const r = h("mrow");
|
|
5135
|
-
r.append(g(t[1],
|
|
5150
|
+
r.append(g(t[1], o));
|
|
5136
5151
|
const l = h("mroot");
|
|
5137
|
-
return l.append(r,
|
|
5152
|
+
return l.append(r, e), l;
|
|
5138
5153
|
},
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5154
|
+
// msqrt(与 typst html 导出一致:<msqrt>…</msqrt>),被开方数直接作为子元素,
|
|
5155
|
+
// 不包 mrow、不走 mroot——空指数的 mroot 会被 MathML 校验/渲染当成错误结构。
|
|
5156
|
+
sqrt: (t, n, o) => {
|
|
5157
|
+
const e = h("msqrt");
|
|
5158
|
+
return e.append(g(t[0], o)), e;
|
|
5143
5159
|
},
|
|
5144
|
-
inline
|
|
5145
|
-
|
|
5160
|
+
// display/inline/script/sscript 是局部样式(typst 的样式栈:内层覆盖外层,
|
|
5161
|
+
// `display(script(sum_1^2))` 仍走角标)。limits 的判定在 ast3 的「处理^_」
|
|
5162
|
+
// 里读全局 display 标志,故在渲染子树期间改写它、渲染完恢复;wrapper 用
|
|
5163
|
+
// mstyle 而不是 mrow —— MathML Core 里 displaystyle/scriptlevel 是 mstyle
|
|
5164
|
+
// 的属性,挂在 mrow 上浏览器会忽略(∑ 大小/脚标层级都随之失真)。
|
|
5165
|
+
display: (t, n, o) => I(!0, () => {
|
|
5166
|
+
const e = h("mstyle", null, { displaystyle: "true" });
|
|
5167
|
+
return e.append(g(t[0], o)), e;
|
|
5168
|
+
}),
|
|
5169
|
+
inline: (t, n, o) => I(!1, () => {
|
|
5170
|
+
const e = h("mstyle", null, {
|
|
5146
5171
|
displaystyle: "false",
|
|
5147
5172
|
scriptlevel: "0"
|
|
5148
5173
|
});
|
|
5149
|
-
return
|
|
5150
|
-
},
|
|
5151
|
-
script: (t, n,
|
|
5152
|
-
const
|
|
5174
|
+
return e.append(g(t[0], o)), e;
|
|
5175
|
+
}),
|
|
5176
|
+
script: (t, n, o) => I(!1, () => {
|
|
5177
|
+
const e = h("mstyle", null, {
|
|
5153
5178
|
displaystyle: "false",
|
|
5154
5179
|
scriptlevel: "1"
|
|
5155
5180
|
});
|
|
5156
|
-
return
|
|
5157
|
-
},
|
|
5158
|
-
sscript: (t, n,
|
|
5159
|
-
const
|
|
5181
|
+
return e.append(g(t[0], o)), e;
|
|
5182
|
+
}),
|
|
5183
|
+
sscript: (t, n, o) => I(!1, () => {
|
|
5184
|
+
const e = h("mstyle", null, {
|
|
5160
5185
|
displaystyle: "false",
|
|
5161
5186
|
scriptlevel: "2"
|
|
5162
5187
|
});
|
|
5163
|
-
return
|
|
5164
|
-
},
|
|
5165
|
-
upright: (t, n,
|
|
5166
|
-
const
|
|
5167
|
-
return
|
|
5188
|
+
return e.append(g(t[0], o)), e;
|
|
5189
|
+
}),
|
|
5190
|
+
upright: (t, n, o) => {
|
|
5191
|
+
const e = h("mrow");
|
|
5192
|
+
return e.append(g(t[0], o)), e.querySelectorAll("mi").forEach((r) => {
|
|
5168
5193
|
r.getAttribute(C) || r.setAttribute(C, "normal");
|
|
5169
|
-
}),
|
|
5194
|
+
}), e.querySelectorAll("ms").forEach((r) => {
|
|
5170
5195
|
r.getAttribute(C) || r.setAttribute(C, "normal");
|
|
5171
|
-
}),
|
|
5196
|
+
}), e;
|
|
5172
5197
|
},
|
|
5173
|
-
italic: (t, n,
|
|
5174
|
-
const
|
|
5175
|
-
return
|
|
5198
|
+
italic: (t, n, o) => {
|
|
5199
|
+
const e = h("mrow");
|
|
5200
|
+
return e.append(g(t[0], o)), e.querySelectorAll("mi").forEach((r) => {
|
|
5176
5201
|
r.getAttribute(C) || r.setAttribute(C, "italic");
|
|
5177
|
-
}),
|
|
5202
|
+
}), e.querySelectorAll("ms").forEach((r) => {
|
|
5178
5203
|
r.getAttribute(C) || r.setAttribute(C, "italic");
|
|
5179
|
-
}),
|
|
5204
|
+
}), e;
|
|
5180
5205
|
},
|
|
5181
|
-
bold: (t, n,
|
|
5182
|
-
const
|
|
5183
|
-
return
|
|
5206
|
+
bold: (t, n, o) => {
|
|
5207
|
+
const e = h("mrow");
|
|
5208
|
+
return e.style.fontWeight = "bold", e.append(g(t[0], o)), e;
|
|
5184
5209
|
},
|
|
5185
|
-
op: (t, n,
|
|
5186
|
-
const
|
|
5187
|
-
return r.append(g(t[0],
|
|
5210
|
+
op: (t, n, o) => {
|
|
5211
|
+
const e = h("mrow"), r = h("ms");
|
|
5212
|
+
return r.append(g(t[0], o)), e.append(r), e;
|
|
5188
5213
|
},
|
|
5189
|
-
underline: (t, n,
|
|
5190
|
-
overline: (t, n,
|
|
5191
|
-
underbrace: (t, n,
|
|
5192
|
-
overbrace: (t, n,
|
|
5193
|
-
underbracket: (t, n,
|
|
5194
|
-
overbracket: (t, n,
|
|
5214
|
+
underline: (t, n, o) => ct("under", t[0], o),
|
|
5215
|
+
overline: (t, n, o) => ct("over", t[0], o),
|
|
5216
|
+
underbrace: (t, n, o) => F("under", t[0], "⏟", t == null ? void 0 : t[1], o),
|
|
5217
|
+
overbrace: (t, n, o) => F("over", t[0], "⏞", t == null ? void 0 : t[1], o),
|
|
5218
|
+
underbracket: (t, n, o) => F("under", t[0], "⎵", t == null ? void 0 : t[1], o),
|
|
5219
|
+
overbracket: (t, n, o) => F("over", t[0], "⎴", t == null ? void 0 : t[1], o),
|
|
5195
5220
|
serif: (t) => g(t[0], "serif"),
|
|
5196
5221
|
sans: (t) => g(t[0], "sans"),
|
|
5197
5222
|
frak: (t) => g(t[0], "frak"),
|
|
5198
5223
|
mono: (t) => g(t[0], "mono"),
|
|
5199
5224
|
bb: (t) => g(t[0], "bb"),
|
|
5200
5225
|
cal: (t) => g(t[0], "cal"),
|
|
5201
|
-
vec: (t, n,
|
|
5202
|
-
const
|
|
5203
|
-
return
|
|
5226
|
+
vec: (t, n, o) => {
|
|
5227
|
+
const e = X(n, "("), r = h("mrow"), l = h("mo", e[0]), u = h("mo", e[1]), p = et(t, o), c = L(n, "gap") || "0.5em";
|
|
5228
|
+
return p.setAttribute("rowspacing", c), p.setAttribute("columnspacing", "0.5em"), r.append(l, p, u), r;
|
|
5204
5229
|
},
|
|
5205
5230
|
h: (t, n) => h("mspace", "", { width: t[0][0].value }),
|
|
5206
5231
|
// 额外
|
|
5207
5232
|
//
|
|
5208
5233
|
x_table: (t, n) => {
|
|
5209
|
-
const
|
|
5210
|
-
return n.cases &&
|
|
5234
|
+
const o = et(t);
|
|
5235
|
+
return n.cases && o.setAttribute("columnalign", "left"), o;
|
|
5211
5236
|
}
|
|
5212
5237
|
};
|
|
5213
|
-
function
|
|
5214
|
-
let
|
|
5238
|
+
function et(t, n, o) {
|
|
5239
|
+
let e = 0;
|
|
5215
5240
|
const r = h("mtable");
|
|
5216
5241
|
for (const l of t) {
|
|
5217
|
-
const
|
|
5218
|
-
|
|
5242
|
+
const u = l.filter((p) => q(p, y("&"))).length;
|
|
5243
|
+
u > e && (e = u);
|
|
5219
5244
|
}
|
|
5220
5245
|
for (const l of t) {
|
|
5221
|
-
const
|
|
5246
|
+
const u = h("mtr"), p = [[]];
|
|
5222
5247
|
for (let b = 0; b < l.length; b++)
|
|
5223
|
-
q(l[b], y("&")) ?
|
|
5224
|
-
for (const b of
|
|
5248
|
+
q(l[b], y("&")) ? p.push([]) : p.at(-1).push(l[b]);
|
|
5249
|
+
for (const b of p) {
|
|
5225
5250
|
const v = h("mtd");
|
|
5226
|
-
|
|
5251
|
+
u.append(v), v.append(g(b, n));
|
|
5227
5252
|
}
|
|
5228
5253
|
const c = [];
|
|
5229
|
-
for (let b = 0; b <=
|
|
5230
|
-
|
|
5231
|
-
r.setAttribute("columnalign", c.join(" ")), r.setAttribute("columnspacing", "0"), r.append(
|
|
5254
|
+
for (let b = 0; b <= e; b++)
|
|
5255
|
+
e > 0 ? c.push(b % 2 === 0 ? "right" : "left") : c.push(o ? "left" : "center");
|
|
5256
|
+
r.setAttribute("columnalign", c.join(" ")), r.setAttribute("columnspacing", "0"), r.append(u);
|
|
5232
5257
|
}
|
|
5233
5258
|
return r;
|
|
5234
5259
|
}
|
|
5235
|
-
function
|
|
5260
|
+
function Kt(t) {
|
|
5236
5261
|
const n = [
|
|
5237
5262
|
_.prime,
|
|
5238
5263
|
_["prime.double"],
|
|
@@ -5241,28 +5266,28 @@ function Vt(t) {
|
|
|
5241
5266
|
];
|
|
5242
5267
|
return t <= 4 ? n[t - 1] : _.prime.repeat(t);
|
|
5243
5268
|
}
|
|
5244
|
-
function
|
|
5245
|
-
for (const t of
|
|
5246
|
-
x[t.id] = (n,
|
|
5247
|
-
const r = x.op([[{ type: "str", value: t.str || t.id }]], {},
|
|
5269
|
+
function Rt() {
|
|
5270
|
+
for (const t of dt)
|
|
5271
|
+
x[t.id] = (n, o, e) => {
|
|
5272
|
+
const r = x.op([[{ type: "str", value: t.str || t.id }]], {}, e);
|
|
5248
5273
|
if (n) {
|
|
5249
|
-
const l =
|
|
5250
|
-
return l.append(r,
|
|
5274
|
+
const l = yt();
|
|
5275
|
+
return l.append(r, Ut(wt(n))), l;
|
|
5251
5276
|
} else
|
|
5252
5277
|
return r;
|
|
5253
5278
|
};
|
|
5254
5279
|
}
|
|
5255
|
-
|
|
5256
|
-
const
|
|
5280
|
+
Rt();
|
|
5281
|
+
const it = {
|
|
5257
5282
|
quad: "1em",
|
|
5258
5283
|
med: "0.222em",
|
|
5259
5284
|
thin: "0.17em",
|
|
5260
5285
|
thick: "0.28em",
|
|
5261
5286
|
wide: "2em"
|
|
5262
5287
|
};
|
|
5263
|
-
for (const t in
|
|
5264
|
-
x[t] = () => x.h([[{ type: "str", value:
|
|
5265
|
-
function
|
|
5288
|
+
for (const t in it)
|
|
5289
|
+
x[t] = () => x.h([[{ type: "str", value: it[t] }]]);
|
|
5290
|
+
function Jt(t) {
|
|
5266
5291
|
switch (t) {
|
|
5267
5292
|
case "̀":
|
|
5268
5293
|
case "`":
|
|
@@ -5333,7 +5358,7 @@ function Kt(t) {
|
|
|
5333
5358
|
return t;
|
|
5334
5359
|
}
|
|
5335
5360
|
}
|
|
5336
|
-
function
|
|
5361
|
+
function Wt() {
|
|
5337
5362
|
const t = [
|
|
5338
5363
|
"grave",
|
|
5339
5364
|
"acute",
|
|
@@ -5358,10 +5383,10 @@ function Rt() {
|
|
|
5358
5383
|
"harpoon.lt"
|
|
5359
5384
|
];
|
|
5360
5385
|
for (const n of t)
|
|
5361
|
-
x[n] = (
|
|
5386
|
+
x[n] = (o, e, r) => x.accent([o[0], [{ type: "f", value: n }]], {}, r);
|
|
5362
5387
|
}
|
|
5363
|
-
|
|
5364
|
-
function
|
|
5388
|
+
Wt();
|
|
5389
|
+
function Gt() {
|
|
5365
5390
|
const t = [
|
|
5366
5391
|
{ name: "abs", l: y("|"), r: y("|") },
|
|
5367
5392
|
{ name: "norm", l: y("‖"), r: y("‖") },
|
|
@@ -5370,74 +5395,74 @@ function Jt() {
|
|
|
5370
5395
|
{ name: "round", l: y("⌊"), r: y("⌉") }
|
|
5371
5396
|
];
|
|
5372
5397
|
for (const n of t)
|
|
5373
|
-
x[n.name] = (
|
|
5398
|
+
x[n.name] = (o, e, r) => x.lr([[n.l, ...o[0], n.r]], e, r);
|
|
5374
5399
|
}
|
|
5375
|
-
|
|
5376
|
-
function
|
|
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,
|
|
5400
|
+
Gt();
|
|
5401
|
+
function F(t, n, o, e, r) {
|
|
5402
|
+
const l = t === "under" ? h("munder", null, { accentunder: "true" }) : h("mover", null, { accent: "true" }), u = h("mrow");
|
|
5403
|
+
if (u.append(g(n, r)), e) {
|
|
5404
|
+
const p = h("mrow");
|
|
5405
|
+
p.append(g(e, r));
|
|
5406
|
+
const c = h(t === "under" ? "munder" : "mover"), b = h("mo", o);
|
|
5407
|
+
c.append(b, p), l.append(u, c);
|
|
5383
5408
|
} else {
|
|
5384
|
-
const
|
|
5385
|
-
l.append(
|
|
5409
|
+
const p = h("mo", o);
|
|
5410
|
+
l.append(u, p);
|
|
5386
5411
|
}
|
|
5387
5412
|
return l;
|
|
5388
5413
|
}
|
|
5389
|
-
function
|
|
5390
|
-
const
|
|
5391
|
-
return r.append(g(n,
|
|
5414
|
+
function ct(t, n, o) {
|
|
5415
|
+
const e = t === "under" ? h("munder", null, { accentunder: "true" }) : h("mover", null, { accent: "true" }), r = h("mrow");
|
|
5416
|
+
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
5417
|
}
|
|
5393
|
-
const
|
|
5418
|
+
const V = {
|
|
5394
5419
|
"√": x.sqrt,
|
|
5395
|
-
"∛": (t, n,
|
|
5396
|
-
"∜": (t, n,
|
|
5420
|
+
"∛": (t, n, o) => x.root([[y("3")], t[0]], null, o),
|
|
5421
|
+
"∜": (t, n, o) => x.root([[y("4")], t[0]], null, o)
|
|
5397
5422
|
};
|
|
5398
|
-
function
|
|
5399
|
-
const n = h("mrow"),
|
|
5400
|
-
|
|
5401
|
-
const
|
|
5402
|
-
return r.textContent = ")", n.append(
|
|
5423
|
+
function Ut(t) {
|
|
5424
|
+
const n = h("mrow"), o = h("mo");
|
|
5425
|
+
o.textContent = "(";
|
|
5426
|
+
const e = g(t), r = h("mo");
|
|
5427
|
+
return r.textContent = ")", n.append(o, e, r), n;
|
|
5403
5428
|
}
|
|
5404
|
-
function
|
|
5405
|
-
t =
|
|
5429
|
+
function Xt(t) {
|
|
5430
|
+
t = Z(t);
|
|
5406
5431
|
const n = new Object();
|
|
5407
|
-
let
|
|
5432
|
+
let o = "", e = [];
|
|
5408
5433
|
t.push($);
|
|
5409
5434
|
for (let r = 0; r < t.length; r++)
|
|
5410
|
-
!
|
|
5435
|
+
!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
5436
|
return n;
|
|
5412
5437
|
}
|
|
5413
5438
|
function L(t, n) {
|
|
5414
|
-
var
|
|
5415
|
-
if (!((
|
|
5439
|
+
var e;
|
|
5440
|
+
if (!((e = t == null ? void 0 : t[n]) != null && e[0]))
|
|
5416
5441
|
return;
|
|
5417
|
-
const
|
|
5418
|
-
if (
|
|
5419
|
-
if (
|
|
5442
|
+
const o = t[n][0];
|
|
5443
|
+
if (o.type === "sharp") {
|
|
5444
|
+
if (o.value === "true")
|
|
5420
5445
|
return !0;
|
|
5421
|
-
if (
|
|
5446
|
+
if (o.value === "false")
|
|
5422
5447
|
return !1;
|
|
5423
|
-
if (
|
|
5448
|
+
if (o.value === "none")
|
|
5424
5449
|
return null;
|
|
5425
|
-
if (
|
|
5426
|
-
return
|
|
5450
|
+
if (o.children)
|
|
5451
|
+
return o.children.find((r) => q(r, y(":"))) ? Xt(o.children) : o.children.map((r) => r.value).join("");
|
|
5427
5452
|
}
|
|
5428
5453
|
return t[n].map((r) => r.value).join("");
|
|
5429
5454
|
}
|
|
5430
|
-
function
|
|
5455
|
+
function wt(t) {
|
|
5431
5456
|
const n = [];
|
|
5432
|
-
for (const
|
|
5433
|
-
n.push(...
|
|
5457
|
+
for (const o of t)
|
|
5458
|
+
n.push(...o, y(","));
|
|
5434
5459
|
return n.slice(0, -1);
|
|
5435
5460
|
}
|
|
5436
|
-
function
|
|
5437
|
-
function
|
|
5461
|
+
function ut(t, n = "serif") {
|
|
5462
|
+
function o(r) {
|
|
5438
5463
|
return "abcdefghijklmnopqrstuvwxyz".indexOf(r.toLowerCase());
|
|
5439
5464
|
}
|
|
5440
|
-
const
|
|
5465
|
+
const e = {
|
|
5441
5466
|
sans: {
|
|
5442
5467
|
num: "𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫",
|
|
5443
5468
|
low: "𝖺𝖻𝖼𝖽𝖾𝖿𝗀𝗁𝗂𝗃𝗄𝗅𝗆𝗇𝗈𝗉𝗊𝗋𝗌𝗍𝗎𝗏𝗐𝗑𝗒𝗓",
|
|
@@ -5462,59 +5487,59 @@ function it(t, n = "serif") {
|
|
|
5462
5487
|
up: "𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵"
|
|
5463
5488
|
}
|
|
5464
5489
|
};
|
|
5465
|
-
return n === "serif" || (t = t.replace(/[0-9]/g, (r) => [...
|
|
5490
|
+
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
5491
|
}
|
|
5467
5492
|
function g(t, n) {
|
|
5468
|
-
const
|
|
5469
|
-
t =
|
|
5493
|
+
const o = yt();
|
|
5494
|
+
t = gt(t);
|
|
5470
5495
|
{
|
|
5471
|
-
let
|
|
5496
|
+
let e = !1;
|
|
5472
5497
|
for (const r in t) {
|
|
5473
5498
|
const l = t[r];
|
|
5474
|
-
if (
|
|
5475
|
-
|
|
5499
|
+
if (lt(l)) {
|
|
5500
|
+
e = !0;
|
|
5476
5501
|
break;
|
|
5477
5502
|
}
|
|
5478
5503
|
}
|
|
5479
|
-
if (
|
|
5504
|
+
if (e) {
|
|
5480
5505
|
const r = [[]];
|
|
5481
5506
|
for (let l = 0; l < t.length; l++) {
|
|
5482
|
-
const
|
|
5483
|
-
|
|
5507
|
+
const u = t[l];
|
|
5508
|
+
lt(u) ? r.push([]) : r.at(-1).push(u);
|
|
5484
5509
|
}
|
|
5485
|
-
return
|
|
5510
|
+
return et(r, void 0, !mt());
|
|
5486
5511
|
}
|
|
5487
5512
|
}
|
|
5488
|
-
t =
|
|
5513
|
+
t = vt(t);
|
|
5489
5514
|
{
|
|
5490
|
-
const
|
|
5515
|
+
const e = [];
|
|
5491
5516
|
for (const r of t)
|
|
5492
|
-
r.type === "v" && r.value === "&" && !r.esc ||
|
|
5493
|
-
t =
|
|
5517
|
+
r.type === "v" && r.value === "&" && !r.esc || e.push(r);
|
|
5518
|
+
t = e;
|
|
5494
5519
|
}
|
|
5495
5520
|
{
|
|
5496
|
-
const
|
|
5521
|
+
const e = [];
|
|
5497
5522
|
for (const r of t)
|
|
5498
|
-
r.type === "group1" ?
|
|
5499
|
-
t =
|
|
5523
|
+
r.type === "group1" ? e.push(...r.children) : e.push(r);
|
|
5524
|
+
t = e;
|
|
5500
5525
|
}
|
|
5501
|
-
for (const
|
|
5502
|
-
const r = Number(
|
|
5526
|
+
for (const e in t) {
|
|
5527
|
+
const r = Number(e), l = t[r];
|
|
5503
5528
|
if (l.type === "f") {
|
|
5504
5529
|
if (l.children && (l.kh === "()" || !l.kh)) {
|
|
5505
|
-
const { attr:
|
|
5530
|
+
const { attr: u, dic: p } = kt(l);
|
|
5506
5531
|
if (x[l.value]) {
|
|
5507
|
-
const c = x[l.value](
|
|
5508
|
-
|
|
5532
|
+
const c = x[l.value](u, p, n);
|
|
5533
|
+
o.append(c);
|
|
5509
5534
|
} else if (_[l.value]) {
|
|
5510
5535
|
const c = h("mi", _[l.value]);
|
|
5511
|
-
|
|
5512
|
-
} else if (
|
|
5513
|
-
const c =
|
|
5514
|
-
|
|
5536
|
+
o.append(c, g(Tt(l.children), n));
|
|
5537
|
+
} else if (V[l.value]) {
|
|
5538
|
+
const c = V[l.value](u, p, n);
|
|
5539
|
+
o.append(c);
|
|
5515
5540
|
}
|
|
5516
5541
|
} else if (_[l.value]) {
|
|
5517
|
-
let
|
|
5542
|
+
let u, p = null;
|
|
5518
5543
|
const c = {
|
|
5519
5544
|
" ": "0.36em",
|
|
5520
5545
|
" ": "0.5em",
|
|
@@ -5528,60 +5553,60 @@ function g(t, n) {
|
|
|
5528
5553
|
" ": "0.17em",
|
|
5529
5554
|
" ": "0.09em"
|
|
5530
5555
|
};
|
|
5531
|
-
_[l.value].match(/[a-zA-Z\u0391-\u03C9]/) ?
|
|
5532
|
-
const b = h(
|
|
5533
|
-
|
|
5556
|
+
_[l.value].match(/[a-zA-Z\u0391-\u03C9]/) ? u = "mi" : c[_[l.value]] ? (u = "mspace", p = { width: c[_[l.value]] }) : u = "mo";
|
|
5557
|
+
const b = h(u, _[l.value], p);
|
|
5558
|
+
o.append(b);
|
|
5534
5559
|
} else if (x[l.value]) {
|
|
5535
|
-
const
|
|
5536
|
-
|
|
5537
|
-
} else if (
|
|
5538
|
-
const
|
|
5539
|
-
|
|
5560
|
+
const u = x[l.value](null, null, n);
|
|
5561
|
+
o.append(u);
|
|
5562
|
+
} else if (V[l.value]) {
|
|
5563
|
+
const u = V[l.value]([l.children], null, n);
|
|
5564
|
+
o.append(u);
|
|
5540
5565
|
}
|
|
5541
5566
|
}
|
|
5542
5567
|
if (l.type === "str") {
|
|
5543
|
-
const
|
|
5544
|
-
|
|
5568
|
+
const u = h("ms", ut(l.value, n));
|
|
5569
|
+
o.append(u);
|
|
5545
5570
|
}
|
|
5546
5571
|
if (l.type === "v" || l.type === "sharp") {
|
|
5547
|
-
let
|
|
5548
|
-
l.value.match(/[0-9.]+/) ?
|
|
5549
|
-
const c = h(
|
|
5550
|
-
|
|
5572
|
+
let u, p = l.value;
|
|
5573
|
+
l.value.match(/[0-9.]+/) ? u = "mn" : l.value.match(/[a-zA-Z\u0391-\u03C9]/) ? u = "mi" : (l.value.match(/^'+$/) && (l.esc || (p = Kt(l.value.length))), u = "mo"), l.type === "sharp" && l.value.startsWith("emoji.") && (u = "mi", p = St[l.value.replace("emoji.", "")]);
|
|
5574
|
+
const c = h(u, ut(p, n));
|
|
5575
|
+
o.append(c);
|
|
5551
5576
|
}
|
|
5552
|
-
l.type === "group" && (l.kh && l.kh.length === 1 ? (
|
|
5577
|
+
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
5578
|
}
|
|
5554
|
-
return
|
|
5579
|
+
return o;
|
|
5555
5580
|
}
|
|
5556
|
-
function
|
|
5581
|
+
function tn(t) {
|
|
5557
5582
|
for (const n in t)
|
|
5558
|
-
|
|
5583
|
+
J[n] && (J[n] = t[n]);
|
|
5559
5584
|
}
|
|
5560
|
-
function
|
|
5561
|
-
|
|
5562
|
-
const
|
|
5563
|
-
n ||
|
|
5564
|
-
const r = g(
|
|
5565
|
-
return
|
|
5585
|
+
function qt(t, n) {
|
|
5586
|
+
Y(!n);
|
|
5587
|
+
const o = Nt(t), e = h("math");
|
|
5588
|
+
n || e.setAttribute("display", "block");
|
|
5589
|
+
const r = g(o);
|
|
5590
|
+
return e.append(r), e;
|
|
5566
5591
|
}
|
|
5567
|
-
function
|
|
5568
|
-
return
|
|
5592
|
+
function nn(t, n) {
|
|
5593
|
+
return nt(qt(t, n));
|
|
5569
5594
|
}
|
|
5570
|
-
function
|
|
5571
|
-
return
|
|
5595
|
+
function en(t, n) {
|
|
5596
|
+
return It(qt(t, n));
|
|
5572
5597
|
}
|
|
5573
|
-
const
|
|
5598
|
+
const on = {
|
|
5574
5599
|
lan: "0.11.1",
|
|
5575
5600
|
symbol: "0.15.1",
|
|
5576
5601
|
emoji: "0.15.1"
|
|
5577
5602
|
};
|
|
5578
5603
|
export {
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5604
|
+
gt as ast2,
|
|
5605
|
+
vt as ast3,
|
|
5606
|
+
tn as init,
|
|
5607
|
+
nn as toMML,
|
|
5608
|
+
en as toMMLHTML,
|
|
5609
|
+
qt as toMMLV,
|
|
5610
|
+
on as version
|
|
5586
5611
|
};
|
|
5587
5612
|
//# sourceMappingURL=xmmath.es.js.map
|