@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/README.md +227 -1
- package/dist/browser/wenyan-core.js +94 -0
- package/dist/core.js +224 -206
- package/dist/math/wenyan-math.js +50 -0
- package/dist/styles/wenyan-styles.js +2244 -0
- package/package.json +15 -6
package/dist/core.js
CHANGED
|
@@ -1,142 +1,149 @@
|
|
|
1
|
-
import { marked as
|
|
2
|
-
import { markedHighlight as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
|
7
|
-
import { TeX as
|
|
8
|
-
import { SVG as
|
|
9
|
-
import { liteAdaptor as
|
|
10
|
-
import { RegisterHTMLHandler as
|
|
11
|
-
import { AllPackages as
|
|
12
|
-
import { themes as
|
|
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
|
-
|
|
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:
|
|
18
|
+
packages: R
|
|
28
19
|
}, N = {
|
|
29
20
|
fontCache: "none"
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
};
|
|
22
|
+
let g;
|
|
23
|
+
if (!g) {
|
|
24
|
+
g = I();
|
|
25
|
+
try {
|
|
26
|
+
S(g);
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
36
29
|
}
|
|
37
|
-
|
|
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
|
|
38
|
+
const n = V.document(r, {
|
|
40
39
|
InputJax: D,
|
|
41
|
-
OutputJax:
|
|
40
|
+
OutputJax: E,
|
|
42
41
|
renderActions: {
|
|
43
42
|
addContainer: [190, (e) => {
|
|
44
|
-
for (const
|
|
45
|
-
|
|
46
|
-
},
|
|
43
|
+
for (const s of e.math)
|
|
44
|
+
A(s, e);
|
|
45
|
+
}, A]
|
|
47
46
|
}
|
|
48
47
|
});
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
} catch (
|
|
53
|
-
throw console.error("Error rendering MathJax:",
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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,
|
|
61
|
-
return
|
|
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
|
|
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
|
|
73
|
-
if (
|
|
79
|
+
const o = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(e);
|
|
80
|
+
if (o)
|
|
74
81
|
return {
|
|
75
82
|
type: "attributeImage",
|
|
76
|
-
raw:
|
|
77
|
-
alt:
|
|
78
|
-
href:
|
|
79
|
-
attrs:
|
|
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
|
|
84
|
-
([l,
|
|
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="${
|
|
93
|
+
return `<img src="${e.href}" alt="${e.alt}" style="${o}">`;
|
|
87
94
|
}
|
|
88
95
|
};
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
return `<h${
|
|
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
|
-
},
|
|
96
|
-
const
|
|
97
|
-
return
|
|
98
|
-
` : `<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
|
-
},
|
|
101
|
-
return `<img src="${e.href}" alt="${
|
|
102
|
-
},
|
|
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
|
|
105
|
-
const
|
|
106
|
-
return
|
|
107
|
-
const [e,
|
|
108
|
-
e &&
|
|
109
|
-
}),
|
|
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
|
|
112
|
-
const { attributes:
|
|
113
|
-
let
|
|
114
|
-
const { title:
|
|
115
|
-
return
|
|
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),
|
|
124
|
+
`, e.description = l), t && (e.cover = t), e.body = s + a, e;
|
|
118
125
|
}
|
|
119
|
-
async function
|
|
120
|
-
const
|
|
121
|
-
return await
|
|
126
|
+
async function pe(r) {
|
|
127
|
+
const n = m.parse(r);
|
|
128
|
+
return await F(n);
|
|
122
129
|
}
|
|
123
|
-
async function
|
|
124
|
-
let
|
|
125
|
-
if (
|
|
126
|
-
(
|
|
127
|
-
))), !
|
|
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 (!(
|
|
136
|
+
if (!(a in C))
|
|
130
137
|
throw new Error("代码块主题不存在");
|
|
131
|
-
const
|
|
132
|
-
return
|
|
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
|
|
135
|
-
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:
|
|
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
|
|
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
|
-
}),
|
|
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 (
|
|
165
|
-
const
|
|
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
|
-
|
|
179
|
+
o.children.appendList(i.children);
|
|
173
180
|
}
|
|
174
|
-
f.walk(
|
|
181
|
+
f.walk(o, {
|
|
175
182
|
visit: "Rule",
|
|
176
|
-
enter(
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
}) :
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
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
|
|
193
|
-
return
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
const p =
|
|
197
|
-
|
|
198
|
-
}),
|
|
199
|
-
|
|
200
|
-
}),
|
|
201
|
-
const
|
|
202
|
-
f.walk(
|
|
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, " "));
|
|
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(
|
|
205
|
-
const
|
|
206
|
-
|
|
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
|
-
}),
|
|
209
|
-
}),
|
|
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
|
|
212
|
-
const
|
|
213
|
-
let
|
|
214
|
-
for (; (
|
|
215
|
-
const
|
|
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[
|
|
224
|
+
e[t] = i;
|
|
218
225
|
}
|
|
219
|
-
e["sans-serif-font"] || (e["sans-serif-font"] =
|
|
220
|
-
function
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
let
|
|
224
|
-
for (; (
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
|
|
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
|
|
238
|
+
return p;
|
|
232
239
|
}
|
|
233
|
-
for (const
|
|
234
|
-
const
|
|
235
|
-
e[
|
|
240
|
+
for (const t in e) {
|
|
241
|
+
const i = o(e[t], e);
|
|
242
|
+
e[t] = i;
|
|
236
243
|
}
|
|
237
|
-
let l =
|
|
238
|
-
for (; (
|
|
239
|
-
const
|
|
240
|
-
e[
|
|
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
|
|
245
|
-
const
|
|
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(
|
|
259
|
+
return f.walk(a, {
|
|
253
260
|
visit: "Rule",
|
|
254
|
-
leave: (e,
|
|
261
|
+
leave: (e, s, o) => {
|
|
255
262
|
if (e.prelude.type !== "SelectorList") return;
|
|
256
|
-
const l = e.prelude.children.toArray().map((
|
|
263
|
+
const l = e.prelude.children.toArray().map((t) => f.generate(t));
|
|
257
264
|
if (l) {
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
260
|
-
for (const { property:
|
|
261
|
-
if (
|
|
262
|
-
let
|
|
263
|
-
f.walk(e.block, (
|
|
264
|
-
|
|
265
|
-
}), !
|
|
266
|
-
|
|
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:
|
|
269
|
-
value: f.parse(
|
|
275
|
+
property: c,
|
|
276
|
+
value: f.parse(p, { context: "value" })
|
|
270
277
|
})
|
|
271
278
|
);
|
|
272
279
|
}
|
|
273
280
|
}
|
|
274
281
|
}
|
|
275
|
-
}), f.generate(
|
|
282
|
+
}), f.generate(a);
|
|
276
283
|
}
|
|
277
|
-
function
|
|
278
|
-
f.walk(
|
|
284
|
+
function M(r, n) {
|
|
285
|
+
f.walk(r.block, {
|
|
279
286
|
visit: "Declaration",
|
|
280
|
-
enter(
|
|
281
|
-
const e =
|
|
282
|
-
|
|
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
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
for (const [
|
|
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
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
} else if (
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
} else if (
|
|
299
|
-
const
|
|
300
|
-
|
|
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
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
U as
|
|
319
|
-
|
|
320
|
-
|
|
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
|
};
|