@wenyan-md/core 1.0.17 → 2.0.0

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.
Files changed (39) hide show
  1. package/README.md +19 -169
  2. package/dist/core.js +1060 -416
  3. package/dist/publish.js +64 -66
  4. package/dist/types/core/hlThemeRegistry.d.ts +8 -0
  5. package/dist/types/core/index.d.ts +29 -0
  6. package/dist/types/core/parser/cssParser.d.ts +11 -0
  7. package/dist/types/core/parser/frontMatterParser.d.ts +7 -0
  8. package/dist/types/core/parser/markedParser.d.ts +6 -0
  9. package/dist/types/core/parser/mathjaxParser.d.ts +8 -0
  10. package/dist/types/core/renderer/footnotesRender.d.ts +1 -0
  11. package/dist/types/core/renderer/highlightApplyRender.d.ts +1 -0
  12. package/dist/types/core/renderer/macStyleRender.d.ts +3 -0
  13. package/dist/types/core/renderer/pseudoApplyRender.d.ts +1 -0
  14. package/dist/types/core/renderer/themeApplyRender.d.ts +1 -0
  15. package/dist/types/core/renderer/wechatPostRender.d.ts +1 -0
  16. package/dist/types/core/themeRegistry.d.ts +16 -0
  17. package/dist/types/core/types.d.ts +10 -0
  18. package/dist/types/core/utils.d.ts +6 -0
  19. package/dist/types/node/wrapper.d.ts +9 -0
  20. package/dist/types/wechat/adapters/browser.d.ts +2 -0
  21. package/dist/types/wechat/adapters/node.d.ts +2 -0
  22. package/dist/types/wechat/core.d.ts +6 -0
  23. package/dist/types/wechat/http.d.ts +12 -0
  24. package/dist/wrapper.js +17 -8
  25. package/package.json +30 -23
  26. package/dist/browser/wenyan-core.js +0 -94
  27. package/dist/hltheme.js +0 -70
  28. package/dist/math/wenyan-math.js +0 -19
  29. package/dist/styles/wenyan-styles.js +0 -2232
  30. package/dist/theme.js +0 -461
  31. package/dist/types/core.d.ts +0 -17
  32. package/dist/types/hltheme.d.ts +0 -6
  33. package/dist/types/theme.d.ts +0 -11
  34. package/dist/types/utils.d.ts +0 -1
  35. package/dist/types/wechatApi.d.ts +0 -8
  36. package/dist/types/wrapper.d.ts +0 -7
  37. package/dist/utils-YieK94fG.js +0 -9
  38. /package/dist/types/{runtimeEnv.d.ts → node/runtimeEnv.d.ts} +0 -0
  39. /package/dist/types/{publish.d.ts → wechat/publish.d.ts} +0 -0
package/dist/core.js CHANGED
@@ -1,157 +1,22 @@
1
- import { marked } from "marked";
2
- import { markedHighlight } from "marked-highlight";
3
- import hljs from "highlight.js";
4
1
  import fm from "front-matter";
5
2
  import * as csstree from "css-tree";
3
+ import { Marked } from "marked";
4
+ import { markedHighlight } from "marked-highlight";
5
+ import hljs from "highlight.js";
6
6
  import { mathjax } from "mathjax-full/js/mathjax.js";
7
7
  import { TeX } from "mathjax-full/js/input/tex.js";
8
8
  import { SVG } from "mathjax-full/js/output/svg.js";
9
9
  import { liteAdaptor } from "mathjax-full/js/adaptors/liteAdaptor.js";
10
10
  import { RegisterHTMLHandler } from "mathjax-full/js/handlers/html.js";
11
11
  import { AllPackages } from "mathjax-full/js/input/tex/AllPackages.js";
12
- import { themes } from "./theme.js";
13
- import { hlThemes } from "./hltheme.js";
14
- const texConfig = {
15
- inlineMath: [
16
- ["$", "$"],
17
- ["\\(", "\\)"]
18
- ],
19
- displayMath: [
20
- ["$$", "$$"],
21
- ["\\[", "\\]"]
22
- ],
23
- processEscapes: true,
24
- packages: AllPackages
25
- };
26
- const svgConfig = {
27
- fontCache: "none"
28
- };
29
- let adaptor;
30
- if (!adaptor) {
31
- adaptor = liteAdaptor();
32
- try {
33
- RegisterHTMLHandler(adaptor);
34
- } catch (e) {
35
- }
36
- }
37
- RegisterHTMLHandler(adaptor);
38
- const tex = new TeX(texConfig);
39
- const svg = new SVG(svgConfig);
40
- function addContainer(math, doc) {
41
- const tag = math.display ? "section" : "span";
42
- const cls = math.display ? "block-equation" : "inline-equation";
43
- const container = math.typesetRoot;
44
- if (math.math) {
45
- doc.adaptor.setAttribute(container, "math", math.math);
46
- }
47
- const node = doc.adaptor.node(tag, { class: cls }, [container]);
48
- math.typesetRoot = node;
49
- }
50
- async function renderMathInHtml(htmlString) {
51
- try {
52
- const html = mathjax.document(htmlString, {
53
- InputJax: tex,
54
- OutputJax: svg,
55
- renderActions: {
56
- addContainer: [
57
- 190,
58
- (doc) => {
59
- for (const math of doc.math) {
60
- addContainer(math, doc);
61
- }
62
- },
63
- addContainer
64
- ]
65
- }
66
- });
67
- html.render();
68
- const body = adaptor.body(html.document);
69
- return adaptor.innerHTML(body);
70
- } catch (error) {
71
- console.error("Error rendering MathJax:", error);
72
- throw error;
73
- }
74
- }
75
- const macStyleCss = `#wenyan pre::before {
76
- display: block;
77
- content: "";
78
- 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>');
79
- background-repeat: no-repeat;
80
- width: 100%;
81
- height: 16px;
82
- }`;
83
12
  const serif = "Georgia, Cambria, 'Noto Serif', 'Times New Roman', serif";
84
13
  const sansSerif = "system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', 'Roboto', sans-serif";
85
14
  const monospace = "Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace";
86
- let markedConfigured = false;
87
- let configurePromise = null;
88
- async function configureMarked() {
89
- if (markedConfigured) return;
90
- if (configurePromise) return configurePromise;
91
- configurePromise = (async () => {
92
- const highlightExtension = markedHighlight({
93
- emptyLangClass: "hljs",
94
- langPrefix: "hljs language-",
95
- highlight: function(code, lang, info) {
96
- const language = hljs.getLanguage(lang) ? lang : "plaintext";
97
- return hljs.highlight(code, { language }).value;
98
- }
99
- });
100
- marked.use(highlightExtension);
101
- const attributeImageExtension = {
102
- name: "attributeImage",
103
- level: "inline",
104
- start(src) {
105
- return src.indexOf("![");
106
- },
107
- tokenizer(src) {
108
- const rule = /^!\[([^\]]*)\]\(([^)]+)\)\{(.*?)\}/;
109
- const match = rule.exec(src);
110
- if (match) {
111
- return {
112
- type: "attributeImage",
113
- raw: match[0],
114
- alt: match[1],
115
- href: match[2],
116
- attrs: match[3]
117
- };
118
- }
119
- },
120
- renderer(token) {
121
- const attrs = stringToMap(token.attrs);
122
- const attrStr = Array.from(attrs).map(
123
- ([k, v]) => /^\d+$/.test(v) ? `${k}:${v}px` : `${k}:${v}`
124
- ).join("; ");
125
- return `<img src="${token.href}" alt="${token.alt || ""}" title="${token.alt || ""}" style="${attrStr}">`;
126
- }
127
- };
128
- marked.use({ extensions: [attributeImageExtension] });
129
- const renderer = marked.Renderer;
130
- const parser = marked.Parser;
131
- renderer.heading = function(heading) {
132
- const text = parser.parseInline(heading.tokens);
133
- const level = heading.depth;
134
- return `<h${level}><span>${text}</span></h${level}>
135
- `;
136
- };
137
- renderer.paragraph = function(paragraph) {
138
- const text = paragraph.text;
139
- if (text.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(text) || /\\\[[\s\S]*?\\\]/g.test(text))) {
140
- return `${text}
141
- `;
142
- } else {
143
- return `<p>${parser.parseInline(paragraph.tokens)}</p>
144
- `;
145
- }
146
- };
147
- renderer.image = function(token, title, text) {
148
- const src = token.href;
149
- return `<img src="${src}" alt="${token.text || ""}" title="${token.text || ""}">`;
150
- };
151
- marked.use({ renderer });
152
- markedConfigured = true;
153
- })();
154
- return configurePromise;
15
+ function normalizeCssLoader(loaderOrContent) {
16
+ if (typeof loaderOrContent === "string") {
17
+ return () => Promise.resolve(loaderOrContent);
18
+ }
19
+ return loaderOrContent;
155
20
  }
156
21
  function stringToMap(str) {
157
22
  const map = /* @__PURE__ */ new Map();
@@ -163,174 +28,6 @@ function stringToMap(str) {
163
28
  });
164
29
  return map;
165
30
  }
