@wenyan-md/core 1.0.1 → 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 CHANGED
@@ -1,173 +1,71 @@
1
1
  import { marked as y } from "marked";
2
2
  import { markedHighlight as H } from "marked-highlight";
3
- import S from "highlight.js";
4
- import V from "front-matter";
5
- import * as p from "css-tree";
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 I } from "mathjax-full/js/input/tex.js";
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 q } from "mathjax-full/js/adaptors/liteAdaptor.js";
10
- import { RegisterHTMLHandler as N } from "mathjax-full/js/handlers/html.js";
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
- const O = `#wenyan pre::before {
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
- }`, B = [
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
- }, Y = {
26
+ }, J = {
129
27
  fontCache: "none"
130
- }, C = q();
131
- N(C);
132
- const Z = new I(W), X = new R(Y);
133
- function E(e, n) {
134
- const s = e.display ? "section" : "span", t = e.display ? "block-equation" : "inline-equation";
135
- e.typesetRoot = n.adaptor.node(s, { class: t }, [e.typesetRoot]);
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 K(e) {
35
+ async function O(r) {
138
36
  try {
139
- const n = j.document(e, {
140
- InputJax: Z,
141
- OutputJax: X,
37
+ const n = j.document(r, {
38
+ InputJax: U,
39
+ OutputJax: W,
142
40
  renderActions: {
143
41
  addContainer: [190, (s) => {
144
- for (const t of s.math)
145
- E(t, s);
42
+ for (const e of s.math)
43
+ E(e, s);
146
44
  }, E]
147
45
  }
148
46
  });
149
- return n.render(), C.outerHTML(C.root(n.document));
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 me() {
52
+ function pe() {
155
53
  y.use(
156
54
  H({
157
55
  langPrefix: "hljs language-",
158
- highlight: function(t, r) {
159
- return r = S.getLanguage(r) ? r : "plaintext", S.highlight(t, { language: r }).value;
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 e = {
61
+ const r = {
164
62
  name: "attributeImage",
165
63
  level: "inline",
166
- start(t) {
167
- return t.indexOf("![");
64
+ start(e) {
65
+ return e.indexOf("![");
168
66
  },
169
- tokenizer(t) {
170
- const o = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(t);
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(t) {
181
- const r = Q(t.attrs), o = Array.from(r).map(
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="${t.href}" alt="${t.alt}" style="${o}">`;
82
+ return `<img src="${e.href}" alt="${e.alt}" style="${o}">`;
185
83
  }
186
84
  };
187
- y.use({ extensions: [e] });
85
+ y.use({ extensions: [r] });
188
86
  const n = y.Renderer, s = y.Parser;
189
- n.heading = function(t) {
190
- const r = s.parseInline(t.tokens), o = t.depth;
191
- return `<h${o}><span>${r}</span></h${o}>
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(t) {
194
- const r = t.text;
195
- return r.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(r) || /\\\[[\s\S]*?\\\]/g.test(r)) ? `${r}
196
- ` : `<p>${s.parseInline(t.tokens)}</p>
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(t, r, o) {
199
- return `<img src="${t.href}" alt="${o || ""}" title="${r || o || ""}">`;
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 Q(e) {
100
+ function Y(r) {
203
101
  const n = /* @__PURE__ */ new Map();
204
- return e.split(/\s+/).forEach((s) => {
205
- const [t, r] = s.split("=");
206
- t && r && n.set(t, r.replace(/^["']|["']$/g, ""));
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 ue(e) {
210
- const { attributes: n, body: s } = V(e), t = {};
211
- let r = "";
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 && (t.title = o), i && (r += "> " + i + `
111
+ return o && (e.title = o), i && (t += "> " + i + `
214
112
 
215
- `, t.description = i), a && (t.cover = a), t.body = r + s, t;
113
+ `, e.description = i), a && (e.cover = a), e.body = t + s, e;
216
114
  }
217
- async function de(e) {
218
- const n = y.parse(e);
219
- return await K(n);
115
+ async function ue(r) {
116
+ const n = y.parse(r);
117
+ return await O(n);
220
118
  }
221
- async function fe(e, n, s, t) {
222
- if (!(n in k))
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 r = k[n];
227
- let o = _(await r.getCss());
228
- o = ee(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: z,
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 = p.parse(o, {
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
- }), m = await $[s].getCss(), u = p.parse(m, {
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(u.children), t) {
258
- const c = p.parse(O, {
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 = e.getElementById("wenyan");
268
- p.walk(i, {
165
+ const l = r.getElementById("wenyan");
166
+ f.walk(i, {
269
167
  visit: "Rule",
270
- enter(c, h, f) {
271
- const g = c.prelude.children;
272
- g && g.forEach((b) => {
273
- const w = p.generate(b), M = c.block.children.toArray();
274
- w === "#wenyan" ? M.forEach((v) => {
275
- const x = p.generate(v.value);
276
- l.style[v.property] = x;
277
- }) : l.querySelectorAll(w).forEach((x) => {
278
- M.forEach((A) => {
279
- const T = p.generate(A.value);
280
- x.style[A.property] = T;
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 d = l.querySelectorAll("mjx-container");
287
- return d.forEach((c) => {
288
- const h = c.querySelector("svg");
289
- h.style.width = h.getAttribute("width"), h.style.height = h.getAttribute("height"), h.removeAttribute("width"), h.removeAttribute("height");
290
- const f = c.parentElement;
291
- c.remove(), f.appendChild(h), f.classList.contains("block-equation") && f.setAttribute(
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
- }), d = l.querySelectorAll("pre code"), d.forEach((c) => {
193
+ }), m = l.querySelectorAll("pre code"), m.forEach((c) => {
296
194
  c.innerHTML = c.innerHTML.replace(/\n/g, "<br>").replace(
297
195
  /(>[^<]+)|(^[^<]+)/g,
298
- (h) => h.replace(/\s/g, "&nbsp;")
196
+ (p) => p.replace(/\s/g, "&nbsp;")
299
197
  );
300
- }), d = l.querySelectorAll(
198
+ }), m = l.querySelectorAll(
301
199
  "h1, h2, h3, h4, h5, h6, blockquote, pre"
302
- ), d.forEach((c) => {
303
- const h = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
304
- p.walk(i, {
200
+ ), m.forEach((c) => {
201
+ const p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
202
+ f.walk(i, {
305
203
  visit: "Rule",
306
- enter(g) {
307
- const b = p.generate(g.prelude), w = c.tagName.toLowerCase();
308
- b.includes(`${w}::after`) ? L(g, h) : b.includes(`${w}::before`) && L(g, f);
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
- }), h.size > 0 && c.appendChild(P(h, e)), f.size > 0 && c.insertBefore(
311
- P(f, e),
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 _(e) {
320
- const n = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, s = /var\(--([a-zA-Z0-9\-]+)\)/g, t = {};
321
- let r;
322
- for (; (r = n.exec(e)) !== null; ) {
323
- const a = r[1], m = r[2].trim().replaceAll(`
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
- t[a] = m;
223
+ e[a] = u;
326
224
  }
327
- t["sans-serif-font"] || (t["sans-serif-font"] = U), t["monospace-font"] || (t["monospace-font"] = z);
328
- function o(a, m, u = /* @__PURE__ */ new Set()) {
329
- if (u.has(a)) return a;
330
- u.add(a);
331
- let l = a, d;
332
- for (; (d = s.exec(l)) !== null; ) {
333
- const c = d[1];
334
- if (m[c]) {
335
- const h = o(m[c], m, u);
336
- l = l.replace(d[0], h);
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 t) {
342
- const m = o(t[a], t);
343
- t[a] = m;
239
+ for (const a in e) {
240
+ const u = o(e[a], e);
241
+ e[a] = u;
344
242
  }
345
- let i = e;
346
- for (; (r = s.exec(e)) !== null; ) {
347
- const a = r[1];
348
- t[a] && (i = i.replace(r[0], t[a]));
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 ee(e, n) {
353
- const s = p.parse(e, {
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 p.walk(s, {
258
+ return f.walk(s, {
361
259
  visit: "Rule",
362
- leave: (t, r, o) => {
363
- if (t.prelude.type !== "SelectorList") return;
364
- const i = t.prelude.children.toArray().map((a) => p.generate(a));
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], m = n[a];
367
- if (!m) return;
368
- for (const { property: u, value: l, append: d } of m)
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
- p.walk(t.block, (h) => {
372
- h.type === "Declaration" && h.property === u && (h.value = p.parse(l, { context: "value" }), c = !0);
373
- }), !c && d && t.block.children.prepend(
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: u,
377
- value: p.parse(l, { context: "value" })
274
+ property: h,
275
+ value: f.parse(l, { context: "value" })
378
276
  })
379
277
  );
380
278
  }
381
279
  }
382
280
  }
383
- }), p.generate(s);
281
+ }), f.generate(s);
384
282
  }
385
- function L(e, n) {
386
- p.walk(e.block, {
283
+ function L(r, n) {
284
+ f.walk(r.block, {
387
285
  visit: "Declaration",
388
286
  enter(s) {
389
- const t = s.property, r = p.generate(s.value);
390
- n.set(t, r);
287
+ const e = s.property, t = f.generate(s.value);
288
+ n.set(e, t);
391
289
  }
392
290
  });
393
291
  }
394
- function P(e, n) {
292
+ function P(r, n) {
395
293
  const s = n.createElement("section");
396
- e.get("content") && (s.textContent = e.get("content").replace(/['"]/g, ""), e.delete("content"));
397
- for (const [o, i] of e)
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>)/), m = i.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/), u = i.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
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 = u[1], l.setAttribute("style", "vertical-align: top;"), s.appendChild(l);
306
+ l.src = h[1], l.setAttribute("style", "vertical-align: top;"), s.appendChild(l);
409
307
  }
410
- e.delete(o);
308
+ r.delete(o);
411
309
  }
412
- const r = Array.from(e.entries()).map(([o, i]) => `${o}: ${i}`).join("; ");
413
- return s.style.cssText = r, s;
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
- me as configureMarked,
315
+ pe as configureMarked,
418
316
  L as extractDeclarations,
419
- fe as getContentForGzh,
420
- ue as handleFrontMatter,
421
- ee as modifyCss,
422
- z as monospace,
423
- de as renderMarkdown,
424
- _ as replaceCSSVariables,
425
- U as sansSerif,
426
- pe as serif
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
  };
@@ -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
+ };
@@ -0,0 +1,7 @@
1
+ export type GzhContent = {
2
+ title: string;
3
+ cover: string;
4
+ content: string;
5
+ description: string;
6
+ };
7
+ export declare function getGzhContent(content: string, themeId: string, hlThemeId: string, isMacStyle: boolean): Promise<GzhContent>;
@@ -0,0 +1,15 @@
1
+ import { JSDOM as a } from "jsdom";
2
+ import { configureMarked as s, handleFrontMatter as m, renderMarkdown as w, getContentForGzh as l } from "./core.js";
3
+ async function f(n, o, e, r) {
4
+ s();
5
+ const t = m(n), c = await w(t.body), d = new a(`<body><section id="wenyan">${c}</section></body>`).window.document, i = await l(d, o, e, r);
6
+ return {
7
+ title: t.title,
8
+ cover: t.cover,
9
+ content: i,
10
+ description: t.description
11
+ };
12
+ }
13
+ export {
14
+ f as getGzhContent
15
+ };
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@wenyan-md/core",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Core library for Wenyan markdown rendering & publishing",
5
+ "author": "Lei <caol64@gmail.com> (https://github.com/caol64)",
6
+ "license": "Apache-2.0",
7
+ "keywords": ["公众号", "markdown", "文颜", "wenyan", "wechat", "publishing", "renderer"],
5
8
  "type": "module",
6
9
  "files": [
7
10
  "dist"
@@ -10,17 +13,19 @@
10
13
  "module": "./dist/core.js",
11
14
  "exports": {
12
15
  ".": "./dist/core.js",
13
- "./publish": "./dist/publish.js"
16
+ "./publish": "./dist/publish.js",
17
+ "./wrapper": "./dist/wrapper.js",
18
+ "./theme": "./dist/theme.js",
19
+ "./hltheme": "./dist/hltheme.js"
14
20
  },
15
21
  "scripts": {
16
22
  "dev": "vite build --watch",
17
23
  "build": "vite build && tsc",
18
24
  "testMain": "vitest run main.test.js",
25
+ "testWrapper": "vitest run wrapper.test.js",
19
26
  "testPublish": "vitest run publish.test.js",
20
27
  "prepublishOnly": "pnpm build"
21
28
  },
22
- "keywords": [],
23
- "author": "",
24
29
  "packageManager": "pnpm@10.7.1",
25
30
  "devDependencies": {
26
31
  "@types/css-tree": "^2.3.10",