@wenyan-md/core 1.0.3 → 1.0.5
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 +203 -202
- package/dist/juejin_default-CnUAGV72.js +139 -0
- package/dist/medium_default-BXHGUKdY.js +135 -0
- package/dist/theme.js +61 -19
- package/dist/toutiao_default-DthFV93V.js +151 -0
- package/dist/types/theme.d.ts +3 -0
- package/dist/wrapper.js +4 -4
- package/dist/zhihu_default-7uVAZjKn.js +138 -0
- package/package.json +40 -19
- package/dist/types/index.d.ts +0 -1
package/dist/core.js
CHANGED
|
@@ -1,133 +1,142 @@
|
|
|
1
|
-
import { marked as
|
|
2
|
-
import { markedHighlight as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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";
|
|
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 {
|
|
14
|
-
|
|
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";
|
|
14
|
+
import { hlThemes as C } from "./hltheme.js";
|
|
15
|
+
import { getAllHlThemes as ge } from "./hltheme.js";
|
|
16
|
+
const R = `#wenyan pre::before {
|
|
15
17
|
display: block;
|
|
16
18
|
content: "";
|
|
17
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>');
|
|
18
20
|
background-repeat: no-repeat;
|
|
19
21
|
width: 100%;
|
|
20
22
|
height: 16px;
|
|
21
|
-
}`,
|
|
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 = {
|
|
22
24
|
inlineMath: [["$", "$"], ["\\(", "\\)"]],
|
|
23
25
|
displayMath: [["$$", "$$"], ["\\[", "\\]"]],
|
|
24
26
|
processEscapes: !0,
|
|
25
|
-
packages:
|
|
26
|
-
},
|
|
27
|
+
packages: E
|
|
28
|
+
}, N = {
|
|
27
29
|
fontCache: "none"
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
|
|
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]);
|
|
34
36
|
}
|
|
35
|
-
async function
|
|
37
|
+
async function G(o) {
|
|
36
38
|
try {
|
|
37
|
-
const
|
|
38
|
-
InputJax:
|
|
39
|
-
OutputJax:
|
|
39
|
+
const s = P.document(o, {
|
|
40
|
+
InputJax: D,
|
|
41
|
+
OutputJax: F,
|
|
40
42
|
renderActions: {
|
|
41
|
-
addContainer: [190, (
|
|
42
|
-
for (const
|
|
43
|
-
|
|
44
|
-
},
|
|
43
|
+
addContainer: [190, (e) => {
|
|
44
|
+
for (const t of e.math)
|
|
45
|
+
$(t, e);
|
|
46
|
+
}, $]
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
function ae() {
|
|
57
|
+
g.use(
|
|
58
|
+
L({
|
|
55
59
|
langPrefix: "hljs language-",
|
|
56
60
|
highlight: function(e, t) {
|
|
57
|
-
return t =
|
|
61
|
+
return t = w.getLanguage(t) ? t : "plaintext", w.highlight(e, { language: t }).value;
|
|
58
62
|
}
|
|
59
63
|
})
|
|
60
64
|
);
|
|
61
|
-
const
|
|
65
|
+
const o = {
|
|
62
66
|
name: "attributeImage",
|
|
63
67
|
level: "inline",
|
|
64
68
|
start(e) {
|
|
65
69
|
return e.indexOf("![");
|
|
66
70
|
},
|
|
67
71
|
tokenizer(e) {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
72
|
+
const i = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/.exec(e);
|
|
73
|
+
if (i)
|
|
70
74
|
return {
|
|
71
75
|
type: "attributeImage",
|
|
72
|
-
raw:
|
|
73
|
-
alt:
|
|
74
|
-
href:
|
|
75
|
-
attrs:
|
|
76
|
+
raw: i[0],
|
|
77
|
+
alt: i[1],
|
|
78
|
+
href: i[2],
|
|
79
|
+
attrs: i[3]
|
|
76
80
|
};
|
|
77
81
|
},
|
|
78
82
|
renderer(e) {
|
|
79
|
-
const t =
|
|
80
|
-
([
|
|
83
|
+
const t = B(e.attrs), i = Array.from(t).map(
|
|
84
|
+
([l, r]) => /^\d+$/.test(r) ? `${l}:${r}px` : `${l}:${r}`
|
|
81
85
|
).join("; ");
|
|
82
|
-
return `<img src="${e.href}" alt="${e.alt}" style="${
|
|
86
|
+
return `<img src="${e.href}" alt="${e.alt}" style="${i}">`;
|
|
83
87
|
}
|
|
84
88
|
};
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const t =
|
|
89
|
-
return `<h${
|
|
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}>
|
|
90
94
|
`;
|
|
91
|
-
},
|
|
95
|
+
}, s.paragraph = function(e) {
|
|
92
96
|
const t = e.text;
|
|
93
97
|
return t.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(t) || /\\\[[\s\S]*?\\\]/g.test(t)) ? `${t}
|
|
94
|
-
` : `<p>${
|
|
98
|
+
` : `<p>${n.parseInline(e.tokens)}</p>
|
|
95
99
|
`;
|
|
96
|
-
},
|
|
97
|
-
return `<img src="${e.href}" alt="${
|
|
98
|
-
},
|
|
100
|
+
}, s.image = function(e, t, i) {
|
|
101
|
+
return `<img src="${e.href}" alt="${i || ""}" title="${t || i || ""}">`;
|
|
102
|
+
}, g.use({ renderer: s });
|
|
99
103
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
return
|
|
103
|
-
const [e, t] =
|
|
104
|
-
e && t &&
|
|
105
|
-
}),
|
|
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;
|
|
106
110
|
}
|
|
107
|
-
function
|
|
108
|
-
const { attributes:
|
|
111
|
+
function ie(o) {
|
|
112
|
+
const { attributes: s, body: n } = T(o), e = {};
|
|
109
113
|
let t = "";
|
|
110
|
-
const { title:
|
|
111
|
-
return
|
|
114
|
+
const { title: i, description: l, cover: r } = s;
|
|
115
|
+
return i && (e.title = i), l && (t += "> " + l + `
|
|
112
116
|
|
|
113
|
-
`, e.description =
|
|
117
|
+
`, e.description = l), r && (e.cover = r), e.body = t + n, e;
|
|
114
118
|
}
|
|
115
|
-
async function
|
|
116
|
-
const
|
|
117
|
-
return await
|
|
119
|
+
async function le(o) {
|
|
120
|
+
const s = g.parse(o);
|
|
121
|
+
return await G(s);
|
|
118
122
|
}
|
|
119
|
-
async function
|
|
120
|
-
|
|
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)
|
|
121
128
|
throw new Error("主题不存在");
|
|
122
|
-
if (!(
|
|
129
|
+
if (!(n in C))
|
|
123
130
|
throw new Error("代码块主题不存在");
|
|
124
|
-
const t =
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
const i = O(await t.getCss()), r = await C[n].getCss();
|
|
132
|
+
return J(o, i, r, e);
|
|
133
|
+
}
|
|
134
|
+
async function J(o, s, n, e) {
|
|
135
|
+
s = U(s, {
|
|
127
136
|
"#wenyan pre code": [
|
|
128
137
|
{
|
|
129
138
|
property: "font-family",
|
|
130
|
-
value:
|
|
139
|
+
value: A,
|
|
131
140
|
append: !0
|
|
132
141
|
}
|
|
133
142
|
],
|
|
@@ -139,187 +148,179 @@ async function he(r, n, s, e) {
|
|
|
139
148
|
}
|
|
140
149
|
]
|
|
141
150
|
});
|
|
142
|
-
const
|
|
151
|
+
const t = f.parse(s, {
|
|
143
152
|
context: "stylesheet",
|
|
144
153
|
positions: !1,
|
|
145
154
|
parseAtrulePrelude: !1,
|
|
146
155
|
parseCustomProperty: !1,
|
|
147
156
|
parseValue: !1
|
|
148
|
-
}),
|
|
157
|
+
}), i = f.parse(n, {
|
|
149
158
|
context: "stylesheet",
|
|
150
159
|
positions: !1,
|
|
151
160
|
parseAtrulePrelude: !1,
|
|
152
161
|
parseCustomProperty: !1,
|
|
153
162
|
parseValue: !1
|
|
154
163
|
});
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
164
|
+
if (t.children.appendList(i.children), e) {
|
|
165
|
+
const r = f.parse(R, {
|
|
157
166
|
context: "stylesheet",
|
|
158
167
|
positions: !1,
|
|
159
168
|
parseAtrulePrelude: !1,
|
|
160
169
|
parseCustomProperty: !1,
|
|
161
170
|
parseValue: !1
|
|
162
171
|
});
|
|
163
|
-
|
|
172
|
+
t.children.appendList(r.children);
|
|
164
173
|
}
|
|
165
|
-
|
|
166
|
-
f.walk(i, {
|
|
174
|
+
f.walk(t, {
|
|
167
175
|
visit: "Rule",
|
|
168
|
-
enter(
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
}) :
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
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;
|
|
179
187
|
});
|
|
180
188
|
});
|
|
181
189
|
});
|
|
182
190
|
}
|
|
183
191
|
});
|
|
184
|
-
let
|
|
185
|
-
return
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/(>[^<]+)|(^[^<]+)/g,
|
|
196
|
-
(p) => p.replace(/\s/g, " ")
|
|
197
|
-
);
|
|
198
|
-
}), m = l.querySelectorAll(
|
|
199
|
-
"h1, h2, h3, h4, h5, h6, blockquote, pre"
|
|
200
|
-
), m.forEach((c) => {
|
|
201
|
-
const p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
202
|
-
f.walk(i, {
|
|
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, " "));
|
|
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, {
|
|
203
203
|
visit: "Rule",
|
|
204
|
-
enter(
|
|
205
|
-
const
|
|
206
|
-
|
|
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);
|
|
207
207
|
}
|
|
208
|
-
}),
|
|
209
|
-
|
|
210
|
-
c.firstChild
|
|
211
|
-
);
|
|
212
|
-
}), l.setAttribute("data-provider", "WenYan"), `${l.outerHTML.replace(
|
|
213
|
-
/class="mjx-solid"/g,
|
|
214
|
-
'fill="none" stroke-width="70"'
|
|
215
|
-
)}`;
|
|
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"')}`;
|
|
216
210
|
}
|
|
217
|
-
function
|
|
218
|
-
const
|
|
211
|
+
function O(o) {
|
|
212
|
+
const s = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g, n = /var\(--([a-zA-Z0-9\-]+)\)/g, e = {};
|
|
219
213
|
let t;
|
|
220
|
-
for (; (t =
|
|
221
|
-
const
|
|
214
|
+
for (; (t = s.exec(o)) !== null; ) {
|
|
215
|
+
const r = t[1], a = t[2].trim().replaceAll(`
|
|
222
216
|
`, "");
|
|
223
|
-
e[
|
|
217
|
+
e[r] = a;
|
|
224
218
|
}
|
|
225
|
-
e["sans-serif-font"] || (e["sans-serif-font"] =
|
|
226
|
-
function
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
let
|
|
230
|
-
for (; (
|
|
231
|
-
const
|
|
232
|
-
if (u
|
|
233
|
-
const
|
|
234
|
-
|
|
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);
|
|
235
229
|
}
|
|
236
230
|
}
|
|
237
|
-
return
|
|
231
|
+
return c;
|
|
238
232
|
}
|
|
239
|
-
for (const
|
|
240
|
-
const
|
|
241
|
-
e[
|
|
233
|
+
for (const r in e) {
|
|
234
|
+
const a = i(e[r], e);
|
|
235
|
+
e[r] = a;
|
|
242
236
|
}
|
|
243
|
-
let
|
|
244
|
-
for (; (t =
|
|
245
|
-
const
|
|
246
|
-
e[
|
|
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]));
|
|
247
241
|
}
|
|
248
|
-
return
|
|
242
|
+
return l.replace(/:root\s*\{[^}]*\}/g, "");
|
|
249
243
|
}
|
|
250
|
-
function
|
|
251
|
-
const
|
|
244
|
+
function U(o, s) {
|
|
245
|
+
const n = f.parse(o, {
|
|
252
246
|
context: "stylesheet",
|
|
253
247
|
positions: !1,
|
|
254
248
|
parseAtrulePrelude: !1,
|
|
255
249
|
parseCustomProperty: !1,
|
|
256
250
|
parseValue: !1
|
|
257
251
|
});
|
|
258
|
-
return f.walk(
|
|
252
|
+
return f.walk(n, {
|
|
259
253
|
visit: "Rule",
|
|
260
|
-
leave: (e, t,
|
|
254
|
+
leave: (e, t, i) => {
|
|
261
255
|
if (e.prelude.type !== "SelectorList") return;
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
264
|
-
const
|
|
265
|
-
if (!
|
|
266
|
-
for (const { property:
|
|
267
|
-
if (
|
|
268
|
-
let
|
|
269
|
-
f.walk(e.block, (
|
|
270
|
-
|
|
271
|
-
}), !
|
|
272
|
-
|
|
256
|
+
const l = e.prelude.children.toArray().map((r) => f.generate(r));
|
|
257
|
+
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({
|
|
273
267
|
type: "Declaration",
|
|
274
|
-
property:
|
|
275
|
-
value: f.parse(
|
|
268
|
+
property: p,
|
|
269
|
+
value: f.parse(c, { context: "value" })
|
|
276
270
|
})
|
|
277
271
|
);
|
|
278
272
|
}
|
|
279
273
|
}
|
|
280
274
|
}
|
|
281
|
-
}), f.generate(
|
|
275
|
+
}), f.generate(n);
|
|
282
276
|
}
|
|
283
|
-
function
|
|
284
|
-
f.walk(
|
|
277
|
+
function k(o, s) {
|
|
278
|
+
f.walk(o.block, {
|
|
285
279
|
visit: "Declaration",
|
|
286
|
-
enter(
|
|
287
|
-
const e =
|
|
288
|
-
|
|
280
|
+
enter(n) {
|
|
281
|
+
const e = n.property, t = f.generate(n.value);
|
|
282
|
+
s.set(e, t);
|
|
289
283
|
}
|
|
290
284
|
});
|
|
291
285
|
}
|
|
292
|
-
function
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
for (const [
|
|
296
|
-
if (
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
} else if (
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
} else if (
|
|
305
|
-
const
|
|
306
|
-
|
|
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)
|
|
290
|
+
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);
|
|
307
301
|
}
|
|
308
|
-
|
|
302
|
+
o.delete(i);
|
|
309
303
|
}
|
|
310
|
-
const t = Array.from(
|
|
311
|
-
return
|
|
304
|
+
const t = Array.from(o.entries()).map(([i, l]) => `${i}: ${l}`).join("; ");
|
|
305
|
+
return n.style.cssText = t, n;
|
|
312
306
|
}
|
|
313
307
|
export {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
|
325
326
|
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const n = `:root {
|
|
2
|
+
--sans-serif-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
|
|
3
|
+
"Noto Color Emoji";
|
|
4
|
+
--monospace-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace;
|
|
5
|
+
}
|
|
6
|
+
#wenyan {
|
|
7
|
+
font-family: var(--sans-serif-font);
|
|
8
|
+
line-height: 1.75;
|
|
9
|
+
}
|
|
10
|
+
#wenyan * {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
#wenyan h1,
|
|
14
|
+
#wenyan h2,
|
|
15
|
+
#wenyan h3,
|
|
16
|
+
#wenyan h4,
|
|
17
|
+
#wenyan h5,
|
|
18
|
+
#wenyan h6,
|
|
19
|
+
#wenyan p,
|
|
20
|
+
#wenyan pre {
|
|
21
|
+
margin: 1em 0;
|
|
22
|
+
}
|
|
23
|
+
#wenyan h1,
|
|
24
|
+
#wenyan h2,
|
|
25
|
+
#wenyan h3,
|
|
26
|
+
#wenyan h4,
|
|
27
|
+
#wenyan h5,
|
|
28
|
+
#wenyan h6 {
|
|
29
|
+
line-height: 1.5;
|
|
30
|
+
margin-top: 35px;
|
|
31
|
+
margin-bottom: 10px;
|
|
32
|
+
padding-bottom: 5px;
|
|
33
|
+
}
|
|
34
|
+
#wenyan h1 {
|
|
35
|
+
font-size: 24px;
|
|
36
|
+
line-height: 38px;
|
|
37
|
+
margin-bottom: 5px;
|
|
38
|
+
}
|
|
39
|
+
#wenyan h2 {
|
|
40
|
+
font-size: 22px;
|
|
41
|
+
line-height: 34px;
|
|
42
|
+
padding-bottom: 12px;
|
|
43
|
+
border-bottom: 1px solid #ececec;
|
|
44
|
+
}
|
|
45
|
+
#wenyan h3 {
|
|
46
|
+
font-size: 20px;
|
|
47
|
+
line-height: 28px;
|
|
48
|
+
}
|
|
49
|
+
#wenyan ul,
|
|
50
|
+
#wenyan ol {
|
|
51
|
+
padding-left: 1.2em;
|
|
52
|
+
}
|
|
53
|
+
#wenyan li {
|
|
54
|
+
margin-left: 1.2em;
|
|
55
|
+
}
|
|
56
|
+
#wenyan img {
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
height: auto;
|
|
59
|
+
margin: 0 auto;
|
|
60
|
+
display: block;
|
|
61
|
+
}
|
|
62
|
+
#wenyan table {
|
|
63
|
+
display: inline-block !important;
|
|
64
|
+
font-size: 12px;
|
|
65
|
+
width: auto;
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
overflow: auto;
|
|
68
|
+
border: 1px solid #f6f6f6;
|
|
69
|
+
}
|
|
70
|
+
#wenyan thead {
|
|
71
|
+
background: #f6f6f6;
|
|
72
|
+
color: #000;
|
|
73
|
+
text-align: left;
|
|
74
|
+
}
|
|
75
|
+
#wenyan table td,
|
|
76
|
+
#wenyan table th {
|
|
77
|
+
padding: 12px 7px;
|
|
78
|
+
line-height: 24px;
|
|
79
|
+
}
|
|
80
|
+
#wenyan blockquote {
|
|
81
|
+
color: #666;
|
|
82
|
+
padding: 1px 23px;
|
|
83
|
+
margin: 22px 0;
|
|
84
|
+
border-left: 4px solid #cbcbcb;
|
|
85
|
+
background-color: #f8f8f8;
|
|
86
|
+
font-size: 0.95em;
|
|
87
|
+
}
|
|
88
|
+
#wenyan p code {
|
|
89
|
+
font-family: var(--monospace-font);
|
|
90
|
+
background: #fff5f5;
|
|
91
|
+
color: #ff502c;
|
|
92
|
+
padding: 4px 6px;
|
|
93
|
+
font-size: 0.78em;
|
|
94
|
+
}
|
|
95
|
+
#wenyan pre {
|
|
96
|
+
line-height: 2;
|
|
97
|
+
margin: 1em 0.5em;
|
|
98
|
+
padding: .5em;
|
|
99
|
+
color: #333;
|
|
100
|
+
background: #f8f8f8;
|
|
101
|
+
}
|
|
102
|
+
#wenyan pre code {
|
|
103
|
+
font-family: var(--monospace-font);
|
|
104
|
+
display: block;
|
|
105
|
+
overflow-x: auto;
|
|
106
|
+
margin: .5em;
|
|
107
|
+
padding: 0;
|
|
108
|
+
background: #f8f8f8;
|
|
109
|
+
}
|
|
110
|
+
#wenyan hr {
|
|
111
|
+
border: none;
|
|
112
|
+
border-top: 1px solid #ddd;
|
|
113
|
+
margin-top: 32px;
|
|
114
|
+
margin-bottom: 32px;
|
|
115
|
+
}
|
|
116
|
+
/* 链接 */
|
|
117
|
+
#wenyan a {
|
|
118
|
+
word-wrap: break-word;
|
|
119
|
+
color: #0069c2;
|
|
120
|
+
}
|
|
121
|
+
/* 脚注 */
|
|
122
|
+
#wenyan #footnotes ul {
|
|
123
|
+
font-size: 0.9em;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding-left: 1.2em;
|
|
126
|
+
}
|
|
127
|
+
#wenyan #footnotes li {
|
|
128
|
+
margin: 0 0 0 1.2em;
|
|
129
|
+
overflow-wrap: break-word;
|
|
130
|
+
word-wrap: break-word;
|
|
131
|
+
word-break: break-all;
|
|
132
|
+
}
|
|
133
|
+
#wenyan .footnote {
|
|
134
|
+
color: #0069c2;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
export {
|
|
138
|
+
n as default
|
|
139
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const n = `:root {
|
|
2
|
+
--sans-serif-font: source-serif-pro, Georgia, Cambria, "Times New Roman", Times, serif;
|
|
3
|
+
--monospace-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace;
|
|
4
|
+
}
|
|
5
|
+
#wenyan {
|
|
6
|
+
font-family: var(--sans-serif-font);
|
|
7
|
+
line-height: 1.75;
|
|
8
|
+
font-size: 16px;
|
|
9
|
+
}
|
|
10
|
+
#wenyan * {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
#wenyan h1,
|
|
14
|
+
#wenyan h2,
|
|
15
|
+
#wenyan h3,
|
|
16
|
+
#wenyan h4,
|
|
17
|
+
#wenyan h5,
|
|
18
|
+
#wenyan h6 {
|
|
19
|
+
font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
20
|
+
margin: 1em 0;
|
|
21
|
+
}
|
|
22
|
+
#wenyan h1 {
|
|
23
|
+
font-size: 2em;
|
|
24
|
+
font-weight: 700;
|
|
25
|
+
}
|
|
26
|
+
#wenyan h2,
|
|
27
|
+
#wenyan h3 {
|
|
28
|
+
font-size: 1.3em;
|
|
29
|
+
font-weight: 700;
|
|
30
|
+
}
|
|
31
|
+
#wenyan h4,
|
|
32
|
+
#wenyan h5,
|
|
33
|
+
#wenyan h6 {
|
|
34
|
+
font-size: 1.2em;
|
|
35
|
+
font-weight: 700;
|
|
36
|
+
}
|
|
37
|
+
#wenyan p {
|
|
38
|
+
letter-spacing: -0.003em;
|
|
39
|
+
margin: 1em 0;
|
|
40
|
+
}
|
|
41
|
+
#wenyan ul,
|
|
42
|
+
#wenyan ol {
|
|
43
|
+
padding-left: 1.2em;
|
|
44
|
+
}
|
|
45
|
+
#wenyan li {
|
|
46
|
+
margin-left: 1.2em;
|
|
47
|
+
}
|
|
48
|
+
#wenyan img {
|
|
49
|
+
max-width: 100%;
|
|
50
|
+
height: auto;
|
|
51
|
+
margin: 0 auto;
|
|
52
|
+
display: block;
|
|
53
|
+
}
|
|
54
|
+
#wenyan table {
|
|
55
|
+
border-collapse: collapse;
|
|
56
|
+
font-size: 15px;
|
|
57
|
+
margin: 1.4em auto;
|
|
58
|
+
max-width: 100%;
|
|
59
|
+
table-layout: fixed;
|
|
60
|
+
text-align: left;
|
|
61
|
+
width: 100%;
|
|
62
|
+
word-wrap: break-word;
|
|
63
|
+
word-break: break-all;
|
|
64
|
+
}
|
|
65
|
+
#wenyan table th {
|
|
66
|
+
background: #ebeced;
|
|
67
|
+
color: #191b1f;
|
|
68
|
+
font-weight: 500;
|
|
69
|
+
}
|
|
70
|
+
#wenyan table td,
|
|
71
|
+
#wenyan table th {
|
|
72
|
+
border: 1px solid #c4c7ce;
|
|
73
|
+
height: 24px;
|
|
74
|
+
line-height: 24px;
|
|
75
|
+
padding: 3px 12px;
|
|
76
|
+
}
|
|
77
|
+
#wenyan blockquote {
|
|
78
|
+
letter-spacing: -0.003em;
|
|
79
|
+
border-left: 3px solid rgba(0, 0, 0, 0.84);
|
|
80
|
+
padding-left: 20px;
|
|
81
|
+
margin: 0 0 20px 0;
|
|
82
|
+
}
|
|
83
|
+
#wenyan p code {
|
|
84
|
+
padding: 4px 6px;
|
|
85
|
+
font-size: 0.78em;
|
|
86
|
+
border-radius: 3px;
|
|
87
|
+
font-family: var(--monospace-font);
|
|
88
|
+
background-color: #f2f2f2;
|
|
89
|
+
}
|
|
90
|
+
#wenyan pre {
|
|
91
|
+
line-height: 2;
|
|
92
|
+
margin: 1em 0.5em;
|
|
93
|
+
padding: 1em;
|
|
94
|
+
background: #f9f9f9;
|
|
95
|
+
border-radius: 4px;
|
|
96
|
+
border: 1px solid #e5e5e5;
|
|
97
|
+
}
|
|
98
|
+
#wenyan pre code {
|
|
99
|
+
display: block;
|
|
100
|
+
overflow-x: auto;
|
|
101
|
+
margin: .5em;
|
|
102
|
+
padding: 0;
|
|
103
|
+
font-family: var(--monospace-font);
|
|
104
|
+
background: #f9f9f9;
|
|
105
|
+
}
|
|
106
|
+
#wenyan hr {
|
|
107
|
+
border: none;
|
|
108
|
+
border-top: 1px solid #c4c7ce;
|
|
109
|
+
margin: 2em auto;
|
|
110
|
+
max-width: 100%;
|
|
111
|
+
width: 240px;
|
|
112
|
+
}
|
|
113
|
+
/* 链接 */
|
|
114
|
+
#wenyan a {
|
|
115
|
+
word-wrap: break-word;
|
|
116
|
+
color: #000000;
|
|
117
|
+
}
|
|
118
|
+
/* 脚注 */
|
|
119
|
+
#wenyan #footnotes ul {
|
|
120
|
+
font-size: 0.9em;
|
|
121
|
+
margin: 0;
|
|
122
|
+
padding-left: 1.2em;
|
|
123
|
+
}
|
|
124
|
+
#wenyan #footnotes li {
|
|
125
|
+
margin: 0 0 0 1.2em;
|
|
126
|
+
word-wrap: break-word;
|
|
127
|
+
word-break: break-all;
|
|
128
|
+
}
|
|
129
|
+
#wenyan .footnote {
|
|
130
|
+
color: #000000;
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
export {
|
|
134
|
+
n as default
|
|
135
|
+
};
|
package/dist/theme.js
CHANGED
|
@@ -1,65 +1,107 @@
|
|
|
1
|
-
const
|
|
1
|
+
const i = [
|
|
2
2
|
{
|
|
3
3
|
id: "default",
|
|
4
4
|
name: "Default",
|
|
5
|
-
description: "A clean, classic layout ideal for long-form reading."
|
|
5
|
+
description: "A clean, classic layout ideal for long-form reading.",
|
|
6
|
+
appName: "默认",
|
|
7
|
+
author: ""
|
|
6
8
|
},
|
|
7
9
|
{
|
|
8
10
|
id: "orangeheart",
|
|
9
11
|
name: "OrangeHeart",
|
|
10
|
-
description: "A vibrant and elegant theme in warm orange tones."
|
|
12
|
+
description: "A vibrant and elegant theme in warm orange tones.",
|
|
13
|
+
appName: "Orange Heart",
|
|
14
|
+
author: "evgo2017"
|
|
11
15
|
},
|
|
12
16
|
{
|
|
13
17
|
id: "rainbow",
|
|
14
18
|
name: "Rainbow",
|
|
15
|
-
description: "A colorful, lively theme with a clean layout."
|
|
19
|
+
description: "A colorful, lively theme with a clean layout.",
|
|
20
|
+
appName: "Rainbow",
|
|
21
|
+
author: "thezbm"
|
|
16
22
|
},
|
|
17
23
|
{
|
|
18
24
|
id: "lapis",
|
|
19
25
|
name: "Lapis",
|
|
20
|
-
description: "A minimal and refreshing theme in cool blue tones."
|
|
26
|
+
description: "A minimal and refreshing theme in cool blue tones.",
|
|
27
|
+
appName: "Lapis",
|
|
28
|
+
author: "YiNN"
|
|
21
29
|
},
|
|
22
30
|
{
|
|
23
31
|
id: "pie",
|
|
24
32
|
name: "Pie",
|
|
25
|
-
description: "Inspired by sspai.com and Misty — modern, sharp, and stylish."
|
|
33
|
+
description: "Inspired by sspai.com and Misty — modern, sharp, and stylish.",
|
|
34
|
+
appName: "Pie",
|
|
35
|
+
author: "kevinzhao2233"
|
|
26
36
|
},
|
|
27
37
|
{
|
|
28
38
|
id: "maize",
|
|
29
39
|
name: "Maize",
|
|
30
|
-
description: "A crisp, light theme with a soft maize palette."
|
|
40
|
+
description: "A crisp, light theme with a soft maize palette.",
|
|
41
|
+
appName: "Maize",
|
|
42
|
+
author: "BEATREE"
|
|
31
43
|
},
|
|
32
44
|
{
|
|
33
45
|
id: "purple",
|
|
34
46
|
name: "Purple",
|
|
35
|
-
description: "Clean and minimalist, with a subtle purple accent."
|
|
47
|
+
description: "Clean and minimalist, with a subtle purple accent.",
|
|
48
|
+
appName: "Purple",
|
|
49
|
+
author: "hliu202"
|
|
36
50
|
},
|
|
37
51
|
{
|
|
38
52
|
id: "phycat",
|
|
39
|
-
name: "
|
|
40
|
-
description: "物理猫-薄荷:a mint-green theme with clear structure and hierarchy."
|
|
53
|
+
name: "Phycat",
|
|
54
|
+
description: "物理猫-薄荷:a mint-green theme with clear structure and hierarchy.",
|
|
55
|
+
appName: "物理猫-薄荷",
|
|
56
|
+
author: "sumruler"
|
|
41
57
|
}
|
|
42
|
-
],
|
|
58
|
+
], a = /* @__PURE__ */ Object.assign({
|
|
43
59
|
"./themes/default.css": () => import("./default-D-dyLptq.js").then((e) => e.default),
|
|
60
|
+
"./themes/juejin_default.css": () => import("./juejin_default-CnUAGV72.js").then((e) => e.default),
|
|
44
61
|
"./themes/lapis.css": () => import("./lapis-dRySN5pK.js").then((e) => e.default),
|
|
45
62
|
"./themes/maize.css": () => import("./maize-DFW0x6O3.js").then((e) => e.default),
|
|
63
|
+
"./themes/medium_default.css": () => import("./medium_default-BXHGUKdY.js").then((e) => e.default),
|
|
46
64
|
"./themes/orangeheart.css": () => import("./orangeheart-Da7uQj8U.js").then((e) => e.default),
|
|
47
65
|
"./themes/phycat.css": () => import("./phycat-BGGT9oBk.js").then((e) => e.default),
|
|
48
66
|
"./themes/pie.css": () => import("./pie-DUYodGli.js").then((e) => e.default),
|
|
49
67
|
"./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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
"./themes/rainbow.css": () => import("./rainbow-BtrbZco6.js").then((e) => e.default),
|
|
69
|
+
"./themes/toutiao_default.css": () => import("./toutiao_default-DthFV93V.js").then((e) => e.default),
|
|
70
|
+
"./themes/zhihu_default.css": () => import("./zhihu_default-7uVAZjKn.js").then((e) => e.default)
|
|
71
|
+
});
|
|
72
|
+
function n(e) {
|
|
73
|
+
const s = `./themes/${e.id}.css`, t = a[s];
|
|
74
|
+
return t ? {
|
|
55
75
|
...e,
|
|
56
76
|
getCss: t
|
|
57
|
-
} : console.warn(`[Themes] CSS file not found for theme: ${e.id}`);
|
|
77
|
+
} : (console.warn(`[Themes] CSS file not found for theme: ${e.id}`), null);
|
|
58
78
|
}
|
|
79
|
+
const r = Object.fromEntries(
|
|
80
|
+
i.map((e) => n(e)).filter((e) => e !== null).map((e) => [e.id, e])
|
|
81
|
+
);
|
|
59
82
|
function o() {
|
|
60
|
-
return Object.values(
|
|
83
|
+
return Object.values(r);
|
|
61
84
|
}
|
|
85
|
+
const m = [
|
|
86
|
+
"juejin_default",
|
|
87
|
+
"medium_default",
|
|
88
|
+
"toutiao_default",
|
|
89
|
+
"zhihu_default"
|
|
90
|
+
], h = Object.fromEntries(
|
|
91
|
+
m.map((e) => [
|
|
92
|
+
e,
|
|
93
|
+
{
|
|
94
|
+
id: e,
|
|
95
|
+
name: "",
|
|
96
|
+
description: "",
|
|
97
|
+
appName: "",
|
|
98
|
+
author: "",
|
|
99
|
+
getCss: a[`./themes/${e}.css`]
|
|
100
|
+
}
|
|
101
|
+
])
|
|
102
|
+
);
|
|
62
103
|
export {
|
|
63
104
|
o as getAllThemes,
|
|
64
|
-
|
|
105
|
+
h as otherThemes,
|
|
106
|
+
r as themes
|
|
65
107
|
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const n = `:root {
|
|
2
|
+
--sans-serif-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
|
|
3
|
+
"Noto Color Emoji";
|
|
4
|
+
--monospace-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace;
|
|
5
|
+
}
|
|
6
|
+
#wenyan {
|
|
7
|
+
font-family: var(--sans-serif-font);
|
|
8
|
+
line-height: 1.75;
|
|
9
|
+
}
|
|
10
|
+
#wenyan * {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
#wenyan h1,
|
|
14
|
+
#wenyan h2,
|
|
15
|
+
#wenyan h3,
|
|
16
|
+
#wenyan h4,
|
|
17
|
+
#wenyan h5,
|
|
18
|
+
#wenyan h6,
|
|
19
|
+
#wenyan p,
|
|
20
|
+
#wenyan pre {
|
|
21
|
+
margin: 1em 0;
|
|
22
|
+
}
|
|
23
|
+
#wenyan h1,
|
|
24
|
+
#wenyan h2,
|
|
25
|
+
#wenyan h3,
|
|
26
|
+
#wenyan h4,
|
|
27
|
+
#wenyan h5,
|
|
28
|
+
#wenyan h6 {
|
|
29
|
+
font-size: 18px;
|
|
30
|
+
line-height: 30px;
|
|
31
|
+
margin-top: 20px;
|
|
32
|
+
margin-bottom: 12px;
|
|
33
|
+
font-weight: 700;
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
#wenyan h1:before,
|
|
37
|
+
#wenyan h2:before,
|
|
38
|
+
#wenyan h3:before,
|
|
39
|
+
#wenyan h4:before,
|
|
40
|
+
#wenyan h5:before,
|
|
41
|
+
#wenyan h6:before {
|
|
42
|
+
content: "";
|
|
43
|
+
display: inline-block;
|
|
44
|
+
vertical-align: 1px;
|
|
45
|
+
width: 16px;
|
|
46
|
+
height: 20px;
|
|
47
|
+
margin-right: 6px;
|
|
48
|
+
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDYwLjEgKDg4MTMzKSAtIGh0dHBzOi8vc2tldGNoLmNvbSAtLT4KICAgIDx0aXRsZT7kuInop5LlvaI8L3RpdGxlPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZyBpZD0i5LiJ6KeS5b2iIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8cGF0aCBkPSJNNi4zNTc0OTI5Myw0LjQyOTE1NDg4IEwxMC41OTEzMDI1LDExLjQ4NTUwNDIgQzEwLjg3NTQ1MDcsMTEuOTU5MDg0NSAxMC43MjE4ODU2LDEyLjU3MzM0NDggMTAuMjQ4MzA1NCwxMi44NTc0OTI5IEMxMC4wOTI4OSwxMi45NTA3NDIyIDkuOTE1MDUzNTcsMTMgOS43MzM4MDk2MiwxMyBMMS4yNjYxOTAzOCwxMyBDMC43MTM5MDU2MjksMTMgMC4yNjYxOTAzNzksMTIuNTUyMjg0NyAwLjI2NjE5MDM3OSwxMiBDMC4yNjYxOTAzNzksMTEuODE4NzU2MSAwLjMxNTQ0ODIxMiwxMS42NDA5MTk2IDAuNDA4Njk3NDUzLDExLjQ4NTUwNDIgTDQuNjQyNTA3MDcsNC40MjkxNTQ4OCBDNC45MjY2NTUyMywzLjk1NTU3NDYxIDUuNTQwOTE1NDksMy44MDIwMDk1NSA2LjAxNDQ5NTc2LDQuMDg2MTU3NzEgQzYuMTU1MjQ1MzYsNC4xNzA2MDc0NyA2LjI3MzA0MzE2LDQuMjg4NDA1MjcgNi4zNTc0OTI5Myw0LjQyOTE1NDg4IFoiIGZpbGw9IiNGRjVFNUUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDUuNTAwMDAwLCA4LjAwMDAwMCkgcm90YXRlKC0yNzAuMDAwMDAwKSB0cmFuc2xhdGUoLTUuNTAwMDAwLCAtOC4wMDAwMDApICI+PC9wYXRoPgogICAgPC9nPgo8L3N2Zz4=);
|
|
49
|
+
background-repeat: no-repeat;
|
|
50
|
+
background-size: 16px 16px;
|
|
51
|
+
background-position-y: 6px;
|
|
52
|
+
}
|
|
53
|
+
#wenyan ul,
|
|
54
|
+
#wenyan ol {
|
|
55
|
+
padding-left: 1.2em;
|
|
56
|
+
}
|
|
57
|
+
#wenyan li {
|
|
58
|
+
margin-left: 1.2em;
|
|
59
|
+
}
|
|
60
|
+
#wenyan img {
|
|
61
|
+
max-width: 100%;
|
|
62
|
+
height: auto;
|
|
63
|
+
margin: 0 auto;
|
|
64
|
+
display: block;
|
|
65
|
+
}
|
|
66
|
+
#wenyan table {
|
|
67
|
+
margin-left: auto;
|
|
68
|
+
margin-right: auto;
|
|
69
|
+
border-collapse: collapse;
|
|
70
|
+
table-layout: fixed;
|
|
71
|
+
overflow: auto;
|
|
72
|
+
border-spacing: 0;
|
|
73
|
+
font-size: 1em;
|
|
74
|
+
word-wrap: break-word;
|
|
75
|
+
word-break: break-all;
|
|
76
|
+
}
|
|
77
|
+
#wenyan table td,
|
|
78
|
+
#wenyan table th {
|
|
79
|
+
height: 40px;
|
|
80
|
+
padding: 9px 12px;
|
|
81
|
+
line-height: 22px;
|
|
82
|
+
color: #222;
|
|
83
|
+
min-width: 88px;
|
|
84
|
+
border: 1px solid #d8d8d8;
|
|
85
|
+
vertical-align: top;
|
|
86
|
+
}
|
|
87
|
+
#wenyan blockquote {
|
|
88
|
+
margin: 0;
|
|
89
|
+
margin-bottom: 20px;
|
|
90
|
+
padding: 0 16px;
|
|
91
|
+
position: relative;
|
|
92
|
+
color: #999;
|
|
93
|
+
text-align: justify;
|
|
94
|
+
}
|
|
95
|
+
#wenyan blockquote:before {
|
|
96
|
+
content: " ";
|
|
97
|
+
left: 0;
|
|
98
|
+
position: absolute;
|
|
99
|
+
width: 2px;
|
|
100
|
+
height: 100%;
|
|
101
|
+
background: #f2f2f2;
|
|
102
|
+
}
|
|
103
|
+
#wenyan p code {
|
|
104
|
+
font-family: var(--monospace-font);
|
|
105
|
+
color: #1e6bb8;
|
|
106
|
+
}
|
|
107
|
+
/* 代码块 */
|
|
108
|
+
#wenyan pre {
|
|
109
|
+
border-radius: 3px;
|
|
110
|
+
border: 1px solid #e8e8e8;
|
|
111
|
+
line-height: 2;
|
|
112
|
+
margin: 1em 0.5em;
|
|
113
|
+
padding: .5em;
|
|
114
|
+
}
|
|
115
|
+
#wenyan pre code {
|
|
116
|
+
font-family: var(--monospace-font);
|
|
117
|
+
display: block;
|
|
118
|
+
overflow-x: auto;
|
|
119
|
+
margin: .5em;
|
|
120
|
+
padding: 0;
|
|
121
|
+
}
|
|
122
|
+
#wenyan hr {
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 1px;
|
|
125
|
+
background-color: #e8e8e8;
|
|
126
|
+
border: none;
|
|
127
|
+
margin: 20px 0;
|
|
128
|
+
}
|
|
129
|
+
/* 链接 */
|
|
130
|
+
#wenyan a {
|
|
131
|
+
word-wrap: break-word;
|
|
132
|
+
color: #0069c2;
|
|
133
|
+
}
|
|
134
|
+
/* 脚注 */
|
|
135
|
+
#wenyan #footnotes ul {
|
|
136
|
+
font-size: 0.9em;
|
|
137
|
+
margin: 0;
|
|
138
|
+
padding-left: 1.2em;
|
|
139
|
+
}
|
|
140
|
+
#wenyan #footnotes li {
|
|
141
|
+
margin: 0 0 0 1.2em;
|
|
142
|
+
word-wrap: break-word;
|
|
143
|
+
word-break: break-all;
|
|
144
|
+
}
|
|
145
|
+
#wenyan .footnote {
|
|
146
|
+
color: #0069c2;
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
export {
|
|
150
|
+
n as default
|
|
151
|
+
};
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ export type Theme = {
|
|
|
2
2
|
id: string;
|
|
3
3
|
name: string;
|
|
4
4
|
description: string;
|
|
5
|
+
appName: string;
|
|
6
|
+
author: string;
|
|
5
7
|
getCss: () => Promise<string>;
|
|
6
8
|
};
|
|
7
9
|
export declare const themes: Record<string, Theme>;
|
|
8
10
|
export declare function getAllThemes(): Theme[];
|
|
11
|
+
export declare const otherThemes: Record<string, Theme>;
|
package/dist/wrapper.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSDOM as a } from "jsdom";
|
|
2
|
-
import { configureMarked as
|
|
3
|
-
async function f(n,
|
|
4
|
-
|
|
5
|
-
const t =
|
|
2
|
+
import { configureMarked as m, handleFrontMatter as s, renderMarkdown as w, getContentForGzhBuiltinTheme as l } from "./core.js";
|
|
3
|
+
async function f(n, e, o, r) {
|
|
4
|
+
m();
|
|
5
|
+
const t = s(n), c = await w(t.body), d = new a(`<body><section id="wenyan">${c}</section></body>`).window.document.getElementById("wenyan"), i = await l(d, e, o, r);
|
|
6
6
|
return {
|
|
7
7
|
title: t.title,
|
|
8
8
|
cover: t.cover,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const n = `:root {
|
|
2
|
+
--sans-serif-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
|
|
3
|
+
"Noto Color Emoji";
|
|
4
|
+
--monospace-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace;
|
|
5
|
+
}
|
|
6
|
+
#wenyan {
|
|
7
|
+
font-family: var(--sans-serif-font);
|
|
8
|
+
line-height: 1.75;
|
|
9
|
+
font-size: 16px;
|
|
10
|
+
}
|
|
11
|
+
#wenyan * {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
#wenyan h1,
|
|
15
|
+
#wenyan h2,
|
|
16
|
+
#wenyan h3,
|
|
17
|
+
#wenyan h4,
|
|
18
|
+
#wenyan h5,
|
|
19
|
+
#wenyan h6,
|
|
20
|
+
#wenyan p,
|
|
21
|
+
#wenyan pre {
|
|
22
|
+
margin: 1em 0;
|
|
23
|
+
}
|
|
24
|
+
#wenyan h1,
|
|
25
|
+
#wenyan h2 {
|
|
26
|
+
clear: left;
|
|
27
|
+
font-size: 1.2em;
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
line-height: 1.5;
|
|
30
|
+
margin-bottom: 1.16667em;
|
|
31
|
+
margin-top: 2.33333em;
|
|
32
|
+
}
|
|
33
|
+
#wenyan h3,
|
|
34
|
+
#wenyan h4,
|
|
35
|
+
#wenyan h5,
|
|
36
|
+
#wenyan h6 {
|
|
37
|
+
clear: left;
|
|
38
|
+
font-size: 1.1em;
|
|
39
|
+
font-weight: 600;
|
|
40
|
+
line-height: 1.5;
|
|
41
|
+
margin-bottom: 1.27273em;
|
|
42
|
+
margin-top: 1.90909em;
|
|
43
|
+
}
|
|
44
|
+
#wenyan ul,
|
|
45
|
+
#wenyan ol {
|
|
46
|
+
padding-left: 1.2em;
|
|
47
|
+
}
|
|
48
|
+
#wenyan li {
|
|
49
|
+
margin-left: 1.2em;
|
|
50
|
+
}
|
|
51
|
+
#wenyan img {
|
|
52
|
+
max-width: 100%;
|
|
53
|
+
height: auto;
|
|
54
|
+
margin: 0 auto;
|
|
55
|
+
display: block;
|
|
56
|
+
}
|
|
57
|
+
#wenyan table {
|
|
58
|
+
border-collapse: collapse;
|
|
59
|
+
font-size: 15px;
|
|
60
|
+
margin: 1.4em auto;
|
|
61
|
+
max-width: 100%;
|
|
62
|
+
table-layout: fixed;
|
|
63
|
+
text-align: left;
|
|
64
|
+
width: 100%;
|
|
65
|
+
word-wrap: break-word;
|
|
66
|
+
word-break: break-all;
|
|
67
|
+
}
|
|
68
|
+
#wenyan table th {
|
|
69
|
+
background: #ebeced;
|
|
70
|
+
color: #191b1f;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
}
|
|
73
|
+
#wenyan table td,
|
|
74
|
+
#wenyan table th {
|
|
75
|
+
border: 1px solid #c4c7ce;
|
|
76
|
+
height: 24px;
|
|
77
|
+
line-height: 24px;
|
|
78
|
+
padding: 3px 12px;
|
|
79
|
+
}
|
|
80
|
+
#wenyan blockquote {
|
|
81
|
+
border-left: 3px solid #c4c7ce;
|
|
82
|
+
margin: 1.5em 0;
|
|
83
|
+
padding: 0 0 1em 1em;
|
|
84
|
+
color: #535861;
|
|
85
|
+
}
|
|
86
|
+
#wenyan code {
|
|
87
|
+
margin: 0px 2px;
|
|
88
|
+
padding: 3px 4px;
|
|
89
|
+
border-radius: 3px;
|
|
90
|
+
font-family: var(--monospace-font);
|
|
91
|
+
background-color: rgb(246, 246, 246);
|
|
92
|
+
}
|
|
93
|
+
#wenyan pre {
|
|
94
|
+
word-wrap: normal;
|
|
95
|
+
background: #f8f8fa;
|
|
96
|
+
border-radius: 4px;
|
|
97
|
+
line-height: 2;
|
|
98
|
+
margin: 1em 0.5em;
|
|
99
|
+
padding: .5em;
|
|
100
|
+
white-space: pre;
|
|
101
|
+
word-break: normal;
|
|
102
|
+
}
|
|
103
|
+
#wenyan pre code {
|
|
104
|
+
display: block;
|
|
105
|
+
overflow-x: auto;
|
|
106
|
+
margin: .5em;
|
|
107
|
+
padding: 0;
|
|
108
|
+
}
|
|
109
|
+
#wenyan hr {
|
|
110
|
+
border: none;
|
|
111
|
+
border-top: 1px solid #c4c7ce;
|
|
112
|
+
margin: 2em auto;
|
|
113
|
+
max-width: 100%;
|
|
114
|
+
width: 240px;
|
|
115
|
+
}
|
|
116
|
+
/* 链接 */
|
|
117
|
+
#wenyan a {
|
|
118
|
+
word-wrap: break-word;
|
|
119
|
+
color: #0069c2;
|
|
120
|
+
}
|
|
121
|
+
/* 脚注 */
|
|
122
|
+
#wenyan #footnotes ul {
|
|
123
|
+
font-size: 0.9em;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding-left: 1.2em;
|
|
126
|
+
}
|
|
127
|
+
#wenyan #footnotes li {
|
|
128
|
+
margin: 0 0 0 1.2em;
|
|
129
|
+
word-wrap: break-word;
|
|
130
|
+
word-break: break-all;
|
|
131
|
+
}
|
|
132
|
+
#wenyan .footnote {
|
|
133
|
+
color: #0069c2;
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
export {
|
|
137
|
+
n as default
|
|
138
|
+
};
|
package/package.json
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenyan-md/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|
|
7
|
-
"keywords": [
|
|
7
|
+
"keywords": [
|
|
8
|
+
"公众号",
|
|
9
|
+
"markdown",
|
|
10
|
+
"文颜",
|
|
11
|
+
"wenyan",
|
|
12
|
+
"wechat",
|
|
13
|
+
"publishing",
|
|
14
|
+
"renderer"
|
|
15
|
+
],
|
|
8
16
|
"type": "module",
|
|
9
17
|
"files": [
|
|
10
18
|
"dist"
|
|
11
19
|
],
|
|
12
|
-
"main": "./dist/core.js",
|
|
13
|
-
"module": "./dist/core.js",
|
|
14
20
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"./
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/core.js",
|
|
23
|
+
"browser": "./dist/browser/wenyan-core.js"
|
|
24
|
+
},
|
|
25
|
+
"./publish": {
|
|
26
|
+
"import": "./dist/publish.js",
|
|
27
|
+
"types": "./dist/types/publish.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./wrapper": {
|
|
30
|
+
"import": "./dist/wrapper.js",
|
|
31
|
+
"types": "./dist/types/wrapper.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./theme": {
|
|
34
|
+
"import": "./dist/theme.js",
|
|
35
|
+
"types": "./dist/types/theme.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./hltheme": {
|
|
38
|
+
"import": "./dist/hltheme.js",
|
|
39
|
+
"types": "./dist/types/hltheme.d.ts"
|
|
40
|
+
}
|
|
28
41
|
},
|
|
29
|
-
"packageManager": "pnpm@10.7.1",
|
|
30
42
|
"devDependencies": {
|
|
31
43
|
"@types/css-tree": "^2.3.10",
|
|
32
44
|
"@types/jsdom": "^21.1.7",
|
|
@@ -45,5 +57,14 @@
|
|
|
45
57
|
"marked": "^15.0.12",
|
|
46
58
|
"marked-highlight": "^2.2.1",
|
|
47
59
|
"mathjax-full": "^3.2.2"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"dev": "vite build --watch",
|
|
63
|
+
"build": "vite build && tsc",
|
|
64
|
+
"build:browser": "vite build --config vite.config.browser.ts",
|
|
65
|
+
"build:all": "pnpm build && pnpm build:browser",
|
|
66
|
+
"test:main": "pnpm build && vitest run main.test.js",
|
|
67
|
+
"test:wrapper": "pnpm build && vitest run wrapper.test.js",
|
|
68
|
+
"test:publish": "pnpm build && vitest run publish.test.js"
|
|
48
69
|
}
|
|
49
|
-
}
|
|
70
|
+
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|