@pie-element/shared-math-rendering-mathjax 0.1.7-next.20261015154938 → 0.1.7-next.20261018222107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.d.ts +1 -3
- package/dist/browser/index.js +47 -47
- package/dist/browser/{mathjax-CptWnMbQ.js → mathjax-DqXi3q4c.js} +2 -2
- package/dist/index.js +310 -310
- package/dist/tex-dialect.d.ts +21 -0
- package/dist/tex-to-mathml/index.d.ts +6 -0
- package/dist/tex-to-mathml/index.js +15195 -0
- package/package.json +6 -2
package/dist/adapter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MathjaxOptions } from './types.js';
|
|
2
|
-
|
|
2
|
+
import { type MathJaxMacro } from './tex-dialect.js';
|
|
3
3
|
export interface MathItem {
|
|
4
4
|
typesetRoot?: Element | null;
|
|
5
5
|
state?: () => number;
|
|
@@ -97,8 +97,6 @@ export interface MathJaxGlobal {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
/** `latex` without the pair of legacy delimiters around all of it, if it has one. */
|
|
101
|
-
export declare function stripLegacyDelimiters(latex: string): string;
|
|
102
100
|
/**
|
|
103
101
|
* Create a MathJax renderer function.
|
|
104
102
|
*
|
package/dist/browser/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var o;
|
|
|
4
4
|
function s() {
|
|
5
5
|
return o;
|
|
6
6
|
}
|
|
7
|
-
var c = import("./mathjax-
|
|
7
|
+
var c = import("./mathjax-DqXi3q4c.js");
|
|
8
8
|
c.catch(() => {});
|
|
9
9
|
async function l(e, t) {
|
|
10
10
|
let { createMathJax: n } = await c;
|
|
@@ -712,20 +712,41 @@ function K(e) {
|
|
|
712
712
|
for (let t of e.querySelectorAll("mjx-container")) Qe(t);
|
|
713
713
|
}
|
|
714
714
|
//#endregion
|
|
715
|
-
//#region src/
|
|
716
|
-
var
|
|
717
|
-
|
|
715
|
+
//#region src/tex-dialect.ts
|
|
716
|
+
var $e = {
|
|
717
|
+
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
718
|
+
overarc: "\\overparen",
|
|
719
|
+
napprox: "\\not\\approx",
|
|
720
|
+
longdiv: "\\enclose{longdiv}",
|
|
721
|
+
abs: ["\\left|#1\\right|", 1],
|
|
722
|
+
perpendicular: "\\perp",
|
|
723
|
+
divide: "\\div"
|
|
724
|
+
}, et = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, tt = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, nt = /\\embed\{newLine\}\[\]/g, rt = [
|
|
725
|
+
["$$", "$$"],
|
|
726
|
+
["$", "$"],
|
|
727
|
+
["\\[", "\\]"],
|
|
728
|
+
["\\(", "\\)"]
|
|
729
|
+
];
|
|
730
|
+
function it(e) {
|
|
731
|
+
for (let [t, n] of rt) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
|
|
732
|
+
return e;
|
|
733
|
+
}
|
|
734
|
+
function at(e) {
|
|
735
|
+
return `\\(${it(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e)}\\)`.replace(nt, "\\newline ");
|
|
736
|
+
}
|
|
737
|
+
var ot = "mathjax_ignore", st = "mathjax_process", q = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page", ct = "pie-mathjax-version-conflict", lt = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
|
|
738
|
+
function ut(e, t) {
|
|
718
739
|
if (typeof window > "u") return;
|
|
719
740
|
let n = globalThis;
|
|
720
|
-
n[
|
|
741
|
+
n[lt] ??= {
|
|
721
742
|
logged: !1,
|
|
722
743
|
conditions: []
|
|
723
744
|
};
|
|
724
|
-
let r = n[
|
|
745
|
+
let r = n[lt];
|
|
725
746
|
if (r.conditions.includes(e)) return;
|
|
726
747
|
r.conditions.push(e);
|
|
727
748
|
let i = `[math-rendering] Unsupported page (${e}): ${t}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${q}`;
|
|
728
|
-
r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(
|
|
749
|
+
r.logged || (r.logged = !0, console.error(i)), window.dispatchEvent(new CustomEvent(ct, { detail: {
|
|
729
750
|
condition: e,
|
|
730
751
|
message: i,
|
|
731
752
|
docsUrl: q
|
|
@@ -733,44 +754,23 @@ function tt(e, t) {
|
|
|
733
754
|
}
|
|
734
755
|
//#endregion
|
|
735
756
|
//#region src/adapter.ts
|
|
736
|
-
var
|
|
737
|
-
parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
|
|
738
|
-
overarc: "\\overparen",
|
|
739
|
-
napprox: "\\not\\approx",
|
|
740
|
-
longdiv: "\\enclose{longdiv}",
|
|
741
|
-
abs: ["\\left|#1\\right|", 1],
|
|
742
|
-
perpendicular: "\\perp",
|
|
743
|
-
divide: "\\div"
|
|
744
|
-
}, rt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", it = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, at = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, ot = /\\embed\{newLine\}\[\]/g, st = [
|
|
745
|
-
["$$", "$$"],
|
|
746
|
-
["$", "$"],
|
|
747
|
-
["\\[", "\\]"],
|
|
748
|
-
["\\(", "\\)"]
|
|
749
|
-
], ct = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), lt = "MJX-CHTML-styles", ut = "PIE-MJX-SVG-styles", J = "PIE-MathJax-Menu-Settings", dt = { "mjx-container[overflow=\"linebreak\"][display]": {
|
|
757
|
+
var dt = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", ft = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading"), pt = "MJX-CHTML-styles", mt = "PIE-MJX-SVG-styles", J = "PIE-MathJax-Menu-Settings", ht = { "mjx-container[overflow=\"linebreak\"][display]": {
|
|
750
758
|
overflow: "auto clip",
|
|
751
759
|
"min-width": "initial !important"
|
|
752
|
-
} },
|
|
760
|
+
} }, gt = 200, _t = 201, vt = 202;
|
|
753
761
|
function Y(e) {
|
|
754
762
|
let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
|
|
755
763
|
for (let e of t) for (let t of [e, ...e.querySelectorAll("[data-latex],[data-latex-item]")]) t.removeAttribute("data-latex"), t.removeAttribute("data-latex-item");
|
|
756
764
|
}
|
|
757
|
-
function ht(e) {
|
|
758
|
-
for (let [t, n] of st) if (e.startsWith(t) && e.endsWith(n)) return e.substring(t.length, e.length - n.length);
|
|
759
|
-
return e;
|
|
760
|
-
}
|
|
761
|
-
function gt(e) {
|
|
762
|
-
return ht(e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e);
|
|
763
|
-
}
|
|
764
|
-
var _t = "mathjax_ignore", vt = "mathjax_process";
|
|
765
765
|
function yt(e, t) {
|
|
766
|
-
let n = e.closest(`.${
|
|
767
|
-
return n !== null && t.contains(n) && !n.classList.contains(
|
|
766
|
+
let n = e.closest(`.${ot}, .${st}`);
|
|
767
|
+
return n !== null && t.contains(n) && !n.classList.contains("mathjax_process");
|
|
768
768
|
}
|
|
769
769
|
function bt(e) {
|
|
770
770
|
for (let t of e.querySelectorAll("[data-latex]")) {
|
|
771
771
|
if (t.dataset.mathHandled || t.closest("mjx-container") || yt(t, e)) continue;
|
|
772
772
|
let n = t.textContent;
|
|
773
|
-
n && (t.textContent =
|
|
773
|
+
n && (t.textContent = at(n), t.dataset.mathHandled = "true");
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
776
|
function xt(e) {
|
|
@@ -778,7 +778,7 @@ function xt(e) {
|
|
|
778
778
|
}
|
|
779
779
|
function St(e, t) {
|
|
780
780
|
for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
|
|
781
|
-
return (t ?
|
|
781
|
+
return (t ? tt : et).test(e.textContent ?? "");
|
|
782
782
|
}
|
|
783
783
|
function Ct(e) {
|
|
784
784
|
return new Promise((o, c) => {
|
|
@@ -795,10 +795,10 @@ function Ct(e) {
|
|
|
795
795
|
typeset: !1,
|
|
796
796
|
ready: () => {
|
|
797
797
|
let e = s(), n = e?.startup, r = wt(e);
|
|
798
|
-
r && (Tt(e), Et(e, m.speechLocales), t(e?._?.a11y?.sre_ts?.locales, m.speechLocales)), n?.defaultReady?.(), r && (Dt(n?.document), Ot(n?.document), n?.document?.addStyles?.(
|
|
798
|
+
r && (Tt(e), Et(e, m.speechLocales), t(e?._?.a11y?.sre_ts?.locales, m.speechLocales)), n?.defaultReady?.(), r && (Dt(n?.document), Ot(n?.document), n?.document?.addStyles?.(ht), a(n?.document)), Promise.resolve(n?.promise).then(() => o(), c);
|
|
799
799
|
}
|
|
800
800
|
},
|
|
801
|
-
tex: { macros: {
|
|
801
|
+
tex: { macros: { ...$e } },
|
|
802
802
|
output: { displayOverflow: "linebreak" },
|
|
803
803
|
options: {
|
|
804
804
|
enableMenu: d,
|
|
@@ -810,7 +810,7 @@ function Ct(e) {
|
|
|
810
810
|
a11y: { inTabOrder: h }
|
|
811
811
|
}
|
|
812
812
|
};
|
|
813
|
-
u && g.tex && (console.warn(
|
|
813
|
+
u && g.tex && (console.warn(dt), g.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], g.tex.processEscapes = !0), f || (g.chtml = { fontURL: "" });
|
|
814
814
|
let _ = i(m.speechLocales);
|
|
815
815
|
_ && g.options && (g.options.sre = { locale: _ }), l(g, {
|
|
816
816
|
...m,
|
|
@@ -827,7 +827,7 @@ function Tt(e) {
|
|
|
827
827
|
let t = e?._?.output, n = t?.chtml_ts?.CHTML;
|
|
828
828
|
n && (n.STYLESHEETID = m);
|
|
829
829
|
let r = t?.svg_ts?.SVG;
|
|
830
|
-
r && (r.STYLESHEETID =
|
|
830
|
+
r && (r.STYLESHEETID = mt);
|
|
831
831
|
}
|
|
832
832
|
function Et(e, t) {
|
|
833
833
|
let n = e?._?.ui?.menu?.Menu?.Menu;
|
|
@@ -848,7 +848,7 @@ function Dt(e) {
|
|
|
848
848
|
let n = e.typesetRoot;
|
|
849
849
|
!n || t.has(n) || (Y(n), t.add(n));
|
|
850
850
|
};
|
|
851
|
-
e.addRenderAction?.("pie-strip-latex",
|
|
851
|
+
e.addRenderAction?.("pie-strip-latex", _t, (e) => {
|
|
852
852
|
for (let t of e.math ?? []) n(t);
|
|
853
853
|
return !1;
|
|
854
854
|
}, (e) => {
|
|
@@ -856,13 +856,13 @@ function Dt(e) {
|
|
|
856
856
|
return t && Y(t), !1;
|
|
857
857
|
});
|
|
858
858
|
let r = e.outputJax?.chtmlStyles;
|
|
859
|
-
r?.id ===
|
|
859
|
+
r?.id === pt && (r.id = m), At();
|
|
860
860
|
}
|
|
861
861
|
function Ot(e) {
|
|
862
862
|
let t = (e) => {
|
|
863
863
|
e.typesetRoot && Qe(e.typesetRoot);
|
|
864
864
|
};
|
|
865
|
-
e?.addRenderAction?.("pie-name-math",
|
|
865
|
+
e?.addRenderAction?.("pie-name-math", vt, (e) => {
|
|
866
866
|
for (let n of e.math ?? []) t(n);
|
|
867
867
|
return !1;
|
|
868
868
|
}, (e) => (t(e), !1));
|
|
@@ -871,7 +871,7 @@ function X(e) {
|
|
|
871
871
|
return e instanceof HTMLStyleElement && h.includes(e.id);
|
|
872
872
|
}
|
|
873
873
|
function kt(e) {
|
|
874
|
-
|
|
874
|
+
ut("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
|
|
875
875
|
}
|
|
876
876
|
function At() {
|
|
877
877
|
let e = document.head, t = [...e.children].find(X);
|
|
@@ -893,7 +893,7 @@ function At() {
|
|
|
893
893
|
function jt(e) {
|
|
894
894
|
let t = e?.math;
|
|
895
895
|
if (!t?.remove) return;
|
|
896
|
-
let n = [...t].filter((e) => (e.state?.() ?? 0) >=
|
|
896
|
+
let n = [...t].filter((e) => (e.state?.() ?? 0) >= gt && e.typesetRoot?.isConnected === !1);
|
|
897
897
|
if (n.length !== 0) {
|
|
898
898
|
for (let e of [...n].reverse()) e.clear?.();
|
|
899
899
|
t.remove(...n);
|
|
@@ -921,8 +921,8 @@ function Pt(e) {
|
|
|
921
921
|
});
|
|
922
922
|
}
|
|
923
923
|
function Ft(e) {
|
|
924
|
-
let t = u, n = t[
|
|
925
|
-
return n || (n = Pt(e), t[
|
|
924
|
+
let t = u, n = t[ft];
|
|
925
|
+
return n || (n = Pt(e), t[ft] = n), n;
|
|
926
926
|
}
|
|
927
927
|
function It(e = {}) {
|
|
928
928
|
let t = e.useSingleDollar ?? !1;
|
|
@@ -999,7 +999,7 @@ var $ = async (e) => {
|
|
|
999
999
|
let n = Z()?.wrapMath?.(e, t);
|
|
1000
1000
|
if (n != null) return n;
|
|
1001
1001
|
let [r, i] = t === "dollar" || t === "double_dollar" ? ["$", "$"] : ["\\(", "\\)"];
|
|
1002
|
-
return `${r}${
|
|
1002
|
+
return `${r}${it(e)}${i}`;
|
|
1003
1003
|
}, Yt = (e) => {
|
|
1004
1004
|
let t = e.trim();
|
|
1005
1005
|
return t.startsWith("\\[") && t.endsWith("\\]") ? {
|
|
@@ -1029,4 +1029,4 @@ var $ = async (e) => {
|
|
|
1029
1029
|
} : { unwrapped: t };
|
|
1030
1030
|
}, Xt = (e) => Z()?.mmlToLatex?.(e) ?? e;
|
|
1031
1031
|
//#endregion
|
|
1032
|
-
export {
|
|
1032
|
+
export { ct as MATHJAX_CONFLICT_EVENT, e as NO_ASSET_ROOT_EVENT, q as UNSUPPORTED_PAGE_DOCS_URL, It as createMathjaxRenderer, Lt as getMathjaxCssUrls, Xt as mmlToLatex, $ as renderMath, Xe as speakMathml, Yt as unWrapMath, Jt as wrapMath };
|
|
@@ -36928,7 +36928,7 @@ new qu("unicode", {
|
|
|
36928
36928
|
e.i++, e.Push(e.create("token", "mtext", { mathvariant: B.Variant.MONOSPACE }, i));
|
|
36929
36929
|
} }.Verb }), $u.create("verb", { [V.HANDLER]: { [H.MACRO]: ["verb"] } });
|
|
36930
36930
|
//#endregion
|
|
36931
|
-
//#region src/
|
|
36931
|
+
//#region src/tex-packages.ts
|
|
36932
36932
|
var F_ = [
|
|
36933
36933
|
"base",
|
|
36934
36934
|
"ams",
|
|
@@ -37083,4 +37083,4 @@ function Y_(e, t, n) {
|
|
|
37083
37083
|
}, Sm;
|
|
37084
37084
|
}
|
|
37085
37085
|
//#endregion
|
|
37086
|
-
export {
|
|
37086
|
+
export { Y_ as createMathJax };
|