@pie-element/shared-math-rendering-mathjax 0.1.1-next.0 → 0.1.1-next.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/dist/index.js +39 -35
- package/package.json +2 -7
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
//#region src/adapter.ts
|
|
2
|
-
var e = "
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var e = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
|
|
3
|
+
function t(t) {
|
|
4
|
+
if (typeof window > "u" || window.MathJax?.typesetPromise) return Promise.resolve();
|
|
5
|
+
let n = globalThis, r = n[e];
|
|
6
|
+
if (r) return r;
|
|
7
|
+
let i = new Promise((e, n) => {
|
|
8
|
+
let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = t, s = {
|
|
9
|
+
loader: { load: i ? ["a11y/assistive-mml"] : [] },
|
|
7
10
|
tex: {
|
|
8
11
|
packages: [
|
|
9
12
|
"base",
|
|
@@ -18,27 +21,28 @@ function n(n) {
|
|
|
18
21
|
}
|
|
19
22
|
},
|
|
20
23
|
options: {
|
|
21
|
-
enableMenu:
|
|
22
|
-
enableExplorer:
|
|
23
|
-
enableAssistiveMml:
|
|
24
|
+
enableMenu: i,
|
|
25
|
+
enableExplorer: i,
|
|
26
|
+
enableAssistiveMml: i
|
|
24
27
|
},
|
|
25
28
|
startup: {
|
|
26
29
|
ready: () => {
|
|
27
|
-
window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(),
|
|
30
|
+
window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), e());
|
|
28
31
|
},
|
|
29
32
|
defaultReady: () => {}
|
|
30
33
|
}
|
|
31
34
|
};
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
setTimeout(
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
}, document.head.appendChild(
|
|
39
|
-
})
|
|
35
|
+
r && s.tex && (s.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], s.tex.processEscapes = !0), a || (s.chtml = { fontURL: "" }), window.MathJax = s;
|
|
36
|
+
let c = document.createElement("script");
|
|
37
|
+
c.src = o || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", c.async = !0, c.onload = () => {
|
|
38
|
+
setTimeout(e, 100);
|
|
39
|
+
}, c.onerror = () => {
|
|
40
|
+
n(/* @__PURE__ */ Error("Failed to load MathJax"));
|
|
41
|
+
}, document.head.appendChild(c);
|
|
42
|
+
});
|
|
43
|
+
return n[e] = i, i;
|
|
40
44
|
}
|
|
41
|
-
function
|
|
45
|
+
function n() {
|
|
42
46
|
let e = window.MathJax?.startup?.document;
|
|
43
47
|
if (typeof e?.assistiveMml == "function") try {
|
|
44
48
|
e.assistiveMml().updateDocument?.();
|
|
@@ -46,39 +50,39 @@ function r() {
|
|
|
46
50
|
console.warn("[mathjax-renderer] Failed to attach assistive MathML:", e);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
|
-
function
|
|
50
|
-
return async (
|
|
51
|
-
if (await
|
|
53
|
+
function r(e = {}) {
|
|
54
|
+
return async (r) => {
|
|
55
|
+
if (await t(e), !window.MathJax?.typesetPromise) {
|
|
52
56
|
console.warn("[mathjax-renderer] MathJax not loaded or missing typesetPromise.");
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
await window.MathJax.typesetPromise([
|
|
59
|
+
await window.MathJax.typesetPromise([r]), n();
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
|
-
function
|
|
62
|
+
function i() {
|
|
59
63
|
return [];
|
|
60
64
|
}
|
|
61
65
|
//#endregion
|
|
62
66
|
//#region src/render-math.ts
|
|
63
|
-
var
|
|
64
|
-
function
|
|
65
|
-
return
|
|
67
|
+
var a = "@pie-lib/math-rendering", o = null;
|
|
68
|
+
function s() {
|
|
69
|
+
return o ||= r({
|
|
66
70
|
accessibility: !0,
|
|
67
71
|
useSingleDollar: !0
|
|
68
|
-
}),
|
|
72
|
+
}), o;
|
|
69
73
|
}
|
|
70
|
-
function
|
|
74
|
+
function c() {
|
|
71
75
|
if (typeof window > "u") return null;
|
|
72
|
-
let e = window[
|
|
76
|
+
let e = window[a];
|
|
73
77
|
return typeof e?.renderMath == "function" ? e : null;
|
|
74
78
|
}
|
|
75
|
-
var
|
|
79
|
+
var l = async (e) => {
|
|
76
80
|
if (typeof window > "u") return;
|
|
77
81
|
let t = typeof e == "string", n;
|
|
78
82
|
t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
|
|
79
|
-
let r =
|
|
80
|
-
return r ? await r.renderMath?.(n) : await
|
|
81
|
-
},
|
|
83
|
+
let r = c();
|
|
84
|
+
return r ? await r.renderMath?.(n) : await s()(n), t ? n.innerHTML : void 0;
|
|
85
|
+
}, u = (e) => c()?.wrapMath?.(e) ?? e, d = (e) => {
|
|
82
86
|
let t = e.trim();
|
|
83
87
|
return t.startsWith("\\[") && t.endsWith("\\]") ? {
|
|
84
88
|
unwrapped: t.slice(2, -2).trim(),
|
|
@@ -105,6 +109,6 @@ var u = async (e) => {
|
|
|
105
109
|
close: "$"
|
|
106
110
|
}
|
|
107
111
|
} : { unwrapped: t };
|
|
108
|
-
},
|
|
112
|
+
}, f = (e) => c()?.mmlToLatex?.(e) ?? e;
|
|
109
113
|
//#endregion
|
|
110
|
-
export {
|
|
114
|
+
export { r as createMathjaxRenderer, i as getMathjaxCssUrls, f as mmlToLatex, l as renderMath, d as unWrapMath, u as wrapMath };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/shared-math-rendering-mathjax",
|
|
3
|
-
"version": "0.1.1-next.
|
|
3
|
+
"version": "0.1.1-next.2",
|
|
4
4
|
"description": "MathJax adapter for PIE math rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,11 +21,6 @@
|
|
|
21
21
|
"clean": "rm -rf dist"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"typescript": "^5.9.3",
|
|
26
|
-
"vite": "^8.0.1",
|
|
27
|
-
"vitest": "^4.1.0"
|
|
28
|
-
},
|
|
29
24
|
"publishConfig": {
|
|
30
25
|
"access": "public"
|
|
31
26
|
},
|
|
@@ -39,7 +34,7 @@
|
|
|
39
34
|
"license": "MIT",
|
|
40
35
|
"repository": {
|
|
41
36
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/pie-framework/pie-elements-ng.git",
|
|
37
|
+
"url": "git+https://github.com/pie-framework/pie-elements-ng.git",
|
|
43
38
|
"directory": "packages/shared/math-rendering-mathjax"
|
|
44
39
|
},
|
|
45
40
|
"homepage": "https://github.com/pie-framework/pie-elements-ng#readme",
|