166
- async function handleFrontMatter(markdown) {
167
- const { attributes, body } = fm(markdown);
168
- const result = {};
169
- let head = "";
170
- const { title, description, cover } = attributes;
171
- if (title) {
172
- result.title = title;
173
- }
174
- if (description) {
175
- head += "> " + description + "\n\n";
176
- result.description = description;
177
- }
178
- if (cover) {
179
- result.cover = cover;
180
- }
181
- result.body = head + body;
182
- return result;
183
- }
184
- async function renderMarkdown(content) {
185
- await configureMarked();
186
- const html = marked.parse(content);
187
- const htmlWithMath = await renderMathInHtml(html);
188
- return htmlWithMath;
189
- }
190
- async function getContentForGzhBuiltinTheme(wenyanElement, themeId, hlThemeId, isMacStyle = true, isAddFootnote = true) {
191
- let theme = themes["default"];
192
- if (themeId) {
193
- theme = themes[themeId];
194
- if (!theme) {
195
- theme = Object.values(themes).find(
196
- (t) => t.name.toLowerCase() === themeId.toLowerCase()
197
- );
198
- }
199
- }
200
- if (!theme) {
201
- throw new Error("主题不存在");
202
- }
203
- if (!(hlThemeId in hlThemes)) {
204
- throw new Error("代码块主题不存在");
205
- }
206
- const customCss = replaceCSSVariables(await theme.getCss());
207
- const hlTheme = hlThemes[hlThemeId];
208
- const highlightCss = await hlTheme.getCss();
209
- return getContentForGzhCustomCss(wenyanElement, customCss, highlightCss, isMacStyle, isAddFootnote);
210
- }
211
- async function getContentForGzhCustomCss(wenyanElement, customCss, highlightCss, isMacStyle = true, isAddFootnote = true) {
212
- if (isAddFootnote) {
213
- addFootnotes(false, wenyanElement);
214
- }
215
- customCss = modifyCss(customCss, {
216
- "#wenyan pre code": [
217
- {
218
- property: "font-family",
219
- value: monospace,
220
- append: true
221
- }
222
- ],
223
- "#wenyan pre": [
224
- {
225
- property: "font-size",
226
- value: "12px",
227
- append: true
228
- }
229
- ]
230
- });
231
- const ast = csstree.parse(customCss, {
232
- context: "stylesheet",
233
- positions: false,
234
- parseAtrulePrelude: false,
235
- parseCustomProperty: false,
236
- parseValue: false
237
- });
238
- const ast1 = csstree.parse(highlightCss, {
239
- context: "stylesheet",
240
- positions: false,
241
- parseAtrulePrelude: false,
242
- parseCustomProperty: false,
243
- parseValue: false
244
- });
245
- ast.children.appendList(ast1.children);
246
- if (isMacStyle) {
247
- const ast2 = csstree.parse(macStyleCss, {
248
- context: "stylesheet",
249
- positions: false,
250
- parseAtrulePrelude: false,
251
- parseCustomProperty: false,
252
- parseValue: false
253
- });
254
- ast.children.appendList(ast2.children);
255
- }
256
- csstree.walk(ast, {
257
- visit: "Rule",
258
- enter(node, item, list) {
259
- const selectorList = node.prelude.children;
260
- if (selectorList) {
261
- selectorList.forEach((selectorNode) => {
262
- const selector = csstree.generate(selectorNode);
263
- const declarations = node.block.children.toArray();
264
- if (selector === "#wenyan") {
265
- declarations.forEach((decl) => {
266
- const value = csstree.generate(decl.value);
267
- wenyanElement.style[decl.property] = value;
268
- });
269
- } else {
270
- const elements2 = wenyanElement.querySelectorAll(selector);
271
- elements2.forEach((element) => {
272
- declarations.forEach((decl) => {
273
- const value = csstree.generate(decl.value);
274
- element.style[decl.property] = value;
275
- });
276
- });
277
- }
278
- });
279
- }
280
- }
281
- });
282
- let elements = wenyanElement.querySelectorAll("mjx-container");
283
- elements.forEach((element) => {
284
- const svg2 = element.querySelector("svg");
285
- svg2.style.width = svg2.getAttribute("width");
286
- svg2.style.height = svg2.getAttribute("height");
287
- svg2.removeAttribute("width");
288
- svg2.removeAttribute("height");
289
- const parent = element.parentElement;
290
- element.remove();
291
- parent.appendChild(svg2);
292
- if (parent.classList.contains("block-equation")) {
293
- parent.setAttribute("style", "text-align: center; margin-bottom: 1rem;");
294
- }
295
- });
296
- elements = wenyanElement.querySelectorAll("pre code");
297
- elements.forEach((element) => {
298
- element.innerHTML = element.innerHTML.replace(/\n/g, "<br>").replace(/(>[^<]+)|(^[^<]+)/g, (str) => str.replace(/\s/g, "&nbsp;"));
299
- });
300
- elements = wenyanElement.querySelectorAll("h1, h2, h3, h4, h5, h6, blockquote, pre");
301
- elements.forEach((element) => {
302
- const afterResults = /* @__PURE__ */ new Map();
303
- const beforeResults = /* @__PURE__ */ new Map();
304
- csstree.walk(ast, {
305
- visit: "Rule",
306
- enter(node) {
307
- const selector = csstree.generate(node.prelude);
308
- const tagName = element.tagName.toLowerCase();
309
- if (selector.includes(`${tagName}::after`)) {
310
- extractDeclarations(node, afterResults);
311
- } else if (selector.includes(`${tagName}::before`)) {
312
- extractDeclarations(node, beforeResults);
313
- }
314
- }
315
- });
316
- if (afterResults.size > 0) {
317
- element.appendChild(buildPseudoSpan(afterResults, wenyanElement.ownerDocument));
318
- }
319
- if (beforeResults.size > 0) {
320
- element.insertBefore(buildPseudoSpan(beforeResults, wenyanElement.ownerDocument), element.firstChild);
321
- }
322
- });
323
- elements = wenyanElement.querySelectorAll("li");
324
- elements.forEach((li) => {
325
- const section = wenyanElement.ownerDocument.createElement("section");
326
- while (li.firstChild) {
327
- section.appendChild(li.firstChild);
328
- }
329
- li.appendChild(section);
330
- });
331
- wenyanElement.setAttribute("data-provider", "WenYan");
332
- return `${wenyanElement.outerHTML.replace(/class="mjx-solid"/g, 'fill="none" stroke-width="70"').replace(/\n<li/g, "<li").replace(/<\/li>\n/g, "</li>")}`;
333
- }
334
31
  function replaceCSSVariables(css) {
335
32
  const variablePattern = /--([a-zA-Z0-9\-]+):\s*([^;()]*\((?:[^()]*|\([^()]*\))*\)[^;()]*|[^;]+);/g;
336
33
  const varPattern = /var\(--([a-zA-Z0-9\-]+)\)/g;
@@ -351,159 +48,1106 @@ function replaceCSSVariables(css) {
351
48
  if (resolved.has(value)) return value;
352
49
  resolved.add(value);
353
50
  let resolvedValue = value;
354
- let match2;
355
- while ((match2 = varPattern.exec(resolvedValue)) !== null) {
356
- const varName = match2[1];
51
+ const innerVarPattern = /var\(--([a-zA-Z0-9\-]+)\)/g;
52
+ resolvedValue = resolvedValue.replace(innerVarPattern, (match2, varName) => {
357
53
  if (variables[varName]) {
358
- const resolvedVar = resolveVariable(variables[varName], variables, resolved);
359
- resolvedValue = resolvedValue.replace(match2[0], resolvedVar);
54
+ return resolveVariable(variables[varName], variables, resolved);
360
55
  }
361
- }
56
+ return match2;
57
+ });
362
58
  return resolvedValue;
363
59
  }
364
60
  for (const key in cssVariables) {
365
61
  const resolvedValue = resolveVariable(cssVariables[key], cssVariables);
366
62
  cssVariables[key] = resolvedValue;
367
63
  }
368
- let modifiedCSS = css;
369
- while ((match = varPattern.exec(css)) !== null) {
370
- const varName = match[1];
64
+ let modifiedCSS = css.replace(varPattern, (match2, varName) => {
371
65
  if (cssVariables[varName]) {
372
- modifiedCSS = modifiedCSS.replace(match[0], cssVariables[varName]);
66
+ return cssVariables[varName];
373
67
  }
374
- }
68
+ return match2;
69
+ });
375
70
  return modifiedCSS.replace(/:root\s*\{[^}]*\}/g, "");
376
71
  }
