返回 reveal.js
math.mjs
根目录 / dist / plugin / math.mjs
1 //#region plugin/math/katex.js
2 var e = () => {
3 let e, t = {
4 version: "latest",
5 delimiters: [
6 {
7 left: "$$",
8 right: "$$",
9 display: !0
10 },
11 {
12 left: "$",
13 right: "$",
14 display: !1
15 },
16 {
17 left: "\\(",
18 right: "\\)",
19 display: !1
20 },
21 {
22 left: "\\[",
23 right: "\\]",
24 display: !0
25 }
26 ],
27 ignoredTags: [
28 "script",
29 "noscript",
30 "style",
31 "textarea",
32 "pre",
33 "code"
34 ]
35 }, n = (e) => {
36 let t = document.createElement("link");
37 t.rel = "stylesheet", t.href = e, document.head.appendChild(t);
38 }, r = (e) => new Promise((t, n) => {
39 let r = document.createElement("script");
40 r.type = "text/javascript", r.onload = t, r.onerror = n, r.src = e, document.head.append(r);
41 });
42 async function i(e) {
43 for (let t of e) await r(t);
44 }
45 return {
46 id: "katex",
47 init: function(r) {
48 e = r;
49 let a = e.getConfig().katex || {}, o = {
50 ...t,
51 ...a
52 }, { local: s, version: c, extensions: l, ...u } = o, d = o.local || "https://cdn.jsdelivr.net/npm/katex", f = o.local ? "" : "@" + o.version, p = d + f + "/dist/katex.min.css", m = d + f + "/dist/katex.min.js", h = d + f + "/dist/contrib/mhchem.min.js", g = d + f + "/dist/contrib/auto-render.min.js", _ = [m];
53 o.extensions && o.extensions.includes("mhchem") && _.push(h), _.push(g);
54 let v = () => {
55 renderMathInElement(r.getSlidesElement(), u), e.layout();
56 };
57 n(p), i(_).then(() => {
58 e.isReady() ? v() : e.on("ready", v.bind(this));
59 });
60 }
61 };
62 }, t = () => {
63 let e, t = {
64 messageStyle: "none",
65 tex2jax: {
66 inlineMath: [["$", "$"], ["\\(", "\\)"]],
67 skipTags: [
68 "script",
69 "noscript",
70 "style",
71 "textarea",
72 "pre",
73 "code"
74 ]
75 },
76 skipStartupTypeset: !0
77 };
78 function n(e, t) {
79 let n = document.querySelector("head"), r = document.createElement("script");
80 r.type = "text/javascript", r.src = e;
81 let i = () => {
82 typeof t == "function" && (t.call(), t = null);
83 };
84 r.onload = i, r.onreadystatechange = () => {
85 this.readyState === "loaded" && i();
86 }, n.appendChild(r);
87 }
88 return {
89 id: "mathjax2",
90 init: function(r) {
91 e = r;
92 let i = e.getConfig().mathjax2 || e.getConfig().math || {}, a = {
93 ...t,
94 ...i
95 }, o = a.mathjax || "https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js", s = a.config || "TeX-AMS_HTML-full", c = o + "?config=" + s;
96 a.tex2jax = {
97 ...t.tex2jax,
98 ...i.tex2jax
99 }, a.mathjax = a.config = null, n(c, function() {
100 MathJax.Hub.Config(a), MathJax.Hub.Queue([
101 "Typeset",
102 MathJax.Hub,
103 e.getRevealElement()
104 ]), MathJax.Hub.Queue(e.layout), e.on("slidechanged", function(e) {
105 MathJax.Hub.Queue([
106 "Typeset",
107 MathJax.Hub,
108 e.currentSlide
109 ]);
110 });
111 });
112 }
113 };
114 }, n = Plugin = Object.assign(t(), {
115 KaTeX: e,
116 MathJax2: t,
117 MathJax3: () => {
118 let e, t = {
119 tex: { inlineMath: [["$", "$"], ["\\(", "\\)"]] },
120 options: { skipHtmlTags: [
121 "script",
122 "noscript",
123 "style",
124 "textarea",
125 "pre",
126 "code"
127 ] },
128 startup: { ready: () => {
129 MathJax.startup.defaultReady(), MathJax.startup.promise.then(() => {
130 e.layout();
131 });
132 } }
133 };
134 function n(e, t) {
135 let n = document.createElement("script");
136 n.type = "text/javascript", n.id = "MathJax-script", n.src = e, n.async = !0, n.onload = () => {
137 typeof t == "function" && (t.call(), t = null);
138 }, document.head.appendChild(n);
139 }
140 return {
141 id: "mathjax3",
142 init: function(r) {
143 e = r;
144 let i = e.getConfig().mathjax3 || {}, a = {
145 ...t,
146 ...i
147 };
148 a.tex = {
149 ...t.tex,
150 ...i.tex
151 }, a.options = {
152 ...t.options,
153 ...i.options
154 }, a.startup = {
155 ...t.startup,
156 ...i.startup
157 };
158 let o = a.mathjax || "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js";
159 a.mathjax = null, window.MathJax = a, n(o, function() {
160 e.addEventListener("slidechanged", function(e) {
161 MathJax.typeset();
162 });
163 });
164 }
165 };
166 },
167 MathJax4: () => {
168 let e, t = {
169 tex: { inlineMath: [["$", "$"], ["\\(", "\\)"]] },
170 options: { skipHtmlTags: [
171 "script",
172 "noscript",
173 "style",
174 "textarea",
175 "pre",
176 "code"
177 ] },
178 startup: { ready: () => {
179 MathJax.startup.defaultReady(), MathJax.startup.promise.then(() => {
180 e.layout();
181 });
182 } }
183 };
184 function n(e, t) {
185 let n = document.createElement("script");
186 n.type = "text/javascript", n.id = "MathJax-script", n.src = e, n.async = !0, n.onload = () => {
187 typeof t == "function" && (t.call(), t = null);
188 }, document.head.appendChild(n);
189 }
190 return {
191 id: "mathjax4",
192 init: function(r) {
193 e = r;
194 let i = e.getConfig().mathjax4 || {}, a = {
195 ...t,
196 ...i
197 };
198 a.tex = {
199 ...t.tex,
200 ...i.tex
201 }, a.options = {
202 ...t.options,
203 ...i.options
204 }, a.startup = {
205 ...t.startup,
206 ...i.startup
207 };
208 let o = a.mathjax || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js";
209 a.mathjax = null, window.MathJax = a, n(o, function() {
210 MathJax.startup.promise.then(() => {
211 MathJax.typeset(), e.addEventListener("slidechanged", function(e) {
212 MathJax.typeset();
213 });
214 });
215 });
216 }
217 };
218 }
219 });
220 //#endregion
221 export { n as default };
222
222 lines Plain Text