@wenyan-md/core 1.0.2 → 1.0.3
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 +160 -262
- package/dist/hltheme.js +53 -0
- package/dist/theme.js +65 -0
- package/package.json +4 -2
package/dist/core.js
CHANGED
|
@@ -1,173 +1,71 @@
|
|
|
1
1
|
import { marked as y } from "marked";
|
|
2
2
|
import { markedHighlight as H } from "marked-highlight";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
3
|
+
import M from "highlight.js";
|
|
4
|
+
import I from "front-matter";
|
|
5
|
+
import * as f from "css-tree";
|
|
6
6
|
import { mathjax as j } from "mathjax-full/js/mathjax.js";
|
|
7
|
-
import { TeX as
|
|
7
|
+
import { TeX as q } from "mathjax-full/js/input/tex.js";
|
|
8
8
|
import { SVG as R } from "mathjax-full/js/output/svg.js";
|
|
9
|
-
import { liteAdaptor as
|
|
10
|
-
import { RegisterHTMLHandler as
|
|
9
|
+
import { liteAdaptor as N } from "mathjax-full/js/adaptors/liteAdaptor.js";
|
|
10
|
+
import { RegisterHTMLHandler as z } from "mathjax-full/js/handlers/html.js";
|
|
11
11
|
import { AllPackages as D } from "mathjax-full/js/input/tex/AllPackages.js";
|
|
12
|
-
|
|
12
|
+
import { themes as S } from "./theme.js";
|
|
13
|
+
import { hlThemes as A } from "./hltheme.js";
|
|
14
|
+
const B = `#wenyan pre::before {
|
|
13
15
|
display: block;
|
|
14
16
|
content: "";
|
|
15
17
|
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>');
|
|
16
18
|
background-repeat: no-repeat;
|
|
17
19
|
width: 100%;
|
|
18
20
|
height: 16px;
|
|
19
|
-
}`,
|
|
20
|
-
{
|
|
21
|
-
id: "default",
|
|
22
|
-
name: "Default",
|
|
23
|
-
description: "A clean, classic layout ideal for long-form reading."
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
id: "orangeheart",
|
|
27
|
-
name: "OrangeHeart",
|
|
28
|
-
description: "A vibrant and elegant theme in warm orange tones."
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
id: "rainbow",
|
|
32
|
-
name: "Rainbow",
|
|
33
|
-
description: "A colorful, lively theme with a clean layout."
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
id: "lapis",
|
|
37
|
-
name: "Lapis",
|
|
38
|
-
description: "A minimal and refreshing theme in cool blue tones."
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: "pie",
|
|
42
|
-
name: "Pie",
|
|
43
|
-
description: "Inspired by sspai.com and Misty — modern, sharp, and stylish."
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: "maize",
|
|
47
|
-
name: "Maize",
|
|
48
|
-
description: "A crisp, light theme with a soft maize palette."
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
id: "purple",
|
|
52
|
-
name: "Purple",
|
|
53
|
-
description: "Clean and minimalist, with a subtle purple accent."
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: "phycat",
|
|
57
|
-
name: "phycat",
|
|
58
|
-
description: "物理猫-薄荷:a mint-green theme with clear structure and hierarchy."
|
|
59
|
-
}
|
|
60
|
-
], F = /* @__PURE__ */ Object.assign({
|
|
61
|
-
"./themes/default.css": () => import("./default-D-dyLptq.js").then((e) => e.default),
|
|
62
|
-
"./themes/lapis.css": () => import("./lapis-dRySN5pK.js").then((e) => e.default),
|
|
63
|
-
"./themes/maize.css": () => import("./maize-DFW0x6O3.js").then((e) => e.default),
|
|
64
|
-
"./themes/orangeheart.css": () => import("./orangeheart-Da7uQj8U.js").then((e) => e.default),
|
|
65
|
-
"./themes/phycat.css": () => import("./phycat-BGGT9oBk.js").then((e) => e.default),
|
|
66
|
-
"./themes/pie.css": () => import("./pie-DUYodGli.js").then((e) => e.default),
|
|
67
|
-
"./themes/purple.css": () => import("./purple-Da1-Vfos.js").then((e) => e.default),
|
|
68
|
-
"./themes/rainbow.css": () => import("./rainbow-BtrbZco6.js").then((e) => e.default)
|
|
69
|
-
}), k = {};
|
|
70
|
-
for (const e of B) {
|
|
71
|
-
const n = `./themes/${e.id}.css`, s = F[n];
|
|
72
|
-
s ? k[e.id] = {
|
|
73
|
-
...e,
|
|
74
|
-
getCss: s
|
|
75
|
-
} : console.warn(`[Themes] CSS file not found for theme: ${e.id}`);
|
|
76
|
-
}
|
|
77
|
-
const G = [
|
|
78
|
-
{
|
|
79
|
-
id: "atom-one-dark"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: "atom-one-light"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "dracula"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
id: "github-dark"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
id: "github"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: "monokai"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: "solarized-dark"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: "solarized-light"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: "xcode"
|
|
104
|
-
}
|
|
105
|
-
], J = /* @__PURE__ */ Object.assign({
|
|
106
|
-
"./highlight/styles/atom-one-dark.min.css": () => import("./atom-one-dark.min-hABhDLRj.js").then((e) => e.default),
|
|
107
|
-
"./highlight/styles/atom-one-light.min.css": () => import("./atom-one-light.min-CwiVhPEv.js").then((e) => e.default),
|
|
108
|
-
"./highlight/styles/dracula.min.css": () => import("./dracula.min-OeyC4Nkp.js").then((e) => e.default),
|
|
109
|
-
"./highlight/styles/github-dark.min.css": () => import("./github-dark.min-DOlD5Ewr.js").then((e) => e.default),
|
|
110
|
-
"./highlight/styles/github.min.css": () => import("./github.min-BZ2GvPsn.js").then((e) => e.default),
|
|
111
|
-
"./highlight/styles/monokai.min.css": () => import("./monokai.min-CH2iHqHz.js").then((e) => e.default),
|
|
112
|
-
"./highlight/styles/solarized-dark.min.css": () => import("./solarized-dark.min-BxbYljx4.js").then((e) => e.default),
|
|
113
|
-
"./highlight/styles/solarized-light.min.css": () => import("./solarized-light.min-Bb25xgOC.js").then((e) => e.default),
|
|
114
|
-
"./highlight/styles/xcode.min.css": () => import("./xcode.min-CG-lWQgl.js").then((e) => e.default)
|
|
115
|
-
}), $ = {};
|
|
116
|
-
for (const e of G) {
|
|
117
|
-
const n = `./highlight/styles/${e.id}.min.css`, s = J[n];
|
|
118
|
-
s ? $[e.id] = {
|
|
119
|
-
...e,
|
|
120
|
-
getCss: s
|
|
121
|
-
} : console.warn(`[Highlight Themes] CSS file not found for theme: ${e.id}`);
|
|
122
|
-
}
|
|
123
|
-
const pe = "ui-serif, Georgia, Cambria, 'Noto Serif', 'Times New Roman', serif", U = "ui-sans-serif, system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', 'Roboto', sans-serif", z = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace", W = {
|
|
21
|
+
}`, ce = "ui-serif, Georgia, Cambria, 'Noto Serif', 'Times New Roman', serif", F = "ui-sans-serif, system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', 'Roboto', sans-serif", T = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace", G = {
|
|
124
22
|
inlineMath: [["$", "$"], ["\\(", "\\)"]],
|
|
125
23
|
displayMath: [["$$", "$$"], ["\\[", "\\]"]],
|
|
126
24
|
processEscapes: !0,
|
|
127
25
|
packages: D.sort().join(", ").split(/\s*,\s*/)
|
|
128
|
-
},
|
|
26
|
+
}, J = {
|
|
129
27
|
fontCache: "none"
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
function E(
|
|
134
|
-
const s =
|
|
135
|
-
|
|
28
|
+
}, $ = N();
|
|
29
|
+
z($);
|
|
30
|
+
const U = new q(G), W = new R(J);
|
|
31
|
+
function E(r, n) {
|
|
32
|
+
const s = r.display ? "section" : "span", e = r.display ? "block-equation" : "inline-equation";
|
|
33
|
+
r.typesetRoot = n.adaptor.node(s, { class: e }, [r.typesetRoot]);
|
|
136
34
|
}
|
|
137
|
-
async function
|
|
35
|
+
async function O(r) {
|
|
138
36
|
try {
|
|
139
|
-
const n = j.document(
|
|
140
|
-
InputJax:
|
|
141
|
-
OutputJax:
|
|
37
|
+
const n = j.document(r, {
|
|
38
|
+
InputJax: U,
|
|
39
|
+
OutputJax: W,
|
|
142
40
|
renderActions: {
|
|
143
41
|
addContainer: [190, (s) => {
|
|
144
|
-
for (const
|
|
145
|
-
E(
|
|
42
|
+
for (const e of s.math)
|
|
43
|
+
E(e, s);
|
|
146
44
|
}, E]
|
|
147
45
|
}
|
|
148
46
|
});
|
|
149
|
-
return n.render(),
|
|
47
|
+
return n.render(), $.outerHTML($.root(n.document));
|
|
150
48
|
} catch (n) {
|
|
151
49
|
throw console.error("Error rendering MathJax:", n), n;
|
|
152
50
|
}
|
|
153
51
|
}
|
|
154
|
-
function
|
|
52
|
+
function pe() {
|
|
155
53
|
y.use(
|
|
156
54
|
H({
|
|
157
55
|
langPrefix: "hljs language-",
|
|
158
|
-
highlight: function(
|
|
159
|
-
return
|
|
56
|
+
highlight: function(e, t) {
|
|
57
|
+
return t = M.getLanguage(t) ? t : "plaintext", M.highlight(e, { language: t }).value;
|
|
160
58
|
}
|
|
161
59
|
})
|
|
162
60
|
);
|
|
163
|
-
const
|
|
61
|
+
const r = {
|
|
164
62
|
name: "attributeImage",
|
|
165
63
|
level: "inline",
|
|
166
|
-
start(
|
|
167
|
-
return
|
|
64
|
+
start(e) {
|
|
65
|
+
return e.indexOf("![");
|
|
168
66
|
},
|
|
169
|
-
tokenizer(
|
|
170
|
-
const o = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(
|
|
67
|
+
tokenizer(e) {
|
|
68
|
+
const o = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(e);
|
|
171
69
|
if (o)
|
|
172
70
|
return {
|
|
173
71
|
type: "attributeImage",
|
|
@@ -177,59 +75,59 @@ function me() {
|
|
|
177
75
|
attrs: o[3]
|
|
178
76
|
};
|
|
179
77
|
},
|
|
180
|
-
renderer(
|
|
181
|
-
const
|
|
78
|
+
renderer(e) {
|
|
79
|
+
const t = Y(e.attrs), o = Array.from(t).map(
|
|
182
80
|
([i, a]) => /^\d+$/.test(a) ? `${i}:${a}px` : `${i}:${a}`
|
|
183
81
|
).join("; ");
|
|
184
|
-
return `<img src="${
|
|
82
|
+
return `<img src="${e.href}" alt="${e.alt}" style="${o}">`;
|
|
185
83
|
}
|
|
186
84
|
};
|
|
187
|
-
y.use({ extensions: [
|
|
85
|
+
y.use({ extensions: [r] });
|
|
188
86
|
const n = y.Renderer, s = y.Parser;
|
|
189
|
-
n.heading = function(
|
|
190
|
-
const
|
|
191
|
-
return `<h${o}><span>${
|
|
87
|
+
n.heading = function(e) {
|
|
88
|
+
const t = s.parseInline(e.tokens), o = e.depth;
|
|
89
|
+
return `<h${o}><span>${t}</span></h${o}>
|
|
192
90
|
`;
|
|
193
|
-
}, n.paragraph = function(
|
|
194
|
-
const
|
|
195
|
-
return
|
|
196
|
-
` : `<p>${s.parseInline(
|
|
91
|
+
}, n.paragraph = function(e) {
|
|
92
|
+
const t = e.text;
|
|
93
|
+
return t.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(t) || /\\\[[\s\S]*?\\\]/g.test(t)) ? `${t}
|
|
94
|
+
` : `<p>${s.parseInline(e.tokens)}</p>
|
|
197
95
|
`;
|
|
198
|
-
}, n.image = function(
|
|
199
|
-
return `<img src="${
|
|
96
|
+
}, n.image = function(e, t, o) {
|
|
97
|
+
return `<img src="${e.href}" alt="${o || ""}" title="${t || o || ""}">`;
|
|
200
98
|
}, y.use({ renderer: n });
|
|
201
99
|
}
|
|
202
|
-
function
|
|
100
|
+
function Y(r) {
|
|
203
101
|
const n = /* @__PURE__ */ new Map();
|
|
204
|
-
return
|
|
205
|
-
const [
|
|
206
|
-
|
|
102
|
+
return r.split(/\s+/).forEach((s) => {
|
|
103
|
+
const [e, t] = s.split("=");
|
|
104
|
+
e && t && n.set(e, t.replace(/^["']|["']$/g, ""));
|
|
207
105
|
}), n;
|
|
208
106
|
}
|
|
209
|
-
function
|
|
210
|
-
const { attributes: n, body: s } =
|
|
211
|
-
let
|
|
107
|
+
function fe(r) {
|
|
108
|
+
const { attributes: n, body: s } = I(r), e = {};
|
|
109
|
+
let t = "";
|
|
212
110
|
const { title: o, description: i, cover: a } = n;
|
|
213
|
-
return o && (
|
|
111
|
+
return o && (e.title = o), i && (t += "> " + i + `
|
|
214
112
|
|
|
215
|
-
`,
|
|
113
|
+
`, e.description = i), a && (e.cover = a), e.body = t + s, e;
|
|
216
114
|
}
|
|
217
|
-
async function
|
|
218
|
-
const n = y.parse(
|
|
219
|
-
return await
|
|
115
|
+
async function ue(r) {
|
|
116
|
+
const n = y.parse(r);
|
|
117
|
+
return await O(n);
|
|
220
118
|
}
|
|
221
|
-
async function
|
|
222
|
-
if (!(n in
|
|
119
|
+
async function he(r, n, s, e) {
|
|
120
|
+
if (!(n in S))
|
|
223
121
|
throw new Error("主题不存在");
|
|
224
|
-
if (!(s in
|
|
122
|
+
if (!(s in A))
|
|
225
123
|
throw new Error("代码块主题不存在");
|
|
226
|
-
const
|
|
227
|
-
let o =
|
|
228
|
-
o =
|
|
124
|
+
const t = S[n];
|
|
125
|
+
let o = Z(await t.getCss());
|
|
126
|
+
o = X(o, {
|
|
229
127
|
"#wenyan pre code": [
|
|
230
128
|
{
|
|
231
129
|
property: "font-family",
|
|
232
|
-
value:
|
|
130
|
+
value: T,
|
|
233
131
|
append: !0
|
|
234
132
|
}
|
|
235
133
|
],
|
|
@@ -241,21 +139,21 @@ async function fe(e, n, s, t) {
|
|
|
241
139
|
}
|
|
242
140
|
]
|
|
243
141
|
});
|
|
244
|
-
const i =
|
|
142
|
+
const i = f.parse(o, {
|
|
245
143
|
context: "stylesheet",
|
|
246
144
|
positions: !1,
|
|
247
145
|
parseAtrulePrelude: !1,
|
|
248
146
|
parseCustomProperty: !1,
|
|
249
147
|
parseValue: !1
|
|
250
|
-
}),
|
|
148
|
+
}), u = await A[s].getCss(), h = f.parse(u, {
|
|
251
149
|
context: "stylesheet",
|
|
252
150
|
positions: !1,
|
|
253
151
|
parseAtrulePrelude: !1,
|
|
254
152
|
parseCustomProperty: !1,
|
|
255
153
|
parseValue: !1
|
|
256
154
|
});
|
|
257
|
-
if (i.children.appendList(
|
|
258
|
-
const c =
|
|
155
|
+
if (i.children.appendList(h.children), e) {
|
|
156
|
+
const c = f.parse(B, {
|
|
259
157
|
context: "stylesheet",
|
|
260
158
|
positions: !1,
|
|
261
159
|
parseAtrulePrelude: !1,
|
|
@@ -264,51 +162,51 @@ async function fe(e, n, s, t) {
|
|
|
264
162
|
});
|
|
265
163
|
i.children.appendList(c.children);
|
|
266
164
|
}
|
|
267
|
-
const l =
|
|
268
|
-
|
|
165
|
+
const l = r.getElementById("wenyan");
|
|
166
|
+
f.walk(i, {
|
|
269
167
|
visit: "Rule",
|
|
270
|
-
enter(c,
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
l.style[
|
|
277
|
-
}) : l.querySelectorAll(
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
168
|
+
enter(c, p, g) {
|
|
169
|
+
const d = c.prelude.children;
|
|
170
|
+
d && d.forEach((w) => {
|
|
171
|
+
const v = f.generate(w), k = c.block.children.toArray();
|
|
172
|
+
v === "#wenyan" ? k.forEach((x) => {
|
|
173
|
+
const b = f.generate(x.value);
|
|
174
|
+
l.style[x.property] = b;
|
|
175
|
+
}) : l.querySelectorAll(v).forEach((b) => {
|
|
176
|
+
k.forEach((C) => {
|
|
177
|
+
const V = f.generate(C.value);
|
|
178
|
+
b.style[C.property] = V;
|
|
281
179
|
});
|
|
282
180
|
});
|
|
283
181
|
});
|
|
284
182
|
}
|
|
285
183
|
});
|
|
286
|
-
let
|
|
287
|
-
return
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
c.remove(),
|
|
184
|
+
let m = l.querySelectorAll("mjx-container");
|
|
185
|
+
return m.forEach((c) => {
|
|
186
|
+
const p = c.querySelector("svg");
|
|
187
|
+
p.style.width = p.getAttribute("width"), p.style.height = p.getAttribute("height"), p.removeAttribute("width"), p.removeAttribute("height");
|
|
188
|
+
const g = c.parentElement;
|
|
189
|
+
c.remove(), g.appendChild(p), g.classList.contains("block-equation") && g.setAttribute(
|
|
292
190
|
"style",
|
|
293
191
|
"text-align: center; margin-bottom: 1rem;"
|
|
294
192
|
);
|
|
295
|
-
}),
|
|
193
|
+
}), m = l.querySelectorAll("pre code"), m.forEach((c) => {
|
|
296
194
|
c.innerHTML = c.innerHTML.replace(/\n/g, "<br>").replace(
|
|
297
195
|
/(>[^<]+)|(^[^<]+)/g,
|
|
298
|
-
(
|
|
196
|
+
(p) => p.replace(/\s/g, " ")
|
|
299
197
|
);
|
|
300
|
-
}),
|
|
198
|
+
}), m = l.querySelectorAll(
|
|
301
199
|
"h1, h2, h3, h4, h5, h6, blockquote, pre"
|
|
302
|
-
),
|
|
303
|
-
const
|
|
304
|
-
|
|
200
|
+
), m.forEach((c) => {
|
|
201
|
+
const p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
202
|
+
f.walk(i, {
|
|
305
203
|
visit: "Rule",
|
|
306
|
-
enter(
|
|
307
|
-
const
|
|
308
|
-
|
|
204
|
+
enter(d) {
|
|
205
|
+
const w = f.generate(d.prelude), v = c.tagName.toLowerCase();
|
|
206
|
+
w.includes(`${v}::after`) ? L(d, p) : w.includes(`${v}::before`) && L(d, g);
|
|
309
207
|
}
|
|
310
|
-
}),
|
|
311
|
-
P(
|
|
208
|
+
}), p.size > 0 && c.appendChild(P(p, r)), g.size > 0 && c.insertBefore(
|
|
209
|
+
P(g, r),
|
|
312
210
|
c.firstChild
|
|
313
211
|
);
|
|
314
212
|
}), l.setAttribute("data-provider", "WenYan"), `${l.outerHTML.replace(
|
|
@@ -316,112 +214,112 @@ async function fe(e, n, s, t) {
|
|
|
316
214
|
'fill="none" stroke-width="70"'
|
|
317
215
|
)}`;
|
|
318
216
|
}
|
|
319
|
-
function
|
|
320
|
-
const n = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, s = /var\(--([a-zA-Z0-9\-]+)\)/g,
|
|
321
|
-
let
|
|
322
|
-
for (; (
|
|
323
|
-
const a =
|
|
217
|
+
function Z(r) {
|
|
218
|
+
const n = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, s = /var\(--([a-zA-Z0-9\-]+)\)/g, e = {};
|
|
219
|
+
let t;
|
|
220
|
+
for (; (t = n.exec(r)) !== null; ) {
|
|
221
|
+
const a = t[1], u = t[2].trim().replaceAll(`
|
|
324
222
|
`, "");
|
|
325
|
-
|
|
223
|
+
e[a] = u;
|
|
326
224
|
}
|
|
327
|
-
|
|
328
|
-
function o(a,
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
let l = a,
|
|
332
|
-
for (; (
|
|
333
|
-
const c =
|
|
334
|
-
if (
|
|
335
|
-
const
|
|
336
|
-
l = l.replace(
|
|
225
|
+
e["sans-serif-font"] || (e["sans-serif-font"] = F), e["monospace-font"] || (e["monospace-font"] = T);
|
|
226
|
+
function o(a, u, h = /* @__PURE__ */ new Set()) {
|
|
227
|
+
if (h.has(a)) return a;
|
|
228
|
+
h.add(a);
|
|
229
|
+
let l = a, m;
|
|
230
|
+
for (; (m = s.exec(l)) !== null; ) {
|
|
231
|
+
const c = m[1];
|
|
232
|
+
if (u[c]) {
|
|
233
|
+
const p = o(u[c], u, h);
|
|
234
|
+
l = l.replace(m[0], p);
|
|
337
235
|
}
|
|
338
236
|
}
|
|
339
237
|
return l;
|
|
340
238
|
}
|
|
341
|
-
for (const a in
|
|
342
|
-
const
|
|
343
|
-
|
|
239
|
+
for (const a in e) {
|
|
240
|
+
const u = o(e[a], e);
|
|
241
|
+
e[a] = u;
|
|
344
242
|
}
|
|
345
|
-
let i =
|
|
346
|
-
for (; (
|
|
347
|
-
const a =
|
|
348
|
-
|
|
243
|
+
let i = r;
|
|
244
|
+
for (; (t = s.exec(r)) !== null; ) {
|
|
245
|
+
const a = t[1];
|
|
246
|
+
e[a] && (i = i.replace(t[0], e[a]));
|
|
349
247
|
}
|
|
350
248
|
return i.replace(/:root\s*\{[^}]*\}/g, "");
|
|
351
249
|
}
|
|
352
|
-
function
|
|
353
|
-
const s =
|
|
250
|
+
function X(r, n) {
|
|
251
|
+
const s = f.parse(r, {
|
|
354
252
|
context: "stylesheet",
|
|
355
253
|
positions: !1,
|
|
356
254
|
parseAtrulePrelude: !1,
|
|
357
255
|
parseCustomProperty: !1,
|
|
358
256
|
parseValue: !1
|
|
359
257
|
});
|
|
360
|
-
return
|
|
258
|
+
return f.walk(s, {
|
|
361
259
|
visit: "Rule",
|
|
362
|
-
leave: (
|
|
363
|
-
if (
|
|
364
|
-
const i =
|
|
260
|
+
leave: (e, t, o) => {
|
|
261
|
+
if (e.prelude.type !== "SelectorList") return;
|
|
262
|
+
const i = e.prelude.children.toArray().map((a) => f.generate(a));
|
|
365
263
|
if (i) {
|
|
366
|
-
const a = i[0],
|
|
367
|
-
if (!
|
|
368
|
-
for (const { property:
|
|
264
|
+
const a = i[0], u = n[a];
|
|
265
|
+
if (!u) return;
|
|
266
|
+
for (const { property: h, value: l, append: m } of u)
|
|
369
267
|
if (l) {
|
|
370
268
|
let c = !1;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}), !c &&
|
|
269
|
+
f.walk(e.block, (p) => {
|
|
270
|
+
p.type === "Declaration" && p.property === h && (p.value = f.parse(l, { context: "value" }), c = !0);
|
|
271
|
+
}), !c && m && e.block.children.prepend(
|
|
374
272
|
o.createItem({
|
|
375
273
|
type: "Declaration",
|
|
376
|
-
property:
|
|
377
|
-
value:
|
|
274
|
+
property: h,
|
|
275
|
+
value: f.parse(l, { context: "value" })
|
|
378
276
|
})
|
|
379
277
|
);
|
|
380
278
|
}
|
|
381
279
|
}
|
|
382
280
|
}
|
|
383
|
-
}),
|
|
281
|
+
}), f.generate(s);
|
|
384
282
|
}
|
|
385
|
-
function L(
|
|
386
|
-
|
|
283
|
+
function L(r, n) {
|
|
284
|
+
f.walk(r.block, {
|
|
387
285
|
visit: "Declaration",
|
|
388
286
|
enter(s) {
|
|
389
|
-
const
|
|
390
|
-
n.set(
|
|
287
|
+
const e = s.property, t = f.generate(s.value);
|
|
288
|
+
n.set(e, t);
|
|
391
289
|
}
|
|
392
290
|
});
|
|
393
291
|
}
|
|
394
|
-
function P(
|
|
292
|
+
function P(r, n) {
|
|
395
293
|
const s = n.createElement("section");
|
|
396
|
-
|
|
397
|
-
for (const [o, i] of
|
|
294
|
+
r.get("content") && (s.textContent = r.get("content").replace(/['"]/g, ""), r.delete("content"));
|
|
295
|
+
for (const [o, i] of r)
|
|
398
296
|
if (i.includes("url(")) {
|
|
399
|
-
const a = i.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/),
|
|
297
|
+
const a = i.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/), u = i.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/), h = i.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
|
|
400
298
|
if (a) {
|
|
401
299
|
const l = decodeURIComponent(a[1]);
|
|
402
300
|
s.innerHTML = l;
|
|
403
|
-
} else if (m) {
|
|
404
|
-
const l = atob(m[1]);
|
|
405
|
-
s.innerHTML = l;
|
|
406
301
|
} else if (u) {
|
|
302
|
+
const l = atob(u[1]);
|
|
303
|
+
s.innerHTML = l;
|
|
304
|
+
} else if (h) {
|
|
407
305
|
const l = n.createElement("img");
|
|
408
|
-
l.src =
|
|
306
|
+
l.src = h[1], l.setAttribute("style", "vertical-align: top;"), s.appendChild(l);
|
|
409
307
|
}
|
|
410
|
-
|
|
308
|
+
r.delete(o);
|
|
411
309
|
}
|
|
412
|
-
const
|
|
413
|
-
return s.style.cssText =
|
|
310
|
+
const t = Array.from(r.entries()).map(([o, i]) => `${o}: ${i}`).join("; ");
|
|
311
|
+
return s.style.cssText = t, s;
|
|
414
312
|
}
|
|
415
313
|
export {
|
|
416
314
|
P as buildPseudoSpan,
|
|
417
|
-
|
|
315
|
+
pe as configureMarked,
|
|
418
316
|
L as extractDeclarations,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
317
|
+
he as getContentForGzh,
|
|
318
|
+
fe as handleFrontMatter,
|
|
319
|
+
X as modifyCss,
|
|
320
|
+
T as monospace,
|
|
321
|
+
ue as renderMarkdown,
|
|
322
|
+
Z as replaceCSSVariables,
|
|
323
|
+
F as sansSerif,
|
|
324
|
+
ce as serif
|
|
427
325
|
};
|
package/dist/hltheme.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const h = [
|
|
2
|
+
{
|
|
3
|
+
id: "atom-one-dark"
|
|
4
|
+
},
|
|
5
|
+
{
|
|
6
|
+
id: "atom-one-light"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "dracula"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: "github-dark"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "github"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "monokai"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "solarized-dark"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "solarized-light"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "xcode"
|
|
28
|
+
}
|
|
29
|
+
], l = /* @__PURE__ */ Object.assign({
|
|
30
|
+
"./highlight/styles/atom-one-dark.min.css": () => import("./atom-one-dark.min-hABhDLRj.js").then((t) => t.default),
|
|
31
|
+
"./highlight/styles/atom-one-light.min.css": () => import("./atom-one-light.min-CwiVhPEv.js").then((t) => t.default),
|
|
32
|
+
"./highlight/styles/dracula.min.css": () => import("./dracula.min-OeyC4Nkp.js").then((t) => t.default),
|
|
33
|
+
"./highlight/styles/github-dark.min.css": () => import("./github-dark.min-DOlD5Ewr.js").then((t) => t.default),
|
|
34
|
+
"./highlight/styles/github.min.css": () => import("./github.min-BZ2GvPsn.js").then((t) => t.default),
|
|
35
|
+
"./highlight/styles/monokai.min.css": () => import("./monokai.min-CH2iHqHz.js").then((t) => t.default),
|
|
36
|
+
"./highlight/styles/solarized-dark.min.css": () => import("./solarized-dark.min-BxbYljx4.js").then((t) => t.default),
|
|
37
|
+
"./highlight/styles/solarized-light.min.css": () => import("./solarized-light.min-Bb25xgOC.js").then((t) => t.default),
|
|
38
|
+
"./highlight/styles/xcode.min.css": () => import("./xcode.min-CG-lWQgl.js").then((t) => t.default)
|
|
39
|
+
}), s = {};
|
|
40
|
+
for (const t of h) {
|
|
41
|
+
const e = `./highlight/styles/${t.id}.min.css`, i = l[e];
|
|
42
|
+
i ? s[t.id] = {
|
|
43
|
+
...t,
|
|
44
|
+
getCss: i
|
|
45
|
+
} : console.warn(`[Highlight Themes] CSS file not found for theme: ${t.id}`);
|
|
46
|
+
}
|
|
47
|
+
function o() {
|
|
48
|
+
return Object.values(s);
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
o as getAllHlThemes,
|
|
52
|
+
s as hlThemes
|
|
53
|
+
};
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const a = [
|
|
2
|
+
{
|
|
3
|
+
id: "default",
|
|
4
|
+
name: "Default",
|
|
5
|
+
description: "A clean, classic layout ideal for long-form reading."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: "orangeheart",
|
|
9
|
+
name: "OrangeHeart",
|
|
10
|
+
description: "A vibrant and elegant theme in warm orange tones."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "rainbow",
|
|
14
|
+
name: "Rainbow",
|
|
15
|
+
description: "A colorful, lively theme with a clean layout."
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "lapis",
|
|
19
|
+
name: "Lapis",
|
|
20
|
+
description: "A minimal and refreshing theme in cool blue tones."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "pie",
|
|
24
|
+
name: "Pie",
|
|
25
|
+
description: "Inspired by sspai.com and Misty — modern, sharp, and stylish."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "maize",
|
|
29
|
+
name: "Maize",
|
|
30
|
+
description: "A crisp, light theme with a soft maize palette."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "purple",
|
|
34
|
+
name: "Purple",
|
|
35
|
+
description: "Clean and minimalist, with a subtle purple accent."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "phycat",
|
|
39
|
+
name: "phycat",
|
|
40
|
+
description: "物理猫-薄荷:a mint-green theme with clear structure and hierarchy."
|
|
41
|
+
}
|
|
42
|
+
], n = /* @__PURE__ */ Object.assign({
|
|
43
|
+
"./themes/default.css": () => import("./default-D-dyLptq.js").then((e) => e.default),
|
|
44
|
+
"./themes/lapis.css": () => import("./lapis-dRySN5pK.js").then((e) => e.default),
|
|
45
|
+
"./themes/maize.css": () => import("./maize-DFW0x6O3.js").then((e) => e.default),
|
|
46
|
+
"./themes/orangeheart.css": () => import("./orangeheart-Da7uQj8U.js").then((e) => e.default),
|
|
47
|
+
"./themes/phycat.css": () => import("./phycat-BGGT9oBk.js").then((e) => e.default),
|
|
48
|
+
"./themes/pie.css": () => import("./pie-DUYodGli.js").then((e) => e.default),
|
|
49
|
+
"./themes/purple.css": () => import("./purple-Da1-Vfos.js").then((e) => e.default),
|
|
50
|
+
"./themes/rainbow.css": () => import("./rainbow-BtrbZco6.js").then((e) => e.default)
|
|
51
|
+
}), s = {};
|
|
52
|
+
for (const e of a) {
|
|
53
|
+
const i = `./themes/${e.id}.css`, t = n[i];
|
|
54
|
+
t ? s[e.id] = {
|
|
55
|
+
...e,
|
|
56
|
+
getCss: t
|
|
57
|
+
} : console.warn(`[Themes] CSS file not found for theme: ${e.id}`);
|
|
58
|
+
}
|
|
59
|
+
function o() {
|
|
60
|
+
return Object.values(s);
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
o as getAllThemes,
|
|
64
|
+
s as themes
|
|
65
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenyan-md/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Core library for Wenyan markdown rendering & publishing",
|
|
5
5
|
"author": "Lei <caol64@gmail.com> (https://github.com/caol64)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": "./dist/core.js",
|
|
16
16
|
"./publish": "./dist/publish.js",
|
|
17
|
-
"./wrapper": "./dist/wrapper.js"
|
|
17
|
+
"./wrapper": "./dist/wrapper.js",
|
|
18
|
+
"./theme": "./dist/theme.js",
|
|
19
|
+
"./hltheme": "./dist/hltheme.js"
|
|
18
20
|
},
|
|
19
21
|
"scripts": {
|
|
20
22
|
"dev": "vite build --watch",
|