koishi-plugin-luogu-saver-bot 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +13 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -54,7 +54,6 @@ __name(statusToString, "statusToString");
|
|
|
54
54
|
|
|
55
55
|
// src/index.ts
|
|
56
56
|
var import_markdown_it = __toESM(require("markdown-it"));
|
|
57
|
-
var import_plugin_katex = require("@mdit/plugin-katex");
|
|
58
57
|
var name = "luogu-saver-bot";
|
|
59
58
|
var inject = ["puppeteer"];
|
|
60
59
|
var Config = import_koishi.Schema.object({
|
|
@@ -130,16 +129,17 @@ var LuoguSaverClient = class {
|
|
|
130
129
|
return res.data;
|
|
131
130
|
}
|
|
132
131
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
async function generateHtml(title, authorInfo, markdownContent) {
|
|
133
|
+
const { katex } = await import("@mdit/plugin-katex");
|
|
134
|
+
const md = new import_markdown_it.default({
|
|
135
|
+
html: true,
|
|
136
|
+
breaks: true
|
|
137
|
+
}).use(katex, {
|
|
138
|
+
allowFunctionInTextMode: true,
|
|
139
|
+
// 允许在文本模式下使用函数
|
|
140
|
+
strict: false
|
|
141
|
+
// 禁用严格模式,防止因不标准语法报错
|
|
142
|
+
});
|
|
143
143
|
const renderedBody = md.render(markdownContent);
|
|
144
144
|
return `<!doctype html>
|
|
145
145
|
<html>
|
|
@@ -329,7 +329,7 @@ function apply(ctx, config = {}) {
|
|
|
329
329
|
const rawContent = art.content ?? art.renderedContent ?? "";
|
|
330
330
|
const title = art.title ?? "";
|
|
331
331
|
const authorInfo = `作者 UID: ${art.authorId}`;
|
|
332
|
-
const html = generateHtml(title, authorInfo, rawContent);
|
|
332
|
+
const html = await generateHtml(title, authorInfo, rawContent);
|
|
333
333
|
if (!ctx.puppeteer) return "当前没有可用的 puppeteer 服务。";
|
|
334
334
|
const page = await ctx.puppeteer.page();
|
|
335
335
|
try {
|
|
@@ -385,7 +385,7 @@ function apply(ctx, config = {}) {
|
|
|
385
385
|
const rawContent = paste.content ?? paste.renderedContent ?? "";
|
|
386
386
|
const title = `剪贴板: ${paste.id}`;
|
|
387
387
|
const authorInfo = paste.author ? `创建者: ${paste.author.name} (UID: ${paste.author.id})` : `创建者 UID: ${paste.authorId}`;
|
|
388
|
-
const html = generateHtml(title, authorInfo, rawContent);
|
|
388
|
+
const html = await generateHtml(title, authorInfo, rawContent);
|
|
389
389
|
if (!ctx.puppeteer) return "当前没有可用的 puppeteer 服务。";
|
|
390
390
|
const page = await ctx.puppeteer.page();
|
|
391
391
|
try {
|