nodebb-plugin-katex2 1.0.2 → 1.0.4
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/package.json +1 -1
- package/plugin.json +1 -2
- package/scripts/copy-katex.js +40 -27
- package/static/js/render.js +1 -1
package/package.json
CHANGED
package/plugin.json
CHANGED
package/scripts/copy-katex.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
const fs = require("fs");
|
|
@@ -25,25 +26,25 @@ function copyDir(src, dest) {
|
|
|
25
26
|
function findKatexDist() {
|
|
26
27
|
const pluginRoot = path.resolve(__dirname, "..");
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
pluginRoot,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
// Все возможные пути поиска
|
|
30
|
+
const searchPaths = [
|
|
31
|
+
// 1. Локальный node_modules плагина
|
|
32
|
+
path.join(pluginRoot, "node_modules", "katex", "dist"),
|
|
33
|
+
// 2. Hoisted в NodeBB (2 уровня вверх)
|
|
34
|
+
path.join(pluginRoot, "..", "..", "node_modules", "katex", "dist"),
|
|
35
|
+
// 3. Hoisted выше (3 уровня)
|
|
36
|
+
path.join(pluginRoot, "..", "..", "..", "node_modules", "katex", "dist"),
|
|
37
|
+
// 4. В соседней папке (параллельно плагину)
|
|
38
|
+
path.join(pluginRoot, "..", "katex", "dist"),
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
console.log("[KaTeX] Searching for katex dist...");
|
|
42
|
+
for (const searchPath of searchPaths) {
|
|
43
|
+
console.log(" Checking:", searchPath);
|
|
44
|
+
if (fs.existsSync(searchPath)) {
|
|
45
|
+
console.log("[KaTeX] ✓ Found at:", searchPath);
|
|
46
|
+
return searchPath;
|
|
47
|
+
}
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
return null;
|
|
@@ -53,25 +54,37 @@ try {
|
|
|
53
54
|
console.log("[KaTeX Plugin] Running postinstall...");
|
|
54
55
|
|
|
55
56
|
const pluginRoot = path.resolve(__dirname, "..");
|
|
56
|
-
const katexSource = findKatexDist();
|
|
57
57
|
const katexDest = path.join(pluginRoot, "static", "katex");
|
|
58
58
|
|
|
59
|
+
// Ищем KaTeX
|
|
60
|
+
const katexSource = findKatexDist();
|
|
61
|
+
|
|
59
62
|
if (!katexSource) {
|
|
60
|
-
console.
|
|
61
|
-
|
|
63
|
+
console.warn("[KaTeX] WARNING: katex not found!");
|
|
64
|
+
console.warn("[KaTeX] This is normal during initial npm install.");
|
|
65
|
+
console.warn(
|
|
66
|
+
"[KaTeX] Run 'npm rebuild nodebb-plugin-katex2' after installation completes.",
|
|
67
|
+
);
|
|
68
|
+
// Не блокируем установку
|
|
69
|
+
process.exit(0);
|
|
62
70
|
}
|
|
63
71
|
|
|
72
|
+
// Удаляем старую директорию
|
|
64
73
|
if (fs.existsSync(katexDest)) {
|
|
74
|
+
console.log("[KaTeX] Removing old directory...");
|
|
65
75
|
fs.rmSync(katexDest, { recursive: true, force: true });
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
|
|
69
|
-
console.log("[KaTeX] Copying
|
|
78
|
+
// Копируем файлы
|
|
79
|
+
console.log("[KaTeX] Copying files...");
|
|
80
|
+
console.log("[KaTeX] From:", katexSource);
|
|
81
|
+
console.log("[KaTeX] To:", katexDest);
|
|
70
82
|
|
|
71
83
|
copyDir(katexSource, katexDest);
|
|
72
84
|
|
|
73
|
-
console.log("[KaTeX] Postinstall completed!");
|
|
85
|
+
console.log("[KaTeX] ✓ Postinstall completed!");
|
|
74
86
|
} catch (err) {
|
|
75
|
-
console.error("[KaTeX] Postinstall failed:", err);
|
|
76
|
-
|
|
87
|
+
console.error("[KaTeX] ✗ Postinstall failed:", err.message);
|
|
88
|
+
// Не блокируем установку
|
|
89
|
+
process.exit(0);
|
|
77
90
|
}
|
package/static/js/render.js
CHANGED
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
// const basePath = "/plugins/nodebb-plugin-katex/node_modules/katex/dist/";
|
|
121
121
|
// Находим правильный путь
|
|
122
122
|
// Путь к файлам через modules
|
|
123
|
-
const basePath = "/assets/plugins/nodebb-plugin-
|
|
123
|
+
const basePath = "/assets/plugins/nodebb-plugin-katex2/katex/";
|
|
124
124
|
|
|
125
125
|
// Параллельная загрузка всех файлов
|
|
126
126
|
await Promise.all([
|