377
- function modifyCss(customCss, updates) {
378
- const ast = csstree.parse(customCss, {
379
- context: "stylesheet",
380
- positions: false,
381
- parseAtrulePrelude: false,
382
- parseCustomProperty: false,
383
- parseValue: false
72
+ const __vite_glob_0_0$1 = "pre{background:#282c34}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}";
73
+ const __vite_glob_0_1$1 = "pre{background:#fafafa}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#383a42;background:#fafafa}.hljs-comment,.hljs-quote{color:#a0a1a7;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#a626a4}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e45649}.hljs-literal{color:#0184bb}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#50a14f}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#986801}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#4078f2}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#c18401}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}";
74
+ const __vite_glob_0_2$1 = "pre{background:#282936}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#e9e9f4;background:#282936}.hljs ::selection,.hljs::selection{background-color:#4d4f68;color:#e9e9f4}.hljs-comment{color:#626483}.hljs-tag{color:#62d6e8}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#e9e9f4}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#ea51b2}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#b45bcf}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#00f769}.hljs-strong{font-weight:700;color:#00f769}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#ebff87}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#a1efe4}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#62d6e8}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#b45bcf}.hljs-emphasis{color:#b45bcf;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#00f769}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}\n";
75
+ const __vite_glob_0_3$1 = "pre{background:#0d1117}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}\n";
76
+ const __vite_glob_0_4$1 = "pre{background:#fff}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}\n";
77
+ const __vite_glob_0_5$1 = "pre{background:#272822}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#272822;color:#ddd}.hljs-keyword,.hljs-literal,.hljs-name,.hljs-number,.hljs-selector-tag,.hljs-strong,.hljs-tag{color:#f92672}.hljs-code{color:#66d9ef}.hljs-attr,.hljs-attribute,.hljs-link,.hljs-regexp,.hljs-symbol{color:#bf79db}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-emphasis,.hljs-section,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-string,.hljs-subst,.hljs-template-tag,.hljs-template-variable,.hljs-title,.hljs-type,.hljs-variable{color:#a6e22e}.hljs-class .hljs-title,.hljs-title.class_{color:#fff}.hljs-comment,.hljs-deletion,.hljs-meta,.hljs-quote{color:#75715e}.hljs-doctag,.hljs-keyword,.hljs-literal,.hljs-section,.hljs-selector-id,.hljs-selector-tag,.hljs-title,.hljs-type{font-weight:700}";
78
+ const __vite_glob_0_6$1 = "pre{background:#002b36}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#93a1a1;background:#002b36}.hljs ::selection,.hljs::selection{background-color:#586e75;color:#93a1a1}.hljs-comment{color:#657b83}.hljs-tag{color:#839496}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#93a1a1}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#dc322f}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#cb4b16}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#b58900}.hljs-strong{font-weight:700;color:#b58900}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#859900}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#2aa198}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#268bd2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#6c71c4}.hljs-emphasis{color:#6c71c4;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#d33682}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}\n";
79
+ const __vite_glob_0_7$1 = "pre{background:#fdf6e3}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#586e75;background:#fdf6e3}.hljs ::selection,.hljs::selection{background-color:#93a1a1;color:#586e75}.hljs-comment{color:#839496}.hljs-tag{color:#657b83}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#586e75}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#dc322f}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#cb4b16}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#b58900}.hljs-strong{font-weight:700;color:#b58900}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#859900}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#2aa198}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#268bd2}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#6c71c4}.hljs-emphasis{color:#6c71c4;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#d33682}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}\n";
80
+ const __vite_glob_0_8$1 = "pre{background:#fff}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#fff;color:#000}.xml .hljs-meta{color:silver}.hljs-comment,.hljs-quote{color:#007400}.hljs-attribute,.hljs-keyword,.hljs-literal,.hljs-name,.hljs-selector-tag,.hljs-tag{color:#aa0d91}.hljs-template-variable,.hljs-variable{color:#3f6e74}.hljs-code,.hljs-meta .hljs-string,.hljs-string{color:#c41a16}.hljs-link,.hljs-regexp{color:#0e0eff}.hljs-bullet,.hljs-number,.hljs-symbol,.hljs-title{color:#1c00cf}.hljs-meta,.hljs-section{color:#643820}.hljs-built_in,.hljs-class .hljs-title,.hljs-params,.hljs-title.class_,.hljs-type{color:#5c2699}.hljs-attr{color:#836c28}.hljs-subst{color:#000}.hljs-formula{background-color:#eee;font-style:italic}.hljs-addition{background-color:#baeeba}.hljs-deletion{background-color:#ffc8bd}.hljs-selector-class,.hljs-selector-id{color:#9b703f}.hljs-doctag,.hljs-strong{font-weight:700}.hljs-emphasis{font-style:italic}";
81
+ const registry$1 = /* @__PURE__ */ new Map();
82
+ function registerHlTheme(theme) {
83
+ registry$1.set(theme.id, theme);
84
+ }
85
+ function getHlTheme(id) {
86
+ return registry$1.get(id);
87
+ }
88
+ function getAllHlThemes() {
89
+ return [...registry$1.values()];
90
+ }
91
+ const hlThemeIds = [
92
+ "atom-one-dark",
93
+ "atom-one-light",
94
+ "dracula",
95
+ "github-dark",
96
+ "github",
97
+ "monokai",
98
+ "solarized-dark",
99
+ "solarized-light",
100
+ "xcode"
101
+ ];
102
+ const cssModules$1 = /* @__PURE__ */ Object.assign({
103
+ "../assets/highlight/styles/atom-one-dark.min.css": __vite_glob_0_0$1,
104
+ "../assets/highlight/styles/atom-one-light.min.css": __vite_glob_0_1$1,
105
+ "../assets/highlight/styles/dracula.min.css": __vite_glob_0_2$1,
106
+ "../assets/highlight/styles/github-dark.min.css": __vite_glob_0_3$1,
107
+ "../assets/highlight/styles/github.min.css": __vite_glob_0_4$1,
108
+ "../assets/highlight/styles/monokai.min.css": __vite_glob_0_5$1,
109
+ "../assets/highlight/styles/solarized-dark.min.css": __vite_glob_0_6$1,
110
+ "../assets/highlight/styles/solarized-light.min.css": __vite_glob_0_7$1,
111
+ "../assets/highlight/styles/xcode.min.css": __vite_glob_0_8$1
112
+ });
113
+ function registerBuiltInHlThemes() {
114
+ for (const id of hlThemeIds) {
115
+ const path = `../assets/highlight/styles/${id}.min.css`;
116
+ const loader = cssModules$1[path];
117
+ if (!loader) continue;
118
+ registerHlTheme(
119
+ createTheme$1(id, {
120
+ type: "asset",
121
+ loader: normalizeCssLoader(loader)
122
+ })
123
+ );
124
+ }
125
+ }
126
+ function createTheme$1(id, source) {
127
+ return {
128
+ id,
129
+ async getCss() {
130
+ switch (source.type) {
131
+ case "inline":
132
+ return source.css;
133
+ case "asset":
134
+ return source.loader();
135
+ // case "file":
136
+ // return fs.readFile(source.path, "utf-8");
137
+ case "url":
138
+ const res = await fetch(source.url);
139
+ if (!res.ok) throw new Error(`Failed to load theme CSS`);
140
+ return res.text();
141
+ }
142
+ }
143
+ };
144
+ }
145
+ function addFootnotes(element, listStyle = false) {
146
+ const footnotes = [];
147
+ let footnoteIndex = 0;
148
+ const links = element.querySelectorAll("a[href]");
149
+ links.forEach((linkElement) => {
150
+ const title = linkElement.textContent || linkElement.innerText;
151
+ const href = linkElement.getAttribute("href") || "";
152
+ footnotes.push([++footnoteIndex, title, href]);
153
+ const footnoteMarker = element.ownerDocument.createElement("sup");
154
+ footnoteMarker.setAttribute("class", "footnote");
155
+ footnoteMarker.innerHTML = `[${footnoteIndex}]`;
156
+ linkElement.after(footnoteMarker);
384
157
  });
385
- csstree.walk(ast, {
386
- visit: "Rule",
387
- leave: (node, item, list) => {
388
- if (node.prelude.type !== "SelectorList") return;
389
- const selectors = node.prelude.children.toArray().map((sel) => csstree.generate(sel));
390
- if (selectors) {
391
- const selector = selectors[0];
392
- const update = updates[selector];
393
- if (!update) return;
394
- for (const { property, value, append } of update) {
395
- if (value) {
396
- let found = false;
397
- csstree.walk(node.block, (decl) => {
398
- if (decl.type === "Declaration" && decl.property === property) {
399
- decl.value = csstree.parse(value, { context: "value" });
400
- found = true;
158
+ if (footnoteIndex === 0) return;
159
+ const footnotesHtml = listStyle ? renderListStyleFootnotes(footnotes) : renderParagraphStyleFootnotes(footnotes);
160
+ element.insertAdjacentHTML("beforeend", footnotesHtml);
161
+ }
162
+ function renderParagraphStyleFootnotes(footnotes) {
163
+ const items = footnotes.map(([index, title, href]) => {
164
+ if (title === href) {
165
+ return `<p><span class="footnote-num">[${index}]</span><span class="footnote-txt"><i>${title}</i></span></p>`;
166
+ }
167
+ return `<p><span class="footnote-num">[${index}]</span><span class="footnote-txt">${title}: <i>${href}</i></span></p>`;
168
+ });
169
+ return `<h3>引用链接</h3><section id="footnotes">${items.join("")}</section>`;
170
+ }
171
+ function renderListStyleFootnotes(footnotes) {
172
+ const items = footnotes.map(([index, title, href]) => {
173
+ if (title === href) {
174
+ return `<li id="footnote-${index}">[${index}]: <i>${title}</i></li>`;
175
+ }
176
+ return `<li id="footnote-${index}">[${index}] ${title}: <i>${href}</i></li>`;
177
+ });
178
+ return `<h3>引用链接</h3><div id="footnotes"><ul>${items.join("")}</ul></div>`;
179
+ }
180
+ async function handleFrontMatter(markdown) {
181
+ const { attributes, body } = fm(markdown);
182
+ const result = { body: body || "" };
183
+ let head = "";
184
+ const { title, description, cover } = attributes;
185
+ if (title) {
186
+ result.title = title;
187
+ }
188
+ if (description) {
189
+ head += "> " + description + "\n\n";
190
+ result.description = description;
191
+ }
192
+ if (cover) {
193
+ result.cover = cover;
194
+ }
195
+ if (head) {
196
+ result.body = head + result.body;
197
+ }
198
+ return result;
199
+ }
200
+ const parseOptions = {
201
+ context: "stylesheet",
202
+ positions: false,
203
+ parseAtrulePrelude: false,
204
+ parseCustomProperty: false,
205
+ parseValue: false
206
+ };
207
+ function createCssModifier(updates) {
208
+ return function modifyCss(customCss) {
209
+ const ast = csstree.parse(customCss, parseOptions);
210
+ csstree.walk(ast, {
211
+ visit: "Rule",
212
+ leave(node, _, list) {
213
+ if (node.prelude?.type !== "SelectorList") return;
214
+ const selectors = node.prelude.children.toArray().map((sel) => csstree.generate(sel));
215
+ if (selectors.length > 0) {
216
+ const selector = selectors[0];
217
+ const update = updates[selector];
218
+ if (!update) return;
219
+ for (const { property, value, append } of update) {
220
+ if (value) {
221
+ let found = false;
222
+ csstree.walk(node.block, (decl) => {
223
+ if (decl.type === "Declaration" && decl.property === property) {
224
+ decl.value = csstree.parse(value, { context: "value" });
225
+ found = true;
226
+ }
227
+ });
228
+ if (!found && append) {
229
+ node.block.children.prepend(
230
+ list.createItem({
231
+ type: "Declaration",
232
+ property,
233
+ value: csstree.parse(value, { context: "value" }),
234
+ important: false
235
+ })
236
+ );
401
237
  }
402
- });
403
- if (!found && append) {
404
- node.block.children.prepend(
405
- list.createItem({
406
- type: "Declaration",
407
- property,
408
- value: csstree.parse(value, { context: "value" })
409
- })
410
- );
411
238
  }
412
239
  }
413
240
  }
414
241
  }
415
- }
416
- });
417
- return csstree.generate(ast);
242
+ });
243
+ return csstree.generate(ast);
244
+ };
418
245
  }
419
- function extractDeclarations(ruleNode, resultMap) {
420
- csstree.walk(ruleNode.block, {
421
- visit: "Declaration",
422
- enter(declNode) {
423
- const property = declNode.property;
424
- const value = csstree.generate(declNode.value);
425
- resultMap.set(property, value);
426
- }
246
+ function createCssApplier(css) {
247
+ const ast = csstree.parse(css, parseOptions);
248
+ return function applyToElement(element) {
249
+ csstree.walk(ast, {
250
+ visit: "Rule",
251
+ enter(node) {
252
+ if (node.prelude.type !== "SelectorList") return;
253
+ const declarations = node.block.children.toArray();
254
+ node.prelude.children.forEach((selectorNode) => {
255
+ const selector = csstree.generate(selectorNode);
256
+ if (selector.includes(":")) return;
257
+ const targets = selector === "#wenyan" ? [element] : Array.from(element.querySelectorAll(selector));
258
+ targets.forEach((el) => {
259
+ declarations.forEach((decl) => {
260
+ if (decl.type !== "Declaration") return;
261
+ let value = csstree.generate(decl.value);
262
+ const property = decl.property;
263
+ const priority = decl.important ? "important" : "";
264
+ el.style.setProperty(property, value, priority);
265
+ });
266
+ });
267
+ });
268
+ }
269
+ });
270
+ };
271
+ }
272
+ function renderHighlightTheme(wenyanElement, highlightCss) {
273
+ createCssApplier(highlightCss)(wenyanElement);
274
+ }
275
+ const macStyleCss = `#wenyan pre::before {
276
+ display: block;
277
+ content: "";
278
+ 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>');
279
+ background-repeat: no-repeat;
280
+ width: 100%;
281
+ height: 16px;
282
+ }`;
283
+ function applyPseudoElements(element, themeCss) {
284
+ const ast = csstree.parse(themeCss, parseOptions);
285
+ const rules = extractPseudoRules(ast);
286
+ rules.forEach((rule, tag) => {
287
+ const elements = element.querySelectorAll(tag);
288
+ elements.forEach((el) => {
289
+ const doc = el.ownerDocument;
290
+ if (rule.before.size > 0) {
291
+ el.insertBefore(buildPseudoElement(rule.before, doc), el.firstChild);
292
+ }
293
+ if (rule.after.size > 0) {
294
+ el.appendChild(buildPseudoElement(rule.after, doc));
295
+ }
296
+ });
427
297
  });
428
298
  }
429
- function buildPseudoSpan(beforeRresults, document) {
430
- const span = document.createElement("section");
431
- if (beforeRresults.get("content")) {
432
- span.textContent = beforeRresults.get("content").replace(/['"]/g, "");
433
- beforeRresults.delete("content");
299
+ function buildPseudoElement(originalResults, document2) {
300
+ const beforeResults = new Map(originalResults);
301
+ const section = document2.createElement("section");
302
+ const content = beforeResults.get("content");
303
+ if (content) {
304
+ section.textContent = content.replace(/['"]/g, "");
305
+ beforeResults.delete("content");
434
306
  }
435
- for (const [k, v] of beforeRresults) {
307
+ for (const [k, v] of beforeResults) {
436
308
  if (v.includes("url(")) {
437
309
  const svgMatch = v.match(/data:image\/svg\+xml;utf8,(.*<\/svg>)/);
438
310
  const base64SvgMatch = v.match(/data:image\/svg\+xml;base64,([^"'\)]*)["']?\)/);
439
311
  const httpMatch = v.match(/(?:"|')?(https?[^"'\)]*)(?:"|')?\)/);
440
312
  if (svgMatch) {
441
313
  const svgCode = decodeURIComponent(svgMatch[1]);
442
- span.innerHTML = svgCode;
314
+ section.innerHTML = svgCode;
443
315
  } else if (base64SvgMatch) {
444
316
  const decodedString = atob(base64SvgMatch[1]);
445
- span.innerHTML = decodedString;
317
+ section.innerHTML = decodedString;
446
318
  } else if (httpMatch) {
447
- const img = document.createElement("img");
319
+ const img = document2.createElement("img");
448
320
  img.src = httpMatch[1];
449
321
  img.setAttribute("style", "vertical-align: top;");
450
- span.appendChild(img);
322
+ section.appendChild(img);
451
323
  }
452
- beforeRresults.delete(k);
324
+ beforeResults.delete(k);
453
325
  }
454
326
  }
455
- const entries = Array.from(beforeRresults.entries());
327
+ const entries = Array.from(beforeResults.entries());
456
328
  const cssString = entries.map(([key, value]) => `${key}: ${value}`).join("; ");
457
- span.style.cssText = cssString;
458
- return span;
329
+ section.style.cssText = cssString;
330
+ return section;
459
331
  }
460
- function addFootnotes(listStyle, element) {
461
- let footnotes = [];
462
- let footnoteIndex = 0;
463
- const links = element.querySelectorAll("a[href]");
464
- links.forEach((linkElement) => {
465
- const title = linkElement.textContent || linkElement.innerText;
466
- const href = linkElement.getAttribute("href");
467
- footnotes.push([++footnoteIndex, title, href]);
468
- const footnoteMarker = element.ownerDocument.createElement("sup");
469
- footnoteMarker.setAttribute("class", "footnote");
470
- footnoteMarker.innerHTML = `[${footnoteIndex}]`;
471
- linkElement.after(footnoteMarker);
332
+ function extractPseudoRules(ast) {
333
+ const table = /* @__PURE__ */ new Map();
334
+ csstree.walk(ast, {
335
+ visit: "Rule",
336
+ enter(node) {
337
+ const selector = csstree.generate(node.prelude);
338
+ const match = selector.match(/(^|\s)(h[1-6]|blockquote|pre)::(before|after)\b/);
339
+ if (!match) return;
340
+ const tag = match[2];
341
+ const pseudo = match[3];
342
+ let record = table.get(tag);
343
+ if (!record) {
344
+ record = {
345
+ before: /* @__PURE__ */ new Map(),
346
+ after: /* @__PURE__ */ new Map()
347
+ };
348
+ table.set(tag, record);
349
+ }
350
+ extractDeclarations(node, record[pseudo]);
351
+ }
472
352
  });
473
- if (footnoteIndex > 0) {
474
- if (!listStyle) {
475
- let footnoteArray = footnotes.map((x) => {
476
- if (x[1] === x[2]) {
477
- return `<p><span class="footnote-num">[${x[0]}]</span><span class="footnote-txt"><i>${x[1]}</i></span></p>`;
353
+ return table;
354
+ }
355
+ function extractDeclarations(ruleNode, result) {
356
+ csstree.walk(ruleNode.block, {
357
+ visit: "Declaration",
358
+ enter(decl) {
359
+ const property = decl.property;
360
+ const value = csstree.generate(decl.value);
361
+ result.set(property, value);
362
+ }
363
+ });
364
+ }
365
+ function renderMacStyle(wenyanElement) {
366
+ applyPseudoElements(wenyanElement, macStyleCss);
367
+ }
368
+ function createMarkedClient() {
369
+ let configurePromise = null;
370
+ const md = new Marked();
371
+ async function configure() {
372
+ if (configurePromise) {
373
+ return configurePromise;
374
+ }
375
+ configurePromise = (async () => {
376
+ const highlightExtension = markedHighlight({
377
+ emptyLangClass: "hljs",
378
+ langPrefix: "hljs language-",
379
+ highlight(code, lang) {
380
+ const language = hljs.getLanguage(lang) ? lang : "plaintext";
381
+ return hljs.highlight(code, { language }).value;
478
382
  }
479
- return `<p><span class="footnote-num">[${x[0]}]</span><span class="footnote-txt">${x[1]}: <i>${x[2]}</i></span></p>`;
480
383
  });
481
- const footnotesHtml = `<h3>引用链接</h3><section id="footnotes">${footnoteArray.join("")}</section>`;
482
- element.innerHTML += footnotesHtml;
483
- } else {
484
- let footnoteArray = footnotes.map((x) => {
485
- if (x[1] === x[2]) {
486
- return `<li id="#footnote-${x[0]}">[${x[0]}]: <i>${x[1]}</i></li>`;
384
+ md.use(highlightExtension);
385
+ md.use({
386
+ extensions: [
387
+ {
388
+ name: "attributeImage",
389
+ level: "inline",
390
+ start(src) {
391
+ return src.match(/!\[/)?.index;
392
+ },
393
+ tokenizer(src) {
394
+ const rule = /^!\[([^\]]*)\]\(([^)]+)\)\{([^}]+)\}/;
395
+ const match = rule.exec(src);
396
+ if (match) {
397
+ return {
398
+ type: "attributeImage",
399
+ raw: match[0],
400
+ text: match[1],
401
+ // alt 文本
402
+ href: match[2],
403
+ // 图片链接
404
+ attrs: match[3],
405
+ // 属性字符串
406
+ tokens: []
407
+ //以此作为 inline token
408
+ };
409
+ }
410
+ return void 0;
411
+ },
412
+ renderer(token) {
413
+ const attrs = stringToMap(token.attrs);
414
+ const styleStr = Array.from(attrs).map(([k, v]) => /^\d+$/.test(v) ? `${k}:${v}px` : `${k}:${v}`).join("; ");
415
+ return `<img src="${token.href}" alt="${token.text || ""}" title="${token.text || ""}" style="${styleStr}">`;
416
+ }
417
+ }
418
+ ]
419
+ });
420
+ md.use({
421
+ renderer: {
422
+ // 重写标题 (h1 ~ h6)
423
+ heading(token) {
424
+ const text = this.parser.parseInline(token.tokens);
425
+ const level = token.depth;
426
+ return `<h${level}><span>${text}</span></h${level}>
427
+ `;
428
+ },
429
+ // 重写段落 (处理行间公式)
430
+ paragraph(token) {
431
+ const text = token.text;
432
+ const hasBlockMath = text.length > 4 && (/\$\$[\s\S]*?\$\$/g.test(text) || /\\\[[\s\S]*?\\\]/g.test(text));
433
+ if (hasBlockMath) {
434
+ return `${text}
435
+ `;
436
+ } else {
437
+ return `<p>${this.parser.parseInline(token.tokens)}</p>
438
+ `;
439
+ }
440
+ },
441
+ // 重写普通图片 (处理标准 Markdown 图片)
442
+ image(token) {
443
+ return `<img src="${token.href}" alt="${token.text || ""}" title="${token.title || token.text || ""}">`;
444
+ }
487
445
  }
488
- return `<li id="#footnote-${x[0]}">[${x[0]}] ${x[1]}: <i>${x[2]}</i></li>`;
489
446
  });
490
- const footnotesHtml = `<h3>引用链接</h3><div id="footnotes"><ul>${footnoteArray.join("")}</ul></div>`;
491
- element.innerHTML += footnotesHtml;
447
+ })();
448
+ return configurePromise;
449
+ }
450
+ return {
451
+ /**
452
+ * 解析 Markdown 为 HTML
453
+ */
454
+ async parse(markdown) {
455
+ await configure();
456
+ return md.parse(markdown);
457
+ }
458
+ };
459
+ }
460
+ let htmlHandlerRegistered = false;
461
+ function createMathJaxParser(options = {}) {
462
+ const adaptor = liteAdaptor();
463
+ if (!htmlHandlerRegistered) {
464
+ try {
465
+ RegisterHTMLHandler(adaptor);
466
+ htmlHandlerRegistered = true;
467
+ } catch {
468
+ }
469
+ }
470
+ const tex = new TeX({
471
+ inlineMath: options.inlineMath ?? [
472
+ ["$", "$"],
473
+ ["\\(", "\\)"]
474
+ ],
475
+ displayMath: options.displayMath ?? [
476
+ ["$$", "$$"],
477
+ ["\\[", "\\]"]
478
+ ],
479
+ processEscapes: true,
480
+ packages: AllPackages
481
+ });
482
+ const svg = new SVG({
483
+ fontCache: options.fontCache ?? "none"
484
+ });
485
+ function addContainer(math, doc) {
486
+ const tag = math.display ? "section" : "span";
487
+ const cls = math.display ? "block-equation" : "inline-equation";
488
+ const container = math.typesetRoot;
489
+ if (math.math) {
490
+ doc.adaptor.setAttribute(container, "math", math.math);
491
+ }
492
+ const node = doc.adaptor.node(tag, { class: cls }, [container]);
493
+ math.typesetRoot = node;
494
+ }
495
+ return {
496
+ parser(htmlString) {
497
+ const doc = mathjax.document(htmlString, {
498
+ InputJax: tex,
499
+ OutputJax: svg,
500
+ renderActions: {
501
+ addContainer: [
502
+ 190,
503
+ (doc2) => {
504
+ for (const math of doc2.math) {
505
+ addContainer(math, doc2);
506
+ }
507
+ },
508
+ addContainer
509
+ ]
510
+ }
511
+ });
512
+ doc.render();
513
+ const body = adaptor.body(doc.document);
514
+ return adaptor.innerHTML(body);
515
+ }
516
+ };
517
+ }
518
+ function wechatPostRender(element) {
519
+ const mathElements = element.querySelectorAll("mjx-container");
520
+ mathElements.forEach((mathContainer) => {
521
+ const svg = mathContainer.querySelector("svg");
522
+ if (!svg) return;
523
+ svg.style.width = svg.getAttribute("width") || "";
524
+ svg.style.height = svg.getAttribute("height") || "";
525
+ svg.removeAttribute("width");
526
+ svg.removeAttribute("height");
527
+ const parent = mathContainer.parentElement;
528
+ if (parent) {
529
+ mathContainer.remove();
530
+ parent.appendChild(svg);
531
+ if (parent.classList.contains("block-equation")) {
532
+ parent.setAttribute("style", "text-align: center; margin-bottom: 1rem;");
533
+ }
534
+ }
535
+ });
536
+ const codeElements = element.querySelectorAll("pre code");
537
+ codeElements.forEach((codeEl) => {
538
+ codeEl.innerHTML = codeEl.innerHTML.replace(/\n/g, "<br>").replace(/(>[^<]+)|(^[^<]+)/g, (str) => str.replace(/\s/g, "&nbsp;"));
539
+ });
540
+ const listElements = element.querySelectorAll("li");
541
+ listElements.forEach((li) => {
542
+ const doc = element.ownerDocument || document;
543
+ const section = doc.createElement("section");
544
+ while (li.firstChild) {
545
+ section.appendChild(li.firstChild);
546
+ }
547
+ li.appendChild(section);
548
+ });
549
+ }
550
+ const themeModifier = createCssModifier({
551
+ "#wenyan pre code": [
552
+ {
553
+ property: "font-family",
554
+ value: monospace,
555
+ append: true
556
+ }
557
+ ],
558
+ "#wenyan pre": [
559
+ {
560
+ property: "font-size",
561
+ value: "12px",
562
+ append: true
563
+ }
564
+ ]
565
+ });
566
+ function renderTheme(wenyanElement, themeCss) {
567
+ const modifiedCss = themeModifier(themeCss);
568
+ createCssApplier(modifiedCss)(wenyanElement);
569
+ }
570
+ const __vite_glob_0_0 = "/**\n * 欢迎使用自定义主题功能,使用教程:\n * https://babyno.top/posts/2024/11/wenyan-supports-customized-themes/\n */\n/* 全局属性 */\n#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n/* 全局子元素属性 */\n/* 支持分组 */\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6,\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n/* 段落 */\n#wenyan p {\n}\n/* 加粗 */\n#wenyan p strong {\n}\n/* 斜体 */\n#wenyan p em {\n}\n/* 一级标题 */\n#wenyan h1 {\n text-align: center;\n text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);\n font-size: 1.5em;\n}\n/* 标题文字 */\n#wenyan h1 span {\n}\n/* 标题前缀,h1-h6都支持前缀 */\n#wenyan h1::before {\n}\n/* 标题后缀,h1-h6都支持后缀 */\n#wenyan h1::after {\n}\n/* 二级标题 */\n#wenyan h2 {\n text-align: center;\n font-size: 1.2em;\n border-bottom: 1px solid #f7f7f7;\n font-weight: bold;\n}\n/* 三-六级标题 */\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n font-size: 1em;\n font-weight: bold;\n}\n/* 列表 */\n#wenyan ul,\n#wenyan ol {\n padding-left: 1.2em;\n}\n/* 列表元素 */\n#wenyan li {\n margin-left: 1.2em;\n}\n/* 图片 */\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n/* 表格 */\n#wenyan table {\n border-collapse: collapse;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n display: table;\n word-wrap: break-word;\n word-break: break-all;\n}\n/* 表格单元格 */\n#wenyan table td,\n#wenyan table th {\n font-size: 0.75em;\n padding: 9px 12px;\n line-height: 22px;\n color: #222;\n border: 1px solid #d8d8d8;\n vertical-align: top;\n}\n/* 表格表头 */\n#wenyan table th {\n font-weight: bold;\n background-color: #f0f0f0;\n}\n/* 表格斑马条纹效果 */\n#wenyan table tr:nth-child(2n) {\n background-color: #f8f8f8;\n}\n/* 引用块 */\n#wenyan blockquote {\n background: #afb8c133;\n border-left: 0.5em solid #ccc;\n margin: 1.5em 0;\n padding: 0.5em 10px;\n font-style: italic;\n font-size: 0.9em;\n}\n/* 引用块前缀 */\n#wenyan blockquote::before {\n}\n/* 引用块后缀 */\n#wenyan blockquote::after {\n}\n/* 行内代码 */\n#wenyan p code {\n font-family: var(--monospace-font);\n color: #ff502c;\n padding: 4px 6px;\n font-size: 0.78em;\n}\n/* 代码块外围 */\n#wenyan pre {\n border-radius: 5px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;\n}\n/* 代码块 */\n#wenyan pre code {\n font-family: var(--monospace-font);\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n}\n/* 分割线 */\n#wenyan hr {\n border: none;\n border-top: 1px solid #ddd;\n margin-top: 2em;\n margin-bottom: 2em;\n}\n/* 链接 */\n#wenyan a {\n word-wrap: break-word;\n color: #0069c2;\n}\n/* 原始链接旁脚注上标 */\n#wenyan .footnote {\n color: #0069c2;\n}\n/* 脚注行 */\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n/* 脚注行内编号 */\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n/* 脚注行内文字 */\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n";
571
+ const __vite_glob_0_1 = "#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n}\n#wenyan * {\n box-sizing: border-box;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6,\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n line-height: 1.5;\n margin-top: 35px;\n margin-bottom: 10px;\n padding-bottom: 5px;\n}\n#wenyan h1 {\n font-size: 24px;\n line-height: 38px;\n margin-bottom: 5px;\n}\n#wenyan h2 {\n font-size: 22px;\n line-height: 34px;\n padding-bottom: 12px;\n border-bottom: 1px solid #ececec;\n}\n#wenyan h3 {\n font-size: 20px;\n line-height: 28px;\n}\n#wenyan ul,\n#wenyan ol {\n padding-left: 1.2em;\n}\n#wenyan li {\n margin-left: 1.2em;\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan table {\n display: inline-block !important;\n font-size: 12px;\n width: auto;\n max-width: 100%;\n overflow: auto;\n border: 1px solid #f6f6f6;\n}\n#wenyan thead {\n background: #f6f6f6;\n color: #000;\n text-align: left;\n}\n#wenyan table td,\n#wenyan table th {\n padding: 12px 7px;\n line-height: 24px;\n}\n#wenyan blockquote {\n color: #666;\n padding: 1px 23px;\n margin: 22px 0;\n border-left: 4px solid #cbcbcb;\n background-color: #f8f8f8;\n font-size: 0.95em;\n}\n#wenyan p code {\n font-family: var(--monospace-font);\n background: #fff5f5;\n color: #ff502c;\n padding: 4px 6px;\n font-size: 0.78em;\n}\n#wenyan pre {\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n color: #333;\n background: #f8f8f8;\n}\n#wenyan pre code {\n font-family: var(--monospace-font);\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n background: #f8f8f8;\n}\n#wenyan hr {\n border: none;\n border-top: 1px solid #ddd;\n margin-top: 32px;\n margin-bottom: 32px;\n}\n/* 链接 */\n#wenyan a {\n word-wrap: break-word;\n color: #0069c2;\n}\n/* 脚注 */\n#wenyan #footnotes ul {\n font-size: 0.9em;\n margin: 0;\n padding-left: 1.2em;\n}\n#wenyan #footnotes li {\n margin: 0 0 0 1.2em;\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan .footnote {\n color: #0069c2;\n}\n";
572
+ const __vite_glob_0_2 = "/*\n * Typora Theme - Lapis / Author - YiNN\n * https://github.com/YiNNx/typora-theme-lapis\n */\n\n:root {\n --text-color: #40464f;\n --primary-color: #4870ac;\n --bg-color: #ffffff;\n --marker-color: #a2b6d4;\n --source-color: #a8a8a9;\n --header-span-color: var(--primary-color);\n --block-bg-color: #f6f8fa;\n}\n#wenyan {\n color: var(--text-color);\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan strong {\n color: var(--primary-color);\n}\n#wenyan a {\n word-wrap: break-word;\n color: var(--primary-color);\n}\n#wenyan p {\n color: var(--text-color);\n}\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n font-weight: normal;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n padding: 0px;\n color: var(--primary-color);\n margin: 1.2em 0 1em;\n}\n#wenyan h1 {\n text-align: center;\n}\n#wenyan h2 {\n padding: 1px 12.5px;\n border-radius: 4px;\n display: inline-block;\n}\n#wenyan h2,\n#wenyan h2 code {\n background-color: var(--header-span-color);\n}\n#wenyan h2,\n#wenyan h2 a,\n#wenyan h2 code,\n#wenyan h2 strong {\n color: var(--bg-color);\n}\n#wenyan h1 {\n font-size: 1.5em;\n}\n#wenyan h2 {\n font-size: 1.3em;\n}\n#wenyan h3 {\n font-size: 1.3em;\n}\n#wenyan h4 {\n font-size: 1.2em;\n}\n#wenyan h5 {\n font-size: 1.2em;\n}\n#wenyan h6 {\n font-size: 1.2em;\n}\n#wenyan ul {\n list-style-type: disc;\n}\n#wenyan em {\n padding: 0 3px 0 0;\n}\n#wenyan ul ul {\n list-style-type: square;\n}\n#wenyan ol {\n list-style-type: decimal;\n}\n#wenyan blockquote {\n display: block;\n font-size: 0.9em;\n border-left: 3px solid var(--primary-color);\n padding: 0.5em 1em;\n margin: 0;\n background: var(--block-bg-color);\n}\n#wenyan p code {\n color: var(--primary-color);\n font-size: 0.9em;\n font-weight: normal;\n word-wrap: break-word;\n padding: 2px 4px 2px;\n border-radius: 3px;\n margin: 2px;\n background-color: var(--block-bg-color);\n font-family: var(--monospace-font);\n word-break: break-all;\n}\n#wenyan img {\n max-width: 100%;\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan table {\n display: table;\n text-align: justify;\n overflow-x: auto;\n border-collapse: collapse;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table th,\n#wenyan table td {\n border: 1px solid #d9dfe4;\n padding: 9px 12px;\n font-size: 0.75em;\n line-height: 22px;\n vertical-align: top;\n}\n#wenyan table th {\n text-align: center;\n font-weight: bold;\n color: var(--primary-color);\n background: #f7f7f7;\n}\n#wenyan hr {\n margin-top: 20px;\n margin-bottom: 20px;\n border: 0;\n border-top: 2px solid #eef2f5;\n border-radius: 2px;\n}\n#wenyan pre {\n border-radius: 5px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n}\n#wenyan .footnote {\n color: var(--primary-color);\n}\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n";
573
+ const __vite_glob_0_3 = '/*\n * Typora Theme - Maize / Author - BEATREE\n * https://github.com/BEATREE/typora-maize-theme\n */\n\n:root {\n --bg-color: #fafafa;\n --text-color: #333333;\n --primary-color: #428bca;\n}\n#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n margin: 1.2em 0 1em;\n padding: 0px;\n font-weight: bold;\n}\n#wenyan h1 {\n font-size: 1.5em;\n}\n#wenyan h2::before {\n content: "";\n width: 20px;\n height: 30px;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIj4KICAgIDxnPgogICAgICAgIDxwYXRoIGQ9Im0zMy40NTIgNjIuMTQyUzY2LjA2MyAxNC45MzcgOTAuNDU2IDEwLjI4M2wxLjQyOSAxLjcxNFM3Mi41MzIgMjkuNTgyIDU4LjEzMyA0OC41ODNDNDMuMDg0IDY4LjQ0MiAzNi4wNTggODkuOTQ3IDMxLjg4IDg5LjcxNWMtNS42ODEtLjQxLTEyLjQyOS0zNy43MTYtMjMuMjg3LTMzLjI4Ny0yLjI4Ni0uNTcxIDMuOTEyLTkuNjE0IDEyLjU3Mi03LjU3MiA1LjQzIDEuMjgxIDEyLjI4NyAxMy4yODYgMTIuMjg3IDEzLjI4NnoiIGZpbGw9IiNmZmIxMWIiIC8+CiAgICA8L2c+Cjwvc3ZnPg==);\n background-repeat: no-repeat;\n background-size: 20px 20px;\n margin-right: 4px;\n background-position-y: 10px;\n}\n#wenyan h2 {\n font-size: 1.3em;\n display: flex;\n align-items: top;\n}\n#wenyan h2 span {\n font-weight: bold;\n color: #333;\n padding: 3px 10px 1px;\n}\n#wenyan h3 {\n font-size: 1.3em;\n}\n#wenyan h4 {\n font-size: 1.2em;\n}\n#wenyan h5 {\n font-size: 1.2em;\n}\n#wenyan h6 {\n font-size: 1.2em;\n}\n#wenyan ul,\n#wenyan ol {\n margin-top: 8px;\n margin-bottom: 8px;\n padding-left: 40px;\n color: black;\n}\n#wenyan ul {\n list-style-type: disc;\n}\n#wenyan ul ul {\n list-style-type: square;\n}\n#wenyan ol {\n list-style-type: decimal;\n}\n#wenyan strong {\n color: #e49123;\n font-weight: bold;\n}\n#wenyan blockquote {\n margin: 0;\n padding: 10px 10px 10px 20px;\n font-size: 0.9em;\n background: #fff9f9;\n border-left: 3px solid #ffb11b;\n color: #6a737d;\n overflow: auto;\n}\n#wenyan a {\n word-wrap: break-word;\n text-decoration: none;\n font-weight: bold;\n color: #e49123;\n border-bottom: 1px solid #e49123;\n}\n#wenyan hr {\n height: 1px;\n padding: 0;\n border: none;\n text-align: center;\n background-image: linear-gradient(to right, rgba(231, 93, 109, 0.3), rgba(255, 159, 150, 0.75), rgba(255, 216, 181, 0.3));\n}\n#wenyan p code,\n#wenyan span code,\n#wenyan li code {\n font-family: var(--monospace-font);\n word-wrap: break-word;\n padding: 2px 4px;\n border-radius: 4px;\n margin: 0 2px;\n word-break: break-all;\n color: rgb(235, 76, 55);\n background-color: #f0f0f0;\n font-size: .8em;\n}\n#wenyan img {\n max-width: 100%;\n display: block;\n margin: 0 auto;\n width: 85%;\n border-radius: 5px;\n box-shadow: 0px 4px 12px #84a1a8;\n border: 0px;\n}\n#wenyan table {\n border-collapse: collapse;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n display: table;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table td,\n#wenyan table th {\n font-size: 0.75em;\n padding: 9px 12px;\n line-height: 22px;\n color: #222;\n border: 1px solid rgb(255, 216, 181);\n vertical-align: top;\n}\n#wenyan table th {\n font-weight: bold;\n color: #ffb11b;\n background: #fff9f9;\n}\n#wenyan table tr:nth-child(2n) {\n background: #fff9f9;\n}\n#wenyan pre {\n border-radius: 5px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n}\n#wenyan .footnote {\n font-weight: bold;\n color: #e49123;\n}\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n';
574
+ const __vite_glob_0_4 = ':root {\n --sans-serif-font: source-serif-pro, Georgia, Cambria, "Times New Roman", Times, serif;\n --monospace-font: Menlo, Monaco, Consolas, "liberation mono", "courier new", monospace;\n}\n#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan * {\n box-sizing: border-box;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif;\n margin: 1em 0;\n}\n#wenyan h1 {\n font-size: 2em;\n font-weight: 700;\n}\n#wenyan h2,\n#wenyan h3 {\n font-size: 1.3em;\n font-weight: 700;\n}\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n font-size: 1.2em;\n font-weight: 700;\n}\n#wenyan p {\n letter-spacing: -0.003em;\n margin: 1em 0;\n}\n#wenyan ul,\n#wenyan ol {\n padding-left: 1.2em;\n}\n#wenyan li {\n margin-left: 1.2em;\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan table {\n border-collapse: collapse;\n font-size: 15px;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n width: 100%;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table th {\n background: #ebeced;\n color: #191b1f;\n font-weight: 500;\n}\n#wenyan table td,\n#wenyan table th {\n border: 1px solid #c4c7ce;\n height: 24px;\n line-height: 24px;\n padding: 3px 12px;\n}\n#wenyan blockquote {\n letter-spacing: -0.003em;\n border-left: 3px solid rgba(0, 0, 0, 0.84);\n padding-left: 20px;\n margin: 0 0 20px 0;\n}\n#wenyan p code {\n padding: 4px 6px;\n font-size: 0.78em;\n border-radius: 3px;\n font-family: var(--monospace-font);\n background-color: #f2f2f2;\n}\n#wenyan pre {\n line-height: 2;\n margin: 1em 0.5em;\n padding: 1em;\n background: #f9f9f9;\n border-radius: 4px;\n border: 1px solid #e5e5e5;\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n background: #f9f9f9;\n}\n#wenyan hr {\n border: none;\n border-top: 1px solid #c4c7ce;\n margin: 2em auto;\n max-width: 100%;\n width: 240px;\n}\n/* 链接 */\n#wenyan a {\n word-wrap: break-word;\n color: #000000;\n}\n/* 脚注 */\n#wenyan #footnotes ul {\n font-size: 0.9em;\n margin: 0;\n padding-left: 1.2em;\n}\n#wenyan #footnotes li {\n margin: 0 0 0 1.2em;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan .footnote {\n color: #000000;\n}\n';
575
+ const __vite_glob_0_5 = '/*\n * Typora Theme - Orange Heart / Author - evgo2017\n * https://github.com/evgo2017/typora-theme-orange-heart\n */\n\n#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n margin: 1.2em 0 1em;\n padding: 0px;\n font-weight: bold;\n}\n#wenyan h1 {\n font-size: 1.5em;\n}\n#wenyan h2 {\n font-size: 1.3em;\n border-bottom: 2px solid rgb(239, 112, 96);\n display: flex;\n}\n#wenyan h2 span {\n display: inline-block;\n font-weight: bold;\n background: rgb(239, 112, 96);\n color: #ffffff;\n padding: 3px 10px 1px;\n border-top-right-radius: 3px;\n border-top-left-radius: 3px;\n margin-right: 3px;\n}\n#wenyan h2::after {\n content: "";\n border-bottom: 36px solid #efebe9;\n border-right: 20px solid transparent;\n align-self: flex-end;\n height: 0;\n}\n#wenyan h3 {\n font-size: 1.3em;\n}\n#wenyan h4 {\n font-size: 1.2em;\n}\n#wenyan h5 {\n font-size: 1.1em;\n}\n#wenyan h6 {\n font-size: 1em;\n}\n#wenyan ul,\n#wenyan ol {\n margin-top: 8px;\n margin-bottom: 8px;\n padding-left: 25px;\n color: black;\n}\n#wenyan ul {\n list-style-type: disc;\n}\n#wenyan ul ul {\n list-style-type: square;\n}\n#wenyan ol {\n list-style-type: decimal;\n}\n#wenyan blockquote {\n margin: 0;\n display: block;\n font-size: 0.9em;\n overflow: auto;\n border-left: 3px solid rgb(239, 112, 96);\n color: #6a737d;\n padding: 10px 10px 10px 20px;\n margin-bottom: 20px;\n margin-top: 20px;\n background: #fff9f9;\n}\n#wenyan a {\n text-decoration: none;\n word-wrap: break-word;\n font-weight: bold;\n color: rgb(239, 112, 96);\n border-bottom: 1px solid rgb(239, 112, 96);\n}\n#wenyan p code,\n#wenyan li code {\n font-size: 0.9em;\n word-wrap: break-word;\n padding: 2px 4px;\n border-radius: 4px;\n margin: 0 2px;\n color: rgb(239, 112, 96);\n background-color: rgba(27, 31, 35, 0.05);\n font-family: var(--monospace-font);\n word-break: break-all;\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan span img {\n max-width: 100%;\n display: inline-block;\n border-right: 0px;\n border-left: 0px;\n}\n#wenyan table {\n border-collapse: collapse;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n display: table;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table td,\n#wenyan table th {\n font-size: 0.75em;\n padding: 9px 12px;\n line-height: 22px;\n color: #222;\n border: 1px solid rgb(239, 112, 96);\n vertical-align: top;\n}\n#wenyan table th {\n font-weight: bold;\n background-color: #fff9f9;\n color: rgb(239, 112, 96);\n}\n#wenyan span code,\n#wenyan li code {\n color: rgb(239, 112, 96);\n}\n#wenyan pre {\n border-radius: 5px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;\n}\n#wenyan pre code {\n display: block;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n}\n#wenyan .footnote {\n color: rgb(239, 112, 96);\n}\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n';
576
+ const __vite_glob_0_6 = `/*
577
+ * Typora Theme - Phycat / Author - sumruler
578
+ * https://github.com/sumruler/typora-theme-phycat
579
+ */
580
+
581
+ :root {
582
+ /* 标题后小图标,借鉴自思源笔记主题——Savor */
583
+ --h3-r-graphic: url("data:image/svg+xml;utf8,<svg fill='rgba(74, 200, 141, 0.5)' height='28' viewBox='0 0 32 32' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M4.571 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM4.571 18.286c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286z'/></svg>")
584
+ no-repeat center;
585
+ --h4-r-graphic: url("data:image/svg+xml;utf8,<svg fill='rgba(74, 200, 141, 0.5)' height='24' viewBox='0 0 32 32' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M4.571 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM4.571 18.286c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 22.857c1.257 0 2.286-1.029 2.286-2.286s-1.029-2.286-2.286-2.286-2.286 1.029-2.286 2.286 1.029 2.286 2.286 2.286z'/></svg>")
586
+ no-repeat center;
587
+ --h5-r-graphic: url("data:image/svg+xml;utf8,<svg fill='rgba(74, 200, 141, 0.5)' height='24' viewBox='0 0 32 32' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M4.571 18.286c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 22.857c1.257 0 2.286-1.029 2.286-2.286s-1.029-2.286-2.286-2.286-2.286 1.029-2.286 2.286 1.029 2.286 2.286 2.286zM4.571 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM4.571 11.429c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286z'/></svg>")
588
+ no-repeat center;
589
+ --h6-r-graphic: url("data:image/svg+xml;utf8,<svg fill='rgba(74, 200, 141, 0.5)' height='24' viewBox='0 0 32 32' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M4.571 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM4.571 18.286c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM4.571 11.429c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 18.286c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 25.143c-1.257 0-2.286 1.029-2.286 2.286s1.029 2.286 2.286 2.286 2.286-1.029 2.286-2.286-1.029-2.286-2.286-2.286zM11.429 16c1.257 0 2.286-1.029 2.286-2.286s-1.029-2.286-2.286-2.286-2.286 1.029-2.286 2.286 1.029 2.286 2.286 2.286z'/></svg>")
590
+ no-repeat center;
591
+
592
+ /* 是否开启网格背景?1 是;0 否 */
593
+ --bg-grid: 0;
594
+
595
+ /* 主题颜色 */
596
+
597
+ --head-title-color: #3db8bf;
598
+ /* 标题主色 */
599
+ --head-title-h2-color: #fff;
600
+ --head-title-h2-background: linear-gradient(to right, #3db8d3, #80f7c4);
601
+ /* 二级标题主色,因为二级标题是背景色的,所以单独设置 */
602
+
603
+ --element-color: #3db8bf;
604
+ /* 元素主色 */
605
+ --element-color-deep: #089ba3;
606
+ /* 元素深色 */
607
+ --element-color-shallow: #7aeaf0;
608
+ /* 元素浅色 */
609
+ --element-color-so-shallow: #7aeaf077;
610
+ /* 元素很浅色 */
611
+ --element-color-soo-shallow: #7aeaf018;
612
+ /* 元素非常浅色 */
613
+
614
+ --element-color-linecode: #089ba3;
615
+ /* 行内代码文字色 */
616
+ --element-color-linecode-background: #7aeaf018;
617
+ /* 行内代码背景色 */
618
+ }
619
+ #wenyan {
620
+ font-size: 14px;
621
+ font-family: var(--sans-serif-font);
622
+ margin: 0 auto;
623
+ padding: 15px;
624
+ line-height: 1.75;
625
+ color: #000;
626
+ letter-spacing: 1.1px;
627
+ word-break: break-word;
628
+ word-wrap: break-word;
629
+ text-align: left;
630
+ background-image: linear-gradient(
631
+ 90deg,
632
+ rgba(50, 0, 0, 0.05) calc(3% * var(--bg-grid)),
633
+ rgba(0, 0, 0, 0) calc(3% * var(--bg-grid))
634
+ ),
635
+ linear-gradient(
636
+ 360deg,
637
+ rgba(50, 0, 0, 0.05) calc(3% * var(--bg-grid)),
638
+ rgba(0, 0, 0, 0) calc(3% * var(--bg-grid))
639
+ );
640
+ background-size: 20px 20px;
641
+ background-position: center center;
642
+ }
643
+ #wenyan p {
644
+ text-align: justify;
645
+ color: #333;
646
+ margin: 10px 10px;
647
+ word-spacing: 2px;
648
+ }
649
+ #wenyan h3::after,
650
+ #wenyan h4::after,
651
+ #wenyan h5::after,
652
+ #wenyan h6::after {
653
+ content: "";
654
+ margin-left: 0.2em;
655
+ height: 2em;
656
+ width: 1.2em;
657
+ }
658
+ #wenyan h3::after {
659
+ background: var(--h3-r-graphic);
660
+ background-position-y: -2px;
661
+ }
662
+ #wenyan h4::after {
663
+ background: var(--h4-r-graphic);
664
+ background-position-y: -2px;
665
+ }
666
+ #wenyan h5::after {
667
+ background: var(--h5-r-graphic);
668
+ background-position-y: -1px;
669
+ }
670
+ #wenyan h6::after {
671
+ background: var(--h6-r-graphic);
672
+ background-position-y: -1px;
673
+ }
674
+ #wenyan h1 {
675
+ text-align: center;
676
+ font-weight: bold;
677
+ font-size: 1.4em;
678
+ }
679
+ #wenyan h2 {
680
+ color: var(--head-title-h2-color);
681
+ font-size: 1.4em;
682
+ line-height: 1.6;
683
+ width: fit-content;
684
+ font-weight: bold;
685
+ margin: 20px 0 5px;
686
+ padding: 1px 12.5px;
687
+ border-radius: 4px;
688
+ background: var(--head-title-h2-background);
689
+ background-size: 200% 100%;
690
+ background-position: 0% 0%;
691
+ display: inline-block;
692
+ }
693
+ #wenyan h3,
694
+ h4,
695
+ h5,
696
+ h6 {
697
+ font-weight: bold;
698
+ display: flex;
699
+ align-items: top;
700
+ }
701
+ #wenyan h3 {
702
+ width: fit-content;
703
+ margin: 20px 0 5px;
704
+ font-size: 1.3em;
705
+ padding-left: 10px;
706
+ border-left: 5px solid var(--head-title-color);
707
+ }
708
+ #wenyan h3 span {
709
+ border-bottom: 2px hidden var(--head-title-color);
710
+ }
711
+ #wenyan h4 {
712
+ margin: 20px 0 5px;
713
+ font-size: 1.15em;
714
+ }
715
+ #wenyan h4::before {
716
+ content: "";
717
+ margin-right: 7px;
718
+ margin-top: 8px;
719
+ background-color: var(--head-title-color);
720
+ width: 10px;
721
+ height: 10px;
722
+ border-radius: 100%;
723
+ border: var(--head-title-color) 1px solid;
724
+ }
725
+ #wenyan h5 {
726
+ margin: 20px 0 5px;
727
+ font-size: 1.1em;
728
+ }
729
+ #wenyan h5::before {
730
+ content: "";
731
+ margin-right: 7px;
732
+ margin-top: 8px;
733
+ display: inline-block;
734
+ background-color: #ffffff;
735
+ width: 10px;
736
+ height: 10px;
737
+ border-radius: 100%;
738
+ border: var(--head-title-color) 2px solid;
739
+ }
740
+ #wenyan h6 {
741
+ margin: 20px 0 5px;
742
+ font-size: 1.1em;
743
+ }
744
+ #wenyan h6::before {
745
+ content: "⁘";
746
+ color: var(--head-title-color);
747
+ margin-right: 7px;
748
+ }
749
+
750
+ #wenyan ol {
751
+ margin-left: 2px;
752
+ padding-left: 12px;
753
+ margin-bottom: 0px;
754
+ margin-top: 0px;
755
+ }
756
+
757
+ #wenyan ul {
758
+ list-style-type: disc;
759
+ margin-bottom: 0px;
760
+ margin-top: 0px;
761
+ }
762
+
763
+ #wenyan ul ul {
764
+ list-style-type: circle;
765
+ }
766
+
767
+ #wenyan ul ul ul {
768
+ list-style-type: square;
769
+ }
770
+
771
+ #wenyan ol {
772
+ padding-left: 27px;
773
+ list-style-type: decimal;
774
+ }
775
+ #wenyan ol ol {
776
+ list-style-type: lower-alpha;
777
+ }
778
+ #wenyan ol ol ol {
779
+ list-style-type: lower-roman;
780
+ }
781
+
782
+ #wenyan li {
783
+ color: #333;
784
+ margin: 0px 6px;
785
+ word-spacing: 2px;
786
+ line-height: 2.5;
787
+ }
788
+
789
+ #wenyan li {
790
+ position: relative;
791
+ }
792
+ #wenyan li > p {
793
+ margin: 0;
794
+ }
795
+ #wenyan blockquote {
796
+ font-size: 12px;
797
+ margin-left: 12px;
798
+ text-align: justify;
799
+ padding: 12px;
800
+ background: var(--element-color-soo-shallow);
801
+ border: 0px solid var(--element-color);
802
+ border-left-color: var(--element-color);
803
+ border-left-width: 4px;
804
+ border-radius: 4px;
805
+ line-height: 26px;
806
+ }
807
+ #wenyan blockquote p {
808
+ color: #000;
809
+ }
810
+ #wenyan a {
811
+ color: #000;
812
+ font-weight: bolder;
813
+ text-decoration: none;
814
+ border-bottom: 1px solid #3db8bf;
815
+ }
816
+
817
+ #wenyan strong {
818
+ color: #000;
819
+ font-weight: bold;
820
+ }
821
+ #wenyan em {
822
+ font-style: italic;
823
+ color: #000;
824
+ }
825
+ #wenyan del {
826
+ text-decoration-color: var(--element-color-deep);
827
+ }
828
+ #wenyan hr {
829
+ height: 1px;
830
+ padding: 0;
831
+ border: none;
832
+ border-top: 2px solid var(--head-title-color);
833
+ }
834
+ #wenyan img {
835
+ max-width: 90%;
836
+ display: block;
837
+ border-radius: 6px;
838
+ margin: 10px auto;
839
+ object-fit: contain;
840
+ }
841
+ #wenyan p code {
842
+ padding: 3px 3px 1px;
843
+ color: var(--element-color-linecode);
844
+ background: var(--element-color-linecode-background);
845
+ border-radius: 3px;
846
+ font-family: var(--monospace-font);
847
+ letter-spacing: 0.5px;
848
+ }
849
+ #wenyan li code {
850
+ color: var(--element-color-linecode);
851
+ }
852
+ #wenyan pre {
853
+ border-radius: 5px;
854
+ line-height: 2;
855
+ margin: 1em 0.5em;
856
+ padding: 0.5em;
857
+ box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;
858
+ }
859
+ #wenyan pre code {
860
+ font-family: var(--monospace-font);
861
+ display: block;
862
+ overflow-x: auto;
863
+ margin: 0.5em;
864
+ padding: 0;
865
+ }
866
+ #wenyan table {
867
+ border-collapse: collapse;
868
+ margin: 1.4em auto;
869
+ max-width: 100%;
870
+ table-layout: fixed;
871
+ text-align: left;
872
+ overflow: auto;
873
+ display: table;
874
+ word-wrap: break-word;
875
+ word-break: break-all;
876
+ }
877
+ #wenyan table td,
878
+ #wenyan table th {
879
+ font-size: 10px;
880
+ padding: 9px 12px;
881
+ line-height: 22px;
882
+ color: #222;
883
+ border: 1px solid var(--element-color-deep);
884
+ vertical-align: top;
885
+ }
886
+ #wenyan table th {
887
+ font-weight: bold;
888
+ background-color: var(--element-color-soo-shallow);
889
+ color: var(--element-color-deep);
890
+ }
891
+
892
+ #wenyan .footnote {
893
+ color: var(--primary-color);
894
+ }
895
+ #wenyan #footnotes p {
896
+ display: flex;
897
+ margin: 0;
898
+ font-size: 0.9em;
899
+ }
900
+ #wenyan .footnote-num {
901
+ display: inline;
902
+ width: 10%;
903
+ }
904
+ #wenyan .footnote-txt {
905
+ display: inline;
906
+ width: 90%;
907
+ word-wrap: break-word;
908
+ word-break: break-all;
909
+ }
910
+ `;
911
+ const __vite_glob_0_7 = '/*\n * Typora Theme - Pie / Author - kevinzhao2233\n * https://github.com/kevinzhao2233/typora-theme-pie\n */\n\n:root {\n --mid-1: #ffffff;\n --mid-7: #8c8c8c;\n --mid-9: #434343;\n --mid-10: #262626;\n --main-1: #fff2f0;\n --main-4: #f27f79;\n --main-5: #e6514e;\n --main-6: #da282a;\n}\n#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n color: var(--mid-10);\n letter-spacing: 0;\n font-size: 16px;\n}\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan p {\n word-spacing: 0.05rem;\n text-align: justify;\n}\n#wenyan a {\n word-wrap: break-word;\n color: var(--main-6);\n text-decoration: none;\n border-bottom: 1px solid var(--main-6);\n transition: border-bottom 0.2s;\n padding: 0 2px;\n font-weight: 500;\n text-decoration: none;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n position: relative;\n margin: 1.2em 0 1em;\n padding: 0px;\n font-weight: bold;\n cursor: text;\n}\n#wenyan h2 a,\n#wenyan h3 a {\n color: var(--mid-9);\n}\n#wenyan h1 {\n font-size: 1.5em;\n text-align: center;\n}\n#wenyan h1::after {\n display: block;\n width: 100px;\n height: 2px;\n margin: 0.2em auto 0;\n content: "";\n border-bottom: 2px dashed var(--main-6);\n}\n#wenyan h2 {\n padding-left: 6px;\n margin: 2em auto 1.4em;\n font-size: 1.3em;\n border-left: 6px solid var(--main-6);\n}\n#wenyan h3 {\n font-size: 1.2em;\n}\n#wenyan h3::before {\n display: inline-block;\n width: 6px;\n height: 6px;\n margin-right: 6px;\n margin-bottom: 0.18em;\n line-height: 1.43;\n vertical-align: middle;\n content: "";\n background-color: var(--main-5);\n border-radius: 50%;\n}\n#wenyan h4 {\n font-size: 1.2em;\n}\n#wenyan h4::before {\n display: inline-block;\n width: 6px;\n height: 2px;\n margin-right: 8px;\n margin-bottom: 0.18em;\n vertical-align: middle;\n content: "";\n background-color: var(--main-4);\n}\n#wenyan h5 {\n font-size: 1.2em;\n}\n#wenyan h6 {\n font-size: 1.2em;\n color: var(--mid-7);\n}\n#wenyan li > ol,\n#wenyan li > ul {\n margin: 0;\n}\n#wenyan hr {\n box-sizing: content-box;\n width: 100%;\n height: 1px;\n padding: 0;\n margin: 46px auto 64px;\n overflow: hidden;\n background-color: var(--main-4);\n border: 0;\n}\n#wenyan blockquote {\n position: relative;\n padding: 24px 16px 12px;\n margin: 24px 0 36px;\n font-size: 1em;\n font-style: normal;\n line-height: 1.6;\n color: var(--mid-7);\n text-indent: 0;\n border: none;\n border-left: 2px solid var(--main-6);\n}\n#wenyan blockquote blockquote {\n padding-right: 0;\n}\n#wenyan blockquote a {\n color: var(--mid-7);\n}\n#wenyan blockquote::before {\n position: absolute;\n top: 0;\n left: 12px;\n font-family: Arial, serif;\n font-size: 2em;\n font-weight: 700;\n line-height: 1em;\n color: var(--main-6);\n content: "“";\n}\n#wenyan table {\n border-collapse: collapse;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n display: table;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table td,\n#wenyan table th {\n font-size: 0.75em;\n padding: 9px 12px;\n line-height: 22px;\n vertical-align: top;\n border: 1px solid var(--main-4);\n}\n#wenyan table th {\n font-weight: bold;\n color: var(--main-6);\n background-color: var(--main-1);\n}\n#wenyan strong {\n padding: 0 1px;\n}\n#wenyan em {\n padding: 0 5px 0 2px;\n}\n#wenyan p code {\n padding: 2px 4px 1px;\n margin: 0 2px;\n font-family: var(--monospace-font);\n font-size: 0.92rem;\n color: var(--main-5);\n background-color: var(--main-1);\n border-radius: 3px;\n}\n#wenyan p code {\n vertical-align: 0.5px;\n}\n#wenyan .footnote {\n color: var(--main-5);\n background-color: var(--main-1);\n}\n#wenyan img {\n max-width: 100%;\n display: block;\n margin: 0 auto;\n border-radius: 4px;\n}\n#wenyan pre {\n border-radius: 5px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n}\n#wenyan .footnote {\n color: rgb(239, 112, 96);\n}\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n';
912
+ const __vite_glob_0_8 = '/*\n * Typora Theme - Purple / Author - hliu202\n * https://github.com/hliu202/typora-purple-theme\n */\n\n:root {\n --title-color: #8064a9;\n --text-color: #444444;\n --link-color: #2aa899;\n --code-color: #745fb5;\n --shadow-color: #eee;\n --border-quote: rgba(116, 95, 181, 0.2);\n --border: #e7e7e7;\n --link-bottom: #bbb;\n --shadow: 3px 3px 10px var(--shadow-color);\n --inline-code-bg: #f4f2f9;\n --header-weight: normal;\n}\n#wenyan {\n font-family: var(--sans-serif-font);\n color: var(--text-color);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan a {\n word-wrap: break-word;\n border-bottom: 1px solid var(--link-bottom);\n color: var(--link-color);\n text-decoration: none;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n margin: 1.2em 0 1em;\n padding: 0px;\n font-weight: var(--header-weight);\n color: var(--title-color);\n font-family: var(--sans-serif-font);\n}\n#wenyan h1 {\n text-align: center;\n}\n#wenyan h1::after {\n content: "";\n display: block;\n margin: 0.2em auto 0;\n width: 6em;\n height: 2px;\n border-bottom: 2px solid var(--title-color);\n}\n#wenyan h2 {\n padding-left: 0.4em;\n border-left: 0.4em solid var(--title-color);\n border-bottom: 1px solid var(--title-color);\n}\n#wenyan h1 {\n font-size: 1.5em;\n}\n#wenyan h2 {\n font-size: 1.3em;\n}\n#wenyan h3 {\n font-size: 1.2em;\n}\n#wenyan h4 {\n font-size: 1.2em;\n}\n#wenyan h5 {\n font-size: 1.2em;\n}\n#wenyan h6 {\n font-size: 1.2em;\n}\n#wenyan p,\n#wenyan ul,\n#wenyan ol {\n margin: 1em 0.8em;\n}\n#wenyan hr {\n margin: 1.5em auto;\n border-top: 1px solid var(--border);\n}\n#wenyan li > ol,\n#wenyan li > ul {\n margin: 0 0;\n}\n#wenyan ul,\n#wenyan ol {\n padding-left: 2em;\n}\n#wenyan ol li,\n#wenyan ul li {\n padding-left: 0.1em;\n}\n#wenyan blockquote {\n margin: 0;\n border-left: 0.3em solid var(--border-quote);\n padding-left: 1em;\n}\n#wenyan table {\n border-collapse: collapse;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n display: table;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table td,\n#wenyan table th {\n font-size: 0.75em;\n padding: 9px 12px;\n line-height: 22px;\n color: #222;\n border: 1px solid var(--border-quote);\n vertical-align: top;\n}\n#wenyan table th {\n font-weight: bold;\n color: var(--title-color);\n background-color: var(--inline-code-bg);\n}\n#wenyan strong {\n padding: 0 2px;\n font-weight: bold;\n}\n#wenyan p code {\n padding: 2px 4px;\n border-radius: 0.3em;\n font-family: var(--monospace-font);\n font-size: 0.9em;\n color: var(--code-color);\n background-color: var(--inline-code-bg);\n margin: 0 2px;\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan pre {\n border-radius: 5px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px;\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n}\n#wenyan .footnote {\n color: var(--code-color);\n background-color: var(--inline-code-bg);\n}\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n';
913
+ const __vite_glob_0_9 = '/*\n * Typora Theme - Rainbow / Author - thezbm\n * https://github.com/thezbm/typora-theme-rainbow\n */\n\n:root {\n --h-border-color: rgb(255, 191, 191);\n --h-bg-color: rgb(255, 232, 232);\n --table-border-color: rgb(255, 235, 211);\n --th-bg-color: rgb(255, 243, 228);\n --tr-bg-color: rgb(255, 249, 242);\n --code-bg-color: rgb(247, 247, 247);\n --block-shadow: 0.15em 0.15em 0.5em rgb(150, 150, 150);\n}\n#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n margin: 1.2em 0 1em;\n padding: 0px;\n font-weight: bold;\n}\n#wenyan h1 {\n font-size: 1.5em;\n text-align: center;\n text-shadow: 0.15em 0.15em 0.3em rgb(187, 187, 187);\n}\n#wenyan h2 {\n font-size: 1.3em;\n background-color: var(--h-bg-color);\n padding-left: 1em;\n padding-right: 1em;\n border-left: 0.5em solid var(--h-border-color);\n border-radius: 0.4em;\n display: inline-block;\n}\n#wenyan h3 {\n font-size: 1.3em;\n text-decoration: underline double var(--h-border-color);\n -webkit-text-decoration: underline double var(--h-border-color);\n text-decoration-thickness: 0.15em;\n}\n#wenyan h4 {\n font-size: 1.2em;\n text-decoration: underline dotted var(--h-border-color);\n -webkit-text-decoration: underline dotted var(--h-border-color);\n text-decoration-thickness: 0.2em;\n}\n#wenyan table {\n border-collapse: collapse;\n border: 0.25em solid var(--table-border-color);\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n overflow: auto;\n display: table;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table th {\n background-color: var(--th-bg-color);\n}\n#wenyan table th,\n#wenyan table td {\n font-size: 0.75em;\n text-align: center;\n border: 0.13em dashed var(--table-border-color);\n padding: 0.5em;\n padding: 9px 12px;\n line-height: 22px;\n vertical-align: top;\n}\n#wenyan table tr:nth-child(even) {\n background-color: var(--tr-bg-color);\n}\n#wenyan blockquote {\n font-size: 0.9em;\n margin: 0 1em;\n color: rgb(102, 102, 102);\n border-left: 0.25em solid rgb(169, 202, 255);\n padding: 0.5em 1em 0.6em 1em;\n}\n#wenyan blockquote::before {\n display: block;\n height: 2em;\n width: 1.5em;\n content: "🌈";\n font-size: 1.2em;\n}\n#wenyan blockquote p {\n margin: 0;\n}\n#wenyan hr {\n margin-top: 2em;\n margin-bottom: 2em;\n background-color: rgb(226, 226, 226);\n height: 0.13em;\n border: 0;\n}\n#wenyan pre {\n line-height: 2;\n padding: .5em;\n border-radius: 0.4em;\n box-shadow: var(--block-shadow);\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n font-family: var(--monospace-font);\n}\n#wenyan p code {\n font-family: var(--monospace-font);\n margin-left: 0.25em;\n margin-right: 0.25em;\n padding: 0.05em 0.3em;\n background-color: var(--code-bg-color);\n border-radius: 0.4em;\n box-shadow: 0.13em 0.13em 0.26em rgb(197, 197, 197);\n font-size: 0.9em;\n}\n#wenyan a {\n word-wrap: break-word;\n color: rgb(31, 117, 255);\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n border-radius: 5px;\n box-shadow: var(--block-shadow);\n}\n#wenyan .footnote {\n color: rgb(31, 117, 255);\n}\n#wenyan #footnotes p {\n display: flex;\n margin: 0;\n font-size: 0.9em;\n}\n#wenyan .footnote-num {\n display: inline;\n width: 10%;\n}\n#wenyan .footnote-txt {\n display: inline;\n width: 90%;\n word-wrap: break-word;\n word-break: break-all;\n}\n';
914
+ const __vite_glob_0_10 = '#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n}\n#wenyan * {\n box-sizing: border-box;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6,\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n font-size: 17px;\n line-height: 30px;\n margin-top: 20px;\n margin-bottom: 12px;\n position: relative;\n}\n#wenyan h1:before,\n#wenyan h2:before,\n#wenyan h3:before,\n#wenyan h4:before,\n#wenyan h5:before,\n#wenyan h6:before {\n content: "";\n display: inline-block;\n vertical-align: 1px;\n width: 10px;\n height: 26px;\n margin-right: 6px;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMCIgaGVpZ2h0PSIyNiIgdmlld0JveD0iMCAwIDEwIDI2IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNOS41IDYuNTY2NTlMNC40OTk5NCAxOS40MzI2TDAgMTkuNDMyNkw1LjAwMDA2IDYuNTY2NTlMOS41IDYuNTY2NTlaIiBmaWxsPSIjRkY0MDNBIi8+Cjwvc3ZnPgo=);\n background-repeat: no-repeat;\n background-size: cover;\n background-position-y: 8px;\n}\n#wenyan ul,\n#wenyan ol {\n padding-left: 1.2em;\n}\n#wenyan li {\n margin-left: 1.2em;\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan table {\n margin-left: auto;\n margin-right: auto;\n border-collapse: collapse;\n table-layout: fixed;\n overflow: auto;\n border-spacing: 0;\n font-size: 1em;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table td,\n#wenyan table th {\n height: 40px;\n padding: 9px 12px;\n line-height: 22px;\n color: #222;\n min-width: 88px;\n border: 1px solid #d8d8d8;\n vertical-align: top;\n}\n#wenyan blockquote {\n margin: 0;\n margin-bottom: 20px;\n padding: 0 16px;\n position: relative;\n color: #999;\n text-align: justify;\n}\n#wenyan blockquote:before {\n content: " ";\n left: 0;\n position: absolute;\n width: 2px;\n height: 100%;\n background: #f2f2f2;\n}\n#wenyan p code {\n font-family: var(--monospace-font);\n color: #1e6bb8;\n}\n/* 代码块 */\n#wenyan pre {\n border-radius: 3px;\n border: 1px solid #e8e8e8;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n}\n#wenyan pre code {\n font-family: var(--monospace-font);\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n}\n#wenyan hr {\n width: 100%;\n height: 1px;\n background-color: #e8e8e8;\n border: none;\n margin: 20px 0;\n}\n/* 链接 */\n#wenyan a {\n word-wrap: break-word;\n color: #0069c2;\n}\n/* 脚注 */\n#wenyan #footnotes ul {\n font-size: 0.9em;\n margin: 0;\n padding-left: 1.2em;\n}\n#wenyan #footnotes li {\n margin: 0 0 0 1.2em;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan .footnote {\n color: #0069c2;\n}\n';
915
+ const __vite_glob_0_11 = "#wenyan {\n font-family: var(--sans-serif-font);\n line-height: 1.75;\n font-size: 16px;\n}\n#wenyan * {\n box-sizing: border-box;\n}\n#wenyan h1,\n#wenyan h2,\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6,\n#wenyan p,\n#wenyan pre {\n margin: 1em 0;\n}\n#wenyan h1,\n#wenyan h2 {\n clear: left;\n font-size: 1.2em;\n font-weight: 600;\n line-height: 1.5;\n margin-bottom: 1.16667em;\n margin-top: 2.33333em;\n}\n#wenyan h3,\n#wenyan h4,\n#wenyan h5,\n#wenyan h6 {\n clear: left;\n font-size: 1.1em;\n font-weight: 600;\n line-height: 1.5;\n margin-bottom: 1.27273em;\n margin-top: 1.90909em;\n}\n#wenyan ul,\n#wenyan ol {\n padding-left: 1.2em;\n}\n#wenyan li {\n margin-left: 1.2em;\n}\n#wenyan img {\n max-width: 100%;\n height: auto;\n margin: 0 auto;\n display: block;\n}\n#wenyan table {\n border-collapse: collapse;\n font-size: 15px;\n margin: 1.4em auto;\n max-width: 100%;\n table-layout: fixed;\n text-align: left;\n width: 100%;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan table th {\n background: #ebeced;\n color: #191b1f;\n font-weight: 500;\n}\n#wenyan table td,\n#wenyan table th {\n border: 1px solid #c4c7ce;\n height: 24px;\n line-height: 24px;\n padding: 3px 12px;\n}\n#wenyan blockquote {\n border-left: 3px solid #c4c7ce;\n margin: 1.5em 0;\n padding: 0 0 1em 1em;\n color: #535861;\n}\n#wenyan code {\n margin: 0px 2px;\n padding: 3px 4px;\n border-radius: 3px;\n font-family: var(--monospace-font);\n background-color: rgb(246, 246, 246);\n}\n#wenyan pre {\n word-wrap: normal;\n background: #f8f8fa;\n border-radius: 4px;\n line-height: 2;\n margin: 1em 0.5em;\n padding: .5em;\n white-space: pre;\n word-break: normal;\n}\n#wenyan pre code {\n display: block;\n overflow-x: auto;\n margin: .5em;\n padding: 0;\n}\n#wenyan hr {\n border: none;\n border-top: 1px solid #c4c7ce;\n margin: 2em auto;\n max-width: 100%;\n width: 240px;\n}\n/* 链接 */\n#wenyan a {\n word-wrap: break-word;\n color: #0069c2;\n}\n/* 脚注 */\n#wenyan #footnotes ul {\n font-size: 0.9em;\n margin: 0;\n padding-left: 1.2em;\n}\n#wenyan #footnotes li {\n margin: 0 0 0 1.2em;\n word-wrap: break-word;\n word-break: break-all;\n}\n#wenyan .footnote {\n color: #0069c2;\n}\n";
916
+ const registry = /* @__PURE__ */ new Map();
917
+ function registerTheme(theme) {
918
+ registry.set(theme.meta.id, theme);
919
+ }
920
+ function getTheme(id) {
921
+ return registry.get(id);
922
+ }
923
+ function getAllThemes() {
924
+ return [...registry.values()];
925
+ }
926
+ const gzhBuiltInThemeMetas = [
927
+ {
928
+ id: "default",
929
+ name: "Default",
930
+ description: "A clean, classic layout ideal for long-form reading.",
931
+ appName: "默认",
932
+ author: ""
933
+ },
934
+ {
935
+ id: "orangeheart",
936
+ name: "OrangeHeart",
937
+ description: "A vibrant and elegant theme in warm orange tones.",
938
+ appName: "Orange Heart",
939
+ author: "evgo2017"
940
+ },
941
+ {
942
+ id: "rainbow",
943
+ name: "Rainbow",
944
+ description: "A colorful, lively theme with a clean layout.",
945
+ appName: "Rainbow",
946
+ author: "thezbm"
947
+ },
948
+ {
949
+ id: "lapis",
950
+ name: "Lapis",
951
+ description: "A minimal and refreshing theme in cool blue tones.",
952
+ appName: "Lapis",
953
+ author: "YiNN"
954
+ },
955
+ {
956
+ id: "pie",
957
+ name: "Pie",
958
+ description: "Inspired by sspai.com and Misty — modern, sharp, and stylish.",
959
+ appName: "Pie",
960
+ author: "kevinzhao2233"
961
+ },
962
+ {
963
+ id: "maize",
964
+ name: "Maize",
965
+ description: "A crisp, light theme with a soft maize palette.",
966
+ appName: "Maize",
967
+ author: "BEATREE"
968
+ },
969
+ {
970
+ id: "purple",
971
+ name: "Purple",
972
+ description: "Clean and minimalist, with a subtle purple accent.",
973
+ appName: "Purple",
974
+ author: "hliu202"
975
+ },
976
+ {
977
+ id: "phycat",
978
+ name: "Phycat",
979
+ description: "物理猫-薄荷:a mint-green theme with clear structure and hierarchy.",
980
+ appName: "物理猫-薄荷",
981
+ author: "sumruler"
982
+ }
983
+ ];
984
+ const otherThemeIds = ["juejin_default", "medium_default", "toutiao_default", "zhihu_default"];
985
+ const otherBuiltInThemeMetas = otherThemeIds.map((id) => ({
986
+ id,
987
+ name: "",
988
+ description: "",
989
+ appName: "",
990
+ author: ""
991
+ }));
992
+ const cssModules = /* @__PURE__ */ Object.assign({
993
+ "../assets/themes/default.css": __vite_glob_0_0,
994
+ "../assets/themes/juejin_default.css": __vite_glob_0_1,
995
+ "../assets/themes/lapis.css": __vite_glob_0_2,
996
+ "../assets/themes/maize.css": __vite_glob_0_3,
997
+ "../assets/themes/medium_default.css": __vite_glob_0_4,
998
+ "../assets/themes/orangeheart.css": __vite_glob_0_5,
999
+ "../assets/themes/phycat.css": __vite_glob_0_6,
1000
+ "../assets/themes/pie.css": __vite_glob_0_7,
1001
+ "../assets/themes/purple.css": __vite_glob_0_8,
1002
+ "../assets/themes/rainbow.css": __vite_glob_0_9,
1003
+ "../assets/themes/toutiao_default.css": __vite_glob_0_10,
1004
+ "../assets/themes/zhihu_default.css": __vite_glob_0_11
1005
+ });
1006
+ function registerAllBuiltInThemes() {
1007
+ registerBuiltInThemes(gzhBuiltInThemeMetas);
1008
+ registerBuiltInThemes(otherBuiltInThemeMetas);
1009
+ }
1010
+ function registerBuiltInThemes(themeMetas) {
1011
+ for (const meta of themeMetas) {
1012
+ const path = `../assets/themes/${meta.id}.css`;
1013
+ const loader = cssModules[path];
1014
+ if (!loader) continue;
1015
+ registerTheme(
1016
+ createTheme(meta, {
1017
+ type: "asset",
1018
+ loader: normalizeCssLoader(loader)
1019
+ })
1020
+ );
1021
+ }
1022
+ }
1023
+ function createTheme(meta, source) {
1024
+ return {
1025
+ meta,
1026
+ async getCss() {
1027
+ switch (source.type) {
1028
+ case "inline":
1029
+ return source.css;
1030
+ case "asset":
1031
+ return source.loader();
1032
+ // case "file":
1033
+ // return fs.readFile(source.path, "utf-8");
1034
+ case "url":
1035
+ const res = await fetch(source.url);
1036
+ if (!res.ok) throw new Error(`Failed to load theme CSS`);
1037
+ return res.text();
1038
+ }
1039
+ }
1040
+ };
1041
+ }
1042
+ function getAllGzhThemes() {
1043
+ return getAllThemes().filter((theme) => gzhBuiltInThemeMetas.some((meta) => meta.id === theme.meta.id));
1044
+ }
1045
+ async function createWenyanCore(options = {}) {
1046
+ const { isConvertMathJax = true, isWechat = true } = options;
1047
+ const markedClient = createMarkedClient();
1048
+ const mathJaxParser = createMathJaxParser();
1049
+ registerAllBuiltInThemes();
1050
+ registerBuiltInHlThemes();
1051
+ return {
1052
+ async handleFrontMatter(markdown) {
1053
+ return await handleFrontMatter(markdown);
1054
+ },
1055
+ async renderMarkdown(markdown) {
1056
+ const html = await markedClient.parse(markdown);
1057
+ if (isConvertMathJax) {
1058
+ return mathJaxParser.parser(html);
1059
+ }
1060
+ return html;
1061
+ },
1062
+ async applyStylesWithTheme(wenyanElement, options2 = {}) {
1063
+ const {
1064
+ themeId = "default",
1065
+ themeCss,
1066
+ hlThemeId = "solarized-light",
1067
+ hlThemeCss,
1068
+ isMacStyle = true,
1069
+ isAddFootnote = true
1070
+ } = options2;
1071
+ const [resolvedThemeCss, resolvedHlThemeCss] = await Promise.all([
1072
+ // 任务 1: 解析文章主题
1073
+ resolveCssContent(
1074
+ themeCss,
1075
+ themeId,
1076
+ getTheme,
1077
+ (id) => getAllGzhThemes().find((t) => t.meta.name.toLowerCase() === id.toLowerCase()),
1078
+ `主题不存在: ${themeId}`
1079
+ ),
1080
+ // 任务 2: 解析代码高亮主题
1081
+ resolveCssContent(
1082
+ hlThemeCss,
1083
+ hlThemeId,
1084
+ getHlTheme,
1085
+ (id) => getAllHlThemes().find((t) => t.id.toLowerCase() === id.toLowerCase()),
1086
+ `代码主题不存在: ${hlThemeId}`
1087
+ )
1088
+ ]);
1089
+ return this.applyStylesWithResolvedCss(wenyanElement, {
1090
+ themeCss: resolvedThemeCss,
1091
+ hlThemeCss: resolvedHlThemeCss,
1092
+ isMacStyle,
1093
+ isAddFootnote
1094
+ });
1095
+ },
1096
+ async applyStylesWithResolvedCss(wenyanElement, options2) {
1097
+ const { themeCss = "", hlThemeCss = "", isMacStyle = true, isAddFootnote = true } = options2;
1098
+ if (!wenyanElement) {
1099
+ throw new Error("wenyanElement不能为空");
1100
+ }
1101
+ if (isAddFootnote) {
1102
+ addFootnotes(wenyanElement);
1103
+ }
1104
+ if (isMacStyle) {
1105
+ renderMacStyle(wenyanElement);
1106
+ }
1107
+ if (themeCss) {
1108
+ renderTheme(wenyanElement, themeCss);
1109
+ applyPseudoElements(wenyanElement, themeCss);
1110
+ }
1111
+ if (hlThemeCss) {
1112
+ renderHighlightTheme(wenyanElement, hlThemeCss);
1113
+ }
1114
+ if (isWechat) {
1115
+ wechatPostRender(wenyanElement);
1116
+ wenyanElement.setAttribute("data-provider", "WenYan");
1117
+ return `${wenyanElement.outerHTML.replace(/class="mjx-solid"/g, 'fill="none" stroke-width="70"').replace(/\n<li/g, "<li").replace(/<\/li>\n/g, "</li>")}`;
1118
+ }
1119
+ return wenyanElement.outerHTML;
492
1120
  }
1121
+ };
1122
+ }
1123
+ async function resolveCssContent(directCss, id, finder, fallbackFinder, errorMessage) {
1124
+ if (directCss) {
1125
+ return replaceCSSVariables(directCss);
1126
+ }
1127
+ let theme = finder(id);
1128
+ if (!theme) {
1129
+ theme = fallbackFinder(id);
1130
+ }
1131
+ if (!theme) {
1132
+ throw new Error(errorMessage);
493
1133
  }
1134
+ const rawCss = await theme.getCss();
1135
+ return replaceCSSVariables(rawCss);
494
1136
  }
495
1137
  export {
496
- addFootnotes,
497
- buildPseudoSpan,
498
- configureMarked,
499
- extractDeclarations,
500
- getContentForGzhBuiltinTheme,
501
- getContentForGzhCustomCss,
502
- handleFrontMatter,
503
- modifyCss,
1138
+ createCssModifier,
1139
+ createWenyanCore,
1140
+ getAllGzhThemes,
1141
+ getAllHlThemes,
1142
+ getAllThemes,
1143
+ getHlTheme,
1144
+ getTheme,
1145
+ macStyleCss,
504
1146
  monospace,
505
- renderMarkdown,
506
- replaceCSSVariables,
1147
+ registerAllBuiltInThemes,
1148
+ registerBuiltInHlThemes,
1149
+ registerHlTheme,
1150
+ registerTheme,
507
1151
  sansSerif,
508
1152
  serif
509
1153
  };