regen.mde 0.2.2 → 0.8.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 (56) hide show
  1. package/LICENSE +16 -16
  2. package/README.md +409 -295
  3. package/bin/build-corpus-editor.js +83 -81
  4. package/bin/build-corpus.js +41 -41
  5. package/bin/postinstall.js +259 -187
  6. package/bin/regen-mdeditor-install.js +27 -27
  7. package/bin/regen-mdeditor-uninstall.js +19 -19
  8. package/bin/validate-katex.js +93 -93
  9. package/desktop/BuildCorpusEditor/BuildCorpusBridge.cs +493 -270
  10. package/desktop/BuildCorpusEditor/BuildCorpusEditor.csproj +22 -22
  11. package/desktop/BuildCorpusEditor/EditorForm.cs +853 -540
  12. package/desktop/BuildCorpusEditor/Program.cs +85 -81
  13. package/desktop/BuildCorpusEditor/app.manifest +16 -16
  14. package/dist/release/regen-mde-0.8.0-win-x64.zip +0 -0
  15. package/dist/windows-editor/BuildCorpusEditor.dll +0 -0
  16. package/dist/windows-editor/BuildCorpusEditor.exe +0 -0
  17. package/dist/windows-editor/BuildCorpusEditor.pdb +0 -0
  18. package/dist/windows-editor/BuildCorpusEditor.runtimeconfig.json +1 -1
  19. package/dist/windows-editor/wwwroot/assets/index-C_VxJk4k.js +375 -0
  20. package/dist/windows-editor/wwwroot/assets/index-Wt9zSjIw.css +1 -0
  21. package/dist/windows-editor/wwwroot/index.html +22 -22
  22. package/editor-web/index.html +21 -21
  23. package/editor-web/src/main.jsx +1044 -399
  24. package/editor-web/src/styles.css +846 -602
  25. package/editor-web/vite.config.js +13 -13
  26. package/examples/build-corpus.config.example.json +21 -21
  27. package/installer/install-regen-mde.ps1 +214 -175
  28. package/installer/regen-mde.nsi +81 -81
  29. package/package.json +10 -6
  30. package/pyproject.toml +4 -3
  31. package/requirements.txt +5 -4
  32. package/scripts/build-windows-editor.ps1 +47 -47
  33. package/scripts/package-windows-editor.ps1 +90 -90
  34. package/scripts/release-dual.mjs +105 -0
  35. package/scripts/run-corpus.ps1 +28 -28
  36. package/scripts/run-editor-implementation-plane.ps1 +226 -203
  37. package/scripts/run-required-tests.ps1 +98 -98
  38. package/scripts/run-smoke.ps1 +28 -28
  39. package/src/build_corpus/__init__.py +1 -1
  40. package/src/build_corpus/docx_exporter.py +1055 -798
  41. package/src/build_corpus/equations.py +1345 -0
  42. package/src/build_corpus/exporter.py +1488 -1195
  43. package/src/build_corpus/frontmatter.py +302 -0
  44. package/src/build_corpus/ppt_exporter.py +543 -532
  45. package/src/build_corpus/templates/__init__.py +1 -1
  46. package/src/build_corpus/validate_assets.py +46 -46
  47. package/tools/audit_corpus.py +203 -203
  48. package/tools/collect_microsoft_word_templates.py +228 -228
  49. package/tools/collect_online_docx_corpus.py +272 -272
  50. package/tools/collect_online_pptx_corpus.py +252 -252
  51. package/tools/compare_pptx_inputs_outputs.py +87 -87
  52. package/tools/roundtrip_docx_corpus.py +171 -171
  53. package/dist/release/regen.mde-0.2.2-win-x64-setup.exe +0 -0
  54. package/dist/release/regen.mde-0.2.2-win-x64.zip +0 -0
  55. package/dist/windows-editor/wwwroot/assets/index-DjJ6xmhy.js +0 -326
  56. package/dist/windows-editor/wwwroot/assets/index-_dwMNNsm.css +0 -1
