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