md2gost 1.3.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.
- package/LICENSE +21 -0
- package/README.md +926 -0
- package/assets/run.ps1 +61 -0
- package/assets/styles.xml +1140 -0
- package/assets/template.dotm +0 -0
- package/dist/cli.js +92 -0
- package/dist/cli.js.map +6 -0
- package/dist/index.cjs +2165 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +142 -0
- package/dist/index.mjs +2130 -0
- package/dist/index.mjs.map +6 -0
- package/package.json +227 -0
|
Binary file
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
var import_index = __toESM(require("./index"));
|
|
28
|
+
(async function() {
|
|
29
|
+
const { Command } = await import("commander");
|
|
30
|
+
const program = new Command();
|
|
31
|
+
program.name("md2gost").description("Render Markdown files into formatted .docx or .pdf documents").argument("<input>", "Absolute or relative file path to the source Markdown document").option("-o, --output <path>", "Destination path for the rendered file").option("-f, --format <type>", 'Target output format ("docx" or "pdf")').option("-k, --keep-intermediate-docx", "Retain the intermediate .docx file after generating a PDF", false).option("-d, --disable-macros", "Disable VBA macro execution (PDF generation will be unavailable)", false).action(action);
|
|
32
|
+
program.parse(process.argv);
|
|
33
|
+
})();
|
|
34
|
+
async function action(input, options) {
|
|
35
|
+
const config = {
|
|
36
|
+
input,
|
|
37
|
+
output: options.output,
|
|
38
|
+
format: options.format,
|
|
39
|
+
keepIntermediateDocx: options.keepIntermediateDocx,
|
|
40
|
+
disableMacros: options.disableMacros,
|
|
41
|
+
progress: (totalPercent, message) => {
|
|
42
|
+
if (process.stdout.isTTY) {
|
|
43
|
+
process.stdout.clearLine(0);
|
|
44
|
+
process.stdout.cursorTo(0);
|
|
45
|
+
process.stdout.write(`[${totalPercent}%] ${message}`);
|
|
46
|
+
} else {
|
|
47
|
+
console.log(`[${totalPercent}%] ${message}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
const result = await (0, import_index.default)(config);
|
|
53
|
+
if (process.stdout.isTTY) {
|
|
54
|
+
process.stdout.write("\n");
|
|
55
|
+
}
|
|
56
|
+
result.warnings.forEach((w) => console.warn(`[WARNING] ${w}`));
|
|
57
|
+
console.log(`
|
|
58
|
+
Successfully saved to: ${result.filePath}`);
|
|
59
|
+
if (result.intermediateDocxPath) {
|
|
60
|
+
console.log(`Intermediate DOCX saved to: ${result.intermediateDocxPath}`);
|
|
61
|
+
}
|
|
62
|
+
process.exit(0);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (process.stdout.isTTY) {
|
|
65
|
+
process.stdout.write("\n");
|
|
66
|
+
}
|
|
67
|
+
if (error instanceof import_index.MDRenderError) {
|
|
68
|
+
console.error(`
|
|
69
|
+
[ERROR: ${error.code.toUpperCase()}] ${error.message}`);
|
|
70
|
+
if (error.renderedFile) {
|
|
71
|
+
console.error(`Partial file recovered at: ${error.renderedFile}`);
|
|
72
|
+
}
|
|
73
|
+
if (error.warnings && error.warnings.length > 0) {
|
|
74
|
+
console.warn("\nWarnings prior to failure:");
|
|
75
|
+
error.warnings.forEach((w) => console.warn(` - ${w}`));
|
|
76
|
+
}
|
|
77
|
+
if (error.code.endsWith("PS") && error.powershellLog && error.powershellLog.length > 0) {
|
|
78
|
+
console.error("\n--- PowerShell Log Trace ---");
|
|
79
|
+
console.error(error.powershellLog.join(""));
|
|
80
|
+
console.error("----------------------------");
|
|
81
|
+
}
|
|
82
|
+
if (error.cause) {
|
|
83
|
+
console.error("\nRoot cause:", error.cause);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
console.error("\n[FATAL] Unexpected runtime error:");
|
|
87
|
+
console.error(error);
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAA8D;AAAA,CAE7D,iBACD;AACC,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,WAAW;AAC5C,QAAM,UAAU,IAAI,QAAQ;AAE5B,UACE,KAAK,SAAS,EACd,YAAY,8DAA8D,EAC1E,SAAS,WAAW,gEAAgE,EACpF,OAAO,u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