@@ -1,93 +1,93 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const katex = require("katex");
4
-
5
- function extractMath(markdown) {
6
- const spans = [];
7
- const blockRe = /\$\$([\s\S]*?)\$\$/g;
8
- let masked = markdown;
9
- let match;
10
- while ((match = blockRe.exec(markdown)) !== null) {
11
- spans.push({ displayMode: true, tex: match[1].trim(), index: match.index });
12
- }
13
- masked = masked.replace(blockRe, "");
14
-
15
- for (let i = 0; i < masked.length; i++) {
16
- if (masked[i] !== "$" || isEscaped(masked, i)) continue;
17
- let end = -1;
18
- for (let j = i + 1; j < masked.length; j++) {
19
- if (masked[j] === "\n") break;
20
- if (masked[j] === "$" && !isEscaped(masked, j)) {
21
- end = j;
22
- break;
23
- }
24
- }
25
- if (end > i + 1) {
26
- spans.push({ displayMode: false, tex: masked.slice(i + 1, end).trim(), index: i });
27
- i = end;
28
- }
29
- }
30
- return spans;
31
- }
32
-
33
- function isEscaped(text, index) {
34
- let slashCount = 0;
35
- for (let i = index - 1; i >= 0 && text[i] === "\\"; i--) {
36
- slashCount++;
37
- }
38
- return slashCount % 2 === 1;
39
- }
40
-
41
- function validateFile(filePath) {
42
- const markdown = fs.readFileSync(filePath, "utf8");
43
- const spans = extractMath(markdown);
44
- const failures = [];
45
- for (const span of spans) {
46
- try {
47
- katex.renderToString(span.tex, {
48
- displayMode: span.displayMode,
49
- throwOnError: true,
50
- strict: "ignore",
51
- trust: false,
52
- });
53
- } catch (error) {
54
- failures.push({
55
- index: span.index,
56
- displayMode: span.displayMode,
57
- tex: span.tex.slice(0, 500),
58
- error: error.message,
59
- });
60
- }
61
- }
62
- return {
63
- file: filePath,
64
- math_spans: spans.length,
65
- failures: failures.length,
66
- failure_samples: failures.slice(0, 50),
67
- };
68
- }
69
-
70
- function main() {
71
- const target = process.argv[2];
72
- if (!target) {
73
- console.error("Usage: node validate_katex.js <markdown-file-or-directory>");
74
- process.exit(2);
75
- }
76
- const stat = fs.statSync(target);
77
- const files = [];
78
- if (stat.isDirectory()) {
79
- for (const entry of fs.readdirSync(target, { recursive: true })) {
80
- const full = path.join(target, entry);
81
- if (fs.existsSync(full) && fs.statSync(full).isFile() && full.endsWith(".md")) {
82
- files.push(full);
83
- }
84
- }
85
- } else {
86
- files.push(target);
87
- }
88
- const results = files.map(validateFile);
89
- console.log(JSON.stringify({ files: results.length, results }, null, 2));
90
- process.exit(results.some((result) => result.failures > 0) ? 1 : 0);
91
- }
92
-
93
- main();
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const katex = require("katex");
4
+
5
+ function extractMath(markdown) {
6
+ const spans = [];
7
+ const blockRe = /\$\$([\s\S]*?)\$\$/g;
8
+ let masked = markdown;
9
+ let match;
10
+ while ((match = blockRe.exec(markdown)) !== null) {
11
+ spans.push({ displayMode: true, tex: match[1].trim(), index: match.index });
12
+ }
13
+ masked = masked.replace(blockRe, "");
14
+
15
+ for (let i = 0; i < masked.length; i++) {
16
+ if (masked[i] !== "$" || isEscaped(masked, i)) continue;
17
+ let end = -1;
18
+ for (let j = i + 1; j < masked.length; j++) {
19
+ if (masked[j] === "\n") break;
20
+ if (masked[j] === "$" && !isEscaped(masked, j)) {
21
+ end = j;
22
+ break;
23
+ }
24
+ }
25
+ if (end > i + 1) {
26
+ spans.push({ displayMode: false, tex: masked.slice(i + 1, end).trim(), index: i });
27
+ i = end;
28
+ }
29
+ }
30
+ return spans;
31
+ }
32
+
33
+ function isEscaped(text, index) {
34
+ let slashCount = 0;
35
+ for (let i = index - 1; i >= 0 && text[i] === "\\"; i--) {
36
+ slashCount++;
37
+ }
38
+ return slashCount % 2 === 1;
39
+ }
40
+
41
+ function validateFile(filePath) {
42
+ const markdown = fs.readFileSync(filePath, "utf8");
43
+ const spans = extractMath(markdown);
44
+ const failures = [];
45
+ for (const span of spans) {
46
+ try {
47
+ katex.renderToString(span.tex, {
48
+ displayMode: span.displayMode,
49
+ throwOnError: true,
50
+ strict: "ignore",
51
+ trust: false,
52
+ });
53
+ } catch (error) {
54
+ failures.push({
55
+ index: span.index,
56
+ displayMode: span.displayMode,
57
+ tex: span.tex.slice(0, 500),
58
+ error: error.message,
59
+ });
60
+ }
61
+ }
62
+ return {
63
+ file: filePath,
64
+ math_spans: spans.length,
65
+ failures: failures.length,
66
+ failure_samples: failures.slice(0, 50),
67
+ };
68
+ }
69
+
70
+ function main() {
71
+ const target = process.argv[2];
72
+ if (!target) {
73
+ console.error("Usage: node validate_katex.js <markdown-file-or-directory>");
74
+ process.exit(2);
75
+ }
76
+ const stat = fs.statSync(target);
77
+ const files = [];
78
+ if (stat.isDirectory()) {
79
+ for (const entry of fs.readdirSync(target, { recursive: true })) {
80
+ const full = path.join(target, entry);
81
+ if (fs.existsSync(full) && fs.statSync(full).isFile() && full.endsWith(".md")) {
82
+ files.push(full);
83
+ }
84
+ }
85
+ } else {
86
+ files.push(target);
87
+ }
88
+ const results = files.map(validateFile);
89
+ console.log(JSON.stringify({ files: results.length, results }, null, 2));
90
+ process.exit(results.some((result) => result.failures > 0) ? 1 : 0);
91
+ }
92
+
93
+ main();