@wenyan-md/core 1.0.5 → 1.0.7

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/core.js CHANGED
@@ -1,142 +1,149 @@
1
- import { marked as g } from "marked";
2
- import { markedHighlight as L } from "marked-highlight";
3
- import w from "highlight.js";
4
- import T from "front-matter";
1
+ import { marked as m } from "marked";
2
+ import { markedHighlight as H } from "marked-highlight";
3
+ import x from "highlight.js";
4
+ import P from "front-matter";
5
5
  import * as f from "css-tree";
6
- import { mathjax as P } from "mathjax-full/js/mathjax.js";
7
- import { TeX as H } from "mathjax-full/js/input/tex.js";
8
- import { SVG as V } from "mathjax-full/js/output/svg.js";
9
- import { liteAdaptor as j } from "mathjax-full/js/adaptors/liteAdaptor.js";
10
- import { RegisterHTMLHandler as q } from "mathjax-full/js/handlers/html.js";
11
- import { AllPackages as E } from "mathjax-full/js/input/tex/AllPackages.js";
12
- import { themes as v } from "./theme.js";
13
- import { getAllThemes as ue, otherThemes as he } from "./theme.js";
6
+ import { mathjax as V } from "mathjax-full/js/mathjax.js";
7
+ import { TeX as j } from "mathjax-full/js/input/tex.js";
8
+ import { SVG as q } from "mathjax-full/js/output/svg.js";
9
+ import { liteAdaptor as I } from "mathjax-full/js/adaptors/liteAdaptor.js";
10
+ import { RegisterHTMLHandler as S } from "mathjax-full/js/handlers/html.js";
11
+ import { AllPackages as R } from "mathjax-full/js/input/tex/AllPackages.js";
12
+ import { themes as b } from "./theme.js";
14
13
  import { hlThemes as C } from "./hltheme.js";
15
- import { getAllHlThemes as ge } from "./hltheme.js";
16
- const R = `#wenyan pre::before {
17
- display: block;
18
- content: "";
19
- background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="45" height="12" viewBox="0 0 450 130"><ellipse cx="65" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"/><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"/><ellipse cx="385" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"/></svg>');
20
- background-repeat: no-repeat;
21
- width: 100%;
22
- height: 16px;
23
- }`, ne = "ui-serif, Georgia, Cambria, 'Noto Serif', 'Times New Roman', serif", z = "ui-sans-serif, system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', 'Roboto', sans-serif", A = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace", I = {
14
+ const z = {
24
15
  inlineMath: [["$", "$"], ["\\(", "\\)"]],
25
16
  displayMath: [["$$", "$$"], ["\\[", "\\]"]],
26
17
  processEscapes: !0,
27
- packages: E
18
+ packages: R
28
19
  }, N = {
29
20
  fontCache: "none"
30
- }, b = j();
31
- q(b);
32
- const D = new H(I), F = new V(N);
33
- function $(o, s) {
34
- const n = o.display ? "section" : "span", e = o.display ? "block-equation" : "inline-equation";
35
- o.typesetRoot = s.adaptor.node(n, { class: e }, [o.typesetRoot]);
21
+ };
22
+ let g;
23
+ if (!g) {
24
+ g = I();
25
+ try {
26
+ S(g);
27
+ } catch {
28
+ }
36
29
  }
