koishi-plugin-latex-render 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +5 -3
- package/lib/index.js +5 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -80,7 +80,7 @@ function autoWrapLatex(text) {
|
|
|
80
80
|
}
|
|
81
81
|
const leading = chunk.slice(0, chunk.indexOf(trimmed));
|
|
82
82
|
const trailing = chunk.slice(chunk.indexOf(trimmed) + trimmed.length);
|
|
83
|
-
const mathMatch = trimmed.match(/^([\s
|
|
83
|
+
const mathMatch = trimmed.match(/^([\s::,,。;;\*\#`~]*)(.*?)([\s::,,。;;\*\#`~]*)$/);
|
|
84
84
|
const prefix = mathMatch ? mathMatch[1] : "";
|
|
85
85
|
const coreMath = mathMatch ? mathMatch[2] : trimmed;
|
|
86
86
|
const suffix = mathMatch ? mathMatch[3] : "";
|
|
@@ -296,10 +296,12 @@ async function renderLatex(ctx, content, config) {
|
|
|
296
296
|
try {
|
|
297
297
|
page = await ctx.puppeteer.page();
|
|
298
298
|
await page.setContent(html, {
|
|
299
|
-
waitUntil: "
|
|
299
|
+
waitUntil: "networkidle2",
|
|
300
|
+
// 修改 1:改成 networkidle2,防止国内 CDN 少量挂起导致超时
|
|
300
301
|
timeout: 3e4
|
|
301
302
|
});
|
|
302
|
-
await
|
|
303
|
+
await page.evaluateHandle("document.fonts.ready");
|
|
304
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
303
305
|
const actualHeight = await page.evaluate(() => document.body ? document.body.scrollHeight : 0);
|
|
304
306
|
const finalHeight = Math.max(actualHeight + 20, height);
|
|
305
307
|
const buffer = await page.screenshot({
|
package/lib/index.js
CHANGED
|
@@ -80,7 +80,7 @@ function autoWrapLatex(text) {
|
|
|
80
80
|
}
|
|
81
81
|
const leading = chunk.slice(0, chunk.indexOf(trimmed));
|
|
82
82
|
const trailing = chunk.slice(chunk.indexOf(trimmed) + trimmed.length);
|
|
83
|
-
const mathMatch = trimmed.match(/^([\s
|
|
83
|
+
const mathMatch = trimmed.match(/^([\s::,,。;;\*\#`~]*)(.*?)([\s::,,。;;\*\#`~]*)$/);
|
|
84
84
|
const prefix = mathMatch ? mathMatch[1] : "";
|
|
85
85
|
const coreMath = mathMatch ? mathMatch[2] : trimmed;
|
|
86
86
|
const suffix = mathMatch ? mathMatch[3] : "";
|
|
@@ -296,10 +296,12 @@ async function renderLatex(ctx, content, config) {
|
|
|
296
296
|
try {
|
|
297
297
|
page = await ctx.puppeteer.page();
|
|
298
298
|
await page.setContent(html, {
|
|
299
|
-
waitUntil: "
|
|
299
|
+
waitUntil: "networkidle2",
|
|
300
|
+
// 修改 1:改成 networkidle2,防止国内 CDN 少量挂起导致超时
|
|
300
301
|
timeout: 3e4
|
|
301
302
|
});
|
|
302
|
-
await
|
|
303
|
+
await page.evaluateHandle("document.fonts.ready");
|
|
304
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
303
305
|
const actualHeight = await page.evaluate(() => document.body ? document.body.scrollHeight : 0);
|
|
304
306
|
const finalHeight = Math.max(actualHeight + 20, height);
|
|
305
307
|
const buffer = await page.screenshot({
|