37
- async function G(o) {
30
+ S(g);
31
+ const D = new j(z), E = new q(N);
32
+ function A(r, n) {
33
+ const a = r.display ? "section" : "span", e = r.display ? "block-equation" : "inline-equation";
34
+ r.typesetRoot = n.adaptor.node(a, { class: e }, [r.typesetRoot]);
35
+ }
36
+ async function F(r) {
38
37
  try {
39
- const s = P.document(o, {
38
+ const n = V.document(r, {
40
39
  InputJax: D,
41
- OutputJax: F,
40
+ OutputJax: E,
42
41
  renderActions: {
43
42
  addContainer: [190, (e) => {
44
- for (const t of e.math)
45
- $(t, e);
46
- }, $]
43
+ for (const s of e.math)
44
+ A(s, e);
45
+ }, A]
47
46
  }
48
47
  });
49
- s.render();
50
- const n = b.body(s.document);
51
- return b.innerHTML(n);
52
- } catch (s) {
53
- throw console.error("Error rendering MathJax:", s), s;
48
+ n.render();
49
+ const a = g.body(n.document);
50
+ return g.innerHTML(a);
51
+ } catch (n) {
52
+ throw console.error("Error rendering MathJax:", n), n;
54
53
  }
55
54
  }
56
- function ae() {
57
- g.use(
58
- L({
55
+ const G = `#wenyan pre::before {
56
+ display: block;
57
+ content: "";
58
+ background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="45" height="12" viewBox="0 0 450 130"><ellipse cx="65" cy="65" rx="50" ry="52" stroke="rgb(220,60,54)" stroke-width="2" fill="rgb(237,108,96)"/><ellipse cx="225" cy="65" rx="50" ry="52" stroke="rgb(218,151,33)" stroke-width="2" fill="rgb(247,193,81)"/><ellipse cx="385" cy="65" rx="50" ry="52" stroke="rgb(27,161,37)" stroke-width="2" fill="rgb(100,200,86)"/></svg>');
59
+ background-repeat: no-repeat;
60
+ width: 100%;
61
+ height: 16px;
62
+ }`, ie = "ui-serif, Georgia, Cambria, 'Noto Serif', 'Times New Roman', serif", B = "ui-sans-serif, system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', 'Roboto', sans-serif", L = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace";
63
+ function le() {
64
+ m.use(
65
+ H({
59
66
  langPrefix: "hljs language-",
60
- highlight: function(e, t) {
61
- return t = w.getLanguage(t) ? t : "plaintext", w.highlight(e, { language: t }).value;
67
+ highlight: function(e, s) {
68
+ return s = x.getLanguage(s) ? s : "plaintext", x.highlight(e, { language: s }).value;
62
69
  }
63
70
  })
64
71
  );
65
- const o = {
72
+ const r = {
66
73
  name: "attributeImage",
67
74
  level: "inline",
68
75
  start(e) {
69
76
  return e.indexOf("![");
70
77
  },
71
78
  tokenizer(e) {
72
- const i = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(e);
73
- if (i)
79
+ const o = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(e);
80
+ if (o)
74
81
  return {
75
82
  type: "attributeImage",
76
- raw: i[0],
77
- alt: i[1],
78
- href: i[2],
79
- attrs: i[3]
83
+ raw: o[0],
84
+ alt: o[1],
85
+ href: o[2],
86
+ attrs: o[3]
80
87
  };
81
88
  },
82
89
  renderer(e) {
83
- const t = B(e.attrs), i = Array.from(t).map(
84
- ([l, r]) => /^\d+$/.test(r) ? `${l}:${r}px` : `${l}:${r}`
90
+ const s = J(e.attrs), o = Array.from(s).map(
91
+ ([l, t]) => /^\d+$/.test(t) ? `${l}:${t}px` : `${l}:${t}`
85
92
  ).join("; ");
86
- return `<img src="${e.href}" alt="${e.alt}" style="${i}">`;
93
+ return `<img src="${e.href}" alt="${e.alt}" style="${o}">`;
87
94
  }
88
95
  };
89
- g.use({ extensions: [o] });
90
- const s = g.Renderer, n = g.Parser;
91
- s.heading = function(e) {
92
- const t = n.parseInline(e.tokens), i = e.depth;
93
- return `<h${i}><span>${t}</span></h${i}>
96
+ m.use({ extensions: [r] });
97
+ const n = m.Renderer, a = m.Parser;
98
+ n.heading = function(e) {
99
+ const s = a.parseInline(e.tokens), o = e.depth;
100
+ return `<h${o}><span>${s}</span></h${o}>
94
101
  `;
95
- }, s.paragraph = function(e) {
96
- const t = e.text;
97
- return t.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(t) || /\\\[[\s\S]*?\\\]/g.test(t)) ? `${t}
98
- ` : `<p>${n.parseInline(e.tokens)}</p>
102
+ }, n.paragraph = function(e) {
103
+ const s = e.text;
104
+ return s.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(s) || /\\\[[\s\S]*?\\\]/g.test(s)) ? `${s}
105
+ ` : `<p>${a.parseInline(e.tokens)}</p>
99
106
  `;
100
- }, s.image = function(e, t, i) {
101
- return `<img src="${e.href}" alt="${i || ""}" title="${t || i || ""}">`;
102
- }, g.use({ renderer: s });
107
+ }, n.image = function(e, s, o) {
108
+ return `<img src="${e.href}" alt="${o || ""}" title="${s || o || ""}">`;
109
+ }, m.use({ renderer: n });
103
110
  }
104
- function B(o) {
105
- const s = /* @__PURE__ */ new Map();
106
- return o.split(/\s+/).forEach((n) => {
107
- const [e, t] = n.split("=");
108
- e && t && s.set(e, t.replace(/^["']|["']$/g, ""));
109
- }), s;
111
+ function J(r) {
112
+ const n = /* @__PURE__ */ new Map();
113
+ return r.split(/\s+/).forEach((a) => {
114
+ const [e, s] = a.split("=");
115
+ e && s && n.set(e, s.replace(/^["']|["']$/g, ""));
116
+ }), n;
110
117
  }
111
- function ie(o) {
112
- const { attributes: s, body: n } = T(o), e = {};
113
- let t = "";
114
- const { title: i, description: l, cover: r } = s;
115
- return i && (e.title = i), l && (t += "> " + l + `
118
+ function ce(r) {
119
+ const { attributes: n, body: a } = P(r), e = {};
120
+ let s = "";
121
+ const { title: o, description: l, cover: t } = n;
122
+ return o && (e.title = o), l && (s += "> " + l + `
116
123
 
117
- `, e.description = l), r && (e.cover = r), e.body = t + n, e;
124
+ `, e.description = l), t && (e.cover = t), e.body = s + a, e;
118
125
  }
119
- async function le(o) {
120
- const s = g.parse(o);
121
- return await G(s);
126
+ async function pe(r) {
127
+ const n = m.parse(r);
128
+ return await F(n);
122
129
  }
123
- async function ce(o, s, n, e) {
124
- let t = v.default;
125
- if (s && (t = v[s], t || (t = Object.values(v).find(
126
- (a) => a.name.toLowerCase() === s.toLowerCase()
127
- ))), !t)
130
+ async function fe(r, n, a, e, s) {
131
+ let o = b.default;
132
+ if (n && (o = b[n], o || (o = Object.values(b).find(
133
+ (c) => c.name.toLowerCase() === n.toLowerCase()
134
+ ))), !o)
128
135
  throw new Error("主题不存在");
129
- if (!(n in C))
136
+ if (!(a in C))
130
137
  throw new Error("代码块主题不存在");
131
- const i = O(await t.getCss()), r = await C[n].getCss();
132
- return J(o, i, r, e);
138
+ const l = U(await o.getCss()), i = await C[a].getCss();
139
+ return O(r, l, i, e, s);
133
140
  }
134
- async function J(o, s, n, e) {
135
- s = U(s, {
141
+ async function O(r, n, a, e, s) {
142
+ s && Y(!1, r), n = W(n, {
136
143
  "#wenyan pre code": [
137
144
  {
138
145
  property: "font-family",
139
- value: A,
146
+ value: L,
140
147
  append: !0
141
148
  }
142
149
  ],
@@ -148,179 +155,190 @@ async function J(o, s, n, e) {
148
155
  }
149
156
  ]
150
157
  });
151
- const t = f.parse(s, {
158
+ const o = f.parse(n, {
152
159
  context: "stylesheet",
153
160
  positions: !1,
154
161
  parseAtrulePrelude: !1,
155
162
  parseCustomProperty: !1,
156
163
  parseValue: !1
157
- }), i = f.parse(n, {
164
+ }), l = f.parse(a, {
158
165
  context: "stylesheet",
159
166
  positions: !1,
160
167
  parseAtrulePrelude: !1,
161
168
  parseCustomProperty: !1,
162
169
  parseValue: !1
163
170
  });
164
- if (t.children.appendList(i.children), e) {
165
- const r = f.parse(R, {
171
+ if (o.children.appendList(l.children), e) {
172
+ const i = f.parse(G, {
166
173
  context: "stylesheet",
167
174
  positions: !1,
168
175
  parseAtrulePrelude: !1,
169
176
  parseCustomProperty: !1,
170
177
  parseValue: !1
171
178
  });
172
- t.children.appendList(r.children);
179
+ o.children.appendList(i.children);
173
180
  }
174
- f.walk(t, {
181
+ f.walk(o, {
175
182
  visit: "Rule",
176
- enter(r, a, p) {
177
- const c = r.prelude.children;
178
- c && c.forEach((h) => {
179
- const u = f.generate(h), m = r.block.children.toArray();
180
- u === "#wenyan" ? m.forEach((d) => {
181
- const y = f.generate(d.value);
182
- o.style[d.property] = y;
183
- }) : o.querySelectorAll(u).forEach((y) => {
184
- m.forEach((x) => {
185
- const S = f.generate(x.value);
186
- y.style[x.property] = S;
183
+ enter(i, c, p) {
184
+ const u = i.prelude.children;
185
+ u && u.forEach((d) => {
186
+ const h = f.generate(d), $ = i.block.children.toArray();
187
+ h === "#wenyan" ? $.forEach((y) => {
188
+ const v = f.generate(y.value);
189
+ r.style[y.property] = v;
190
+ }) : r.querySelectorAll(h).forEach((v) => {
191
+ $.forEach((w) => {
192
+ const T = f.generate(w.value);
193
+ v.style[w.property] = T;
187
194
  });
188
195
  });
189
196
  });
190
197
  }
191
198
  });
192
- let l = o.querySelectorAll("mjx-container");
193
- return l.forEach((r) => {
194
- const a = r.querySelector("svg");
195
- a.style.width = a.getAttribute("width"), a.style.height = a.getAttribute("height"), a.removeAttribute("width"), a.removeAttribute("height");
196
- const p = r.parentElement;
197
- r.remove(), p.appendChild(a), p.classList.contains("block-equation") && p.setAttribute("style", "text-align: center; margin-bottom: 1rem;");
198
- }), l = o.querySelectorAll("pre code"), l.forEach((r) => {
199
- r.innerHTML = r.innerHTML.replace(/\n/g, "<br>").replace(/(>[^<]+)|(^[^<]+)/g, (a) => a.replace(/\s/g, "&nbsp;"));
200
- }), l = o.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre"), l.forEach((r) => {
201
- const a = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
202
- f.walk(t, {
199
+ let t = r.querySelectorAll("mjx-container");
200
+ return t.forEach((i) => {
201
+ const c = i.querySelector("svg");
202
+ c.style.width = c.getAttribute("width"), c.style.height = c.getAttribute("height"), c.removeAttribute("width"), c.removeAttribute("height");
203
+ const p = i.parentElement;
204
+ i.remove(), p.appendChild(c), p.classList.contains("block-equation") && p.setAttribute("style", "text-align: center; margin-bottom: 1rem;");
205
+ }), t = r.querySelectorAll("pre code"), t.forEach((i) => {
206
+ i.innerHTML = i.innerHTML.replace(/\n/g, "<br>").replace(/(>[^<]+)|(^[^<]+)/g, (c) => c.replace(/\s/g, "&nbsp;"));
207
+ }), t = r.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre"), t.forEach((i) => {
208
+ const c = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
209
+ f.walk(o, {
203
210
  visit: "Rule",
204
- enter(c) {
205
- const h = f.generate(c.prelude), u = r.tagName.toLowerCase();
206
- h.includes(`${u}::after`) ? k(c, a) : h.includes(`${u}::before`) && k(c, p);
211
+ enter(u) {
212
+ const d = f.generate(u.prelude), h = i.tagName.toLowerCase();
213
+ d.includes(`${h}::after`) ? M(u, c) : d.includes(`${h}::before`) && M(u, p);
207
214
  }
208
- }), a.size > 0 && r.appendChild(M(a, o.ownerDocument)), p.size > 0 && r.insertBefore(M(p, o.ownerDocument), r.firstChild);
209
- }), o.setAttribute("data-provider", "WenYan"), `${o.outerHTML.replace(/class="mjx-solid"/g, 'fill="none" stroke-width="70"')}`;
215
+ }), c.size > 0 && i.appendChild(k(c, r.ownerDocument)), p.size > 0 && i.insertBefore(k(p, r.ownerDocument), i.firstChild);
216
+ }), r.setAttribute("data-provider", "WenYan"), `${r.outerHTML.replace(/class="mjx-solid"/g, 'fill="none" stroke-width="70"')}`;
210
217
  }
211
- function O(o) {
212
- const s = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, n = /var\(--([a-zA-Z0-9\-]+)\)/g, e = {};
213
- let t;
214
- for (; (t = s.exec(o)) !== null; ) {
215
- const r = t[1], a = t[2].trim().replaceAll(`
218
+ function U(r) {
219
+ const n = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, a = /var\(--([a-zA-Z0-9\-]+)\)/g, e = {};
220
+ let s;
221
+ for (; (s = n.exec(r)) !== null; ) {
222
+ const t = s[1], i = s[2].trim().replaceAll(`
216
223
  `, "");
217
- e[r] = a;
224
+ e[t] = i;
218
225
  }
219
- e["sans-serif-font"] || (e["sans-serif-font"] = z), e["monospace-font"] || (e["monospace-font"] = A);
220
- function i(r, a, p = /* @__PURE__ */ new Set()) {
221
- if (p.has(r)) return r;
222
- p.add(r);
223
- let c = r, h;
224
- for (; (h = n.exec(c)) !== null; ) {
225
- const u = h[1];
226
- if (a[u]) {
227
- const m = i(a[u], a, p);
228
- c = c.replace(h[0], m);
226
+ e["sans-serif-font"] || (e["sans-serif-font"] = B), e["monospace-font"] || (e["monospace-font"] = L);
227
+ function o(t, i, c = /* @__PURE__ */ new Set()) {
228
+ if (c.has(t)) return t;
229
+ c.add(t);
230
+ let p = t, u;
231
+ for (; (u = a.exec(p)) !== null; ) {
232
+ const d = u[1];
233
+ if (i[d]) {
234
+ const h = o(i[d], i, c);
235
+ p = p.replace(u[0], h);
229
236
  }
230
237
  }
231
- return c;
238
+ return p;
232
239
  }
233
- for (const r in e) {
234
- const a = i(e[r], e);
235
- e[r] = a;
240
+ for (const t in e) {
241
+ const i = o(e[t], e);
242
+ e[t] = i;
236
243
  }
237
- let l = o;
238
- for (; (t = n.exec(o)) !== null; ) {
239
- const r = t[1];
240
- e[r] && (l = l.replace(t[0], e[r]));
244
+ let l = r;
245
+ for (; (s = a.exec(r)) !== null; ) {
246
+ const t = s[1];
247
+ e[t] && (l = l.replace(s[0], e[t]));
241
248
  }
242
249
  return l.replace(/:root\s*\{[^}]*\}/g, "");
243
250
  }
244
- function U(o, s) {
245
- const n = f.parse(o, {
251
+ function W(r, n) {
252
+ const a = f.parse(r, {
246
253
  context: "stylesheet",
247
254
  positions: !1,
248
255
  parseAtrulePrelude: !1,
249
256
  parseCustomProperty: !1,
250
257
  parseValue: !1
251
258
  });
252
- return f.walk(n, {
259
+ return f.walk(a, {
253
260
  visit: "Rule",
254
- leave: (e, t, i) => {
261
+ leave: (e, s, o) => {
255
262
  if (e.prelude.type !== "SelectorList") return;
256
- const l = e.prelude.children.toArray().map((r) => f.generate(r));
263
+ const l = e.prelude.children.toArray().map((t) => f.generate(t));
257
264
  if (l) {
258
- const r = l[0], a = s[r];
259
- if (!a) return;
260
- for (const { property: p, value: c, append: h } of a)
261
- if (c) {
262
- let u = !1;
263
- f.walk(e.block, (m) => {
264
- m.type === "Declaration" && m.property === p && (m.value = f.parse(c, { context: "value" }), u = !0);
265
- }), !u && h && e.block.children.prepend(
266
- i.createItem({
265
+ const t = l[0], i = n[t];
266
+ if (!i) return;
267
+ for (const { property: c, value: p, append: u } of i)
268
+ if (p) {
269
+ let d = !1;
270
+ f.walk(e.block, (h) => {
271
+ h.type === "Declaration" && h.property === c && (h.value = f.parse(p, { context: "value" }), d = !0);
272
+ }), !d && u && e.block.children.prepend(
273
+ o.createItem({
267
274
  type: "Declaration",
268
- property: p,
269
- value: f.parse(c, { context: "value" })
275
+ property: c,
276
+ value: f.parse(p, { context: "value" })
270
277
  })
271
278
  );
272
279
  }
273
280
  }
274
281
  }
275
- }), f.generate(n);
282
+ }), f.generate(a);
276
283
  }
277
- function k(o, s) {
278
- f.walk(o.block, {
284
+ function M(r, n) {
285
+ f.walk(r.block, {
279
286
  visit: "Declaration",
280
- enter(n) {
281
- const e = n.property, t = f.generate(n.value);
282
- s.set(e, t);
287
+ enter(a) {
288
+ const e = a.property, s = f.generate(a.value);
289
+ n.set(e, s);
283
290
  }
284
291
  });
285
292
  }
286
- function M(o, s) {
287
- const n = s.createElement("section");
288
- o.get("content") && (n.textContent = o.get("content").replace(/['"]/g, ""), o.delete("content"));
289
- for (const [i, l] of o)
293
+ function k(r, n) {
294
+ const a = n.createElement("section");
295
+ r.get("content") && (a.textContent = r.get("content").replace(/['"]/g, ""), r.delete("content"));
296
+ for (const [o, l] of r)
290
297
  if (l.includes("url(")) {
291
- const r = l.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/), a = l.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/), p = l.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
292
- if (r) {
293
- const c = decodeURIComponent(r[1]);
294
- n.innerHTML = c;
295
- } else if (a) {
296
- const c = atob(a[1]);
297
- n.innerHTML = c;
298
- } else if (p) {
299
- const c = s.createElement("img");
300
- c.src = p[1], c.setAttribute("style", "vertical-align: top;"), n.appendChild(c);
298
+ const t = l.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/), i = l.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/), c = l.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
299
+ if (t) {
300
+ const p = decodeURIComponent(t[1]);
301
+ a.innerHTML = p;
302
+ } else if (i) {
303
+ const p = atob(i[1]);
304
+ a.innerHTML = p;
305
+ } else if (c) {
306
+ const p = n.createElement("img");
307
+ p.src = c[1], p.setAttribute("style", "vertical-align: top;"), a.appendChild(p);
301
308
  }
302
- o.delete(i);
309
+ r.delete(o);
310
+ }
311
+ const s = Array.from(r.entries()).map(([o, l]) => `${o}: ${l}`).join("; ");
312
+ return a.style.cssText = s, a;
313
+ }
314
+ function Y(r, n) {
315
+ let a = [], e = 0;
316
+ if (n.querySelectorAll("a[href]").forEach((o) => {
317
+ const l = o.textContent || o.innerText, t = o.getAttribute("href");
318
+ a.push([++e, l, t]);
319
+ const i = n.ownerDocument.createElement("sup");
320
+ i.setAttribute("class", "footnote"), i.innerHTML = `[${e}]`, o.after(i);
321
+ }), e > 0)
322
+ if (r) {
323
+ const l = `<h3>引用链接</h3><div id="footnotes"><ul>${a.map((t) => t[1] === t[2] ? `<li id="#footnote-${t[0]}">[${t[0]}]: <i>${t[1]}</i></li>` : `<li id="#footnote-${t[0]}">[${t[0]}] ${t[1]}: <i>${t[2]}</i></li>`).join("")}</ul></div>`;
324
+ n.innerHTML += l;
325
+ } else {
326
+ const l = `<h3>引用链接</h3><section id="footnotes">${a.map((t) => t[1] === t[2] ? `<p><span class="footnote-num">[${t[0]}]</span><span class="footnote-txt"><i>${t[1]}</i></span></p>` : `<p><span class="footnote-num">[${t[0]}]</span><span class="footnote-txt">${t[1]}: <i>${t[2]}</i></span></p>`).join("")}</section>`;
327
+ n.innerHTML += l;
303
328
  }
304
- const t = Array.from(o.entries()).map(([i, l]) => `${i}: ${l}`).join("; ");
305
- return n.style.cssText = t, n;
306
329
  }
307
330
  export {
308
- M as buildPseudoSpan,
309
- ae as configureMarked,
310
- k as extractDeclarations,
311
- ge as getAllHlThemes,
312
- ue as getAllThemes,
313
- ce as getContentForGzhBuiltinTheme,
314
- J as getContentForGzhCustomCss,
315
- ie as handleFrontMatter,
316
- C as hlThemes,
317
- R as macStyleCss,
318
- U as modifyCss,
319
- A as monospace,
320
- he as otherThemes,
321
- le as renderMarkdown,
322
- O as replaceCSSVariables,
323
- z as sansSerif,
324
- ne as serif,
325
- v as themes
331
+ Y as addFootnotes,
332
+ k as buildPseudoSpan,
333
+ le as configureMarked,
334
+ M as extractDeclarations,
335
+ fe as getContentForGzhBuiltinTheme,
336
+ O as getContentForGzhCustomCss,
337
+ ce as handleFrontMatter,
338
+ W as modifyCss,
339
+ L as monospace,
340
+ pe as renderMarkdown,
341
+ U as replaceCSSVariables,
342
+ B as sansSerif,
343
+ ie as serif
326
344
  };