md-pipe 0.7.4 → 0.7.6
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/README.md +34 -4
- package/cli-contract.yaml +27 -4
- package/dist/md-pipe.bundle.mjs +156 -119
- package/dist/md-pipe.bundle.mjs.map +4 -4
- package/docs/cli-reference.md +51 -4
- package/package.json +15 -9
- package/dist/cli.js +0 -87
package/docs/cli-reference.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
A rendering engine that transforms Markdown manuscripts into HTML/PDF through HTML-comment directives and DOM transformations, without polluting the Markdown source.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
**Version:** 0.7.
|
|
6
|
+
**Version:** 0.7.6
|
|
7
7
|
|
|
8
8
|
## Table of Contents
|
|
9
9
|
|
|
@@ -35,6 +35,8 @@ Converts HTML-comment directives into class/id/attribute-bearing HTML nodes, emb
|
|
|
35
35
|
|---|---|
|
|
36
36
|
| `PUPPETEER_EXECUTABLE_PATH` | Explicitly specify the Chromium executable path. When unset, auto-detects from Puppeteer cache and common install locations.
|
|
37
37
|
|
|
|
38
|
+
| `MD_PIPE_CHROMIUM_ARGS` | Extra command-line flags for the Chromium process the pdf stage starts, separated by spaces; a flag containing a space cannot be expressed. Set --no-sandbox where Chromium cannot create a sandbox, such as a container running as root.
|
|
39
|
+
|
|
|
38
40
|
|
|
39
41
|
### render
|
|
40
42
|
|
|
@@ -110,7 +112,8 @@ cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf
|
|
|
110
112
|
|
|
111
113
|
**Exit 0:** Rendering succeeded.
|
|
112
114
|
|
|
113
|
-
**Exit 1:** Rendering error (Chromium launch failure, PDF generation failure, etc.).
|
|
115
|
+
**Exit 1:** Rendering error (Chromium launch failure, PDF generation failure, etc.). Every failure md-pipe does not attribute to the invocation lands here, including failures reported by its dependencies, whatever their wording.
|
|
116
|
+
|
|
114
117
|
|
|
115
118
|
- **stderr:** format=`text`
|
|
116
119
|
|
|
@@ -153,7 +156,7 @@ cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf
|
|
|
153
156
|
|
|
154
157
|
</details>
|
|
155
158
|
|
|
156
|
-
**Exit 2:** Input error (file not found, syntax error, invalid pipeline specification, undefined directive in strict mode, etc.).
|
|
159
|
+
**Exit 2:** Input error (file not found, syntax error, invalid pipeline specification, missing required option, undefined directive in strict mode, etc.). Reserved for faults md-pipe raises against the invocation or the files it names, which retrying unchanged cannot clear.
|
|
157
160
|
|
|
158
161
|
|
|
159
162
|
- **stderr:** format=`text`
|
|
@@ -203,7 +206,7 @@ cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf
|
|
|
203
206
|
x-agent:
|
|
204
207
|
recommended_before_use:
|
|
205
208
|
- Check that md-pipe.config.yml exists when using themes or custom directives
|
|
206
|
-
- Verify Chromium is available when targeting pdf output
|
|
209
|
+
- Verify the optional puppeteer peer dependency is installed and Chromium is available when targeting pdf output
|
|
207
210
|
rollback:
|
|
208
211
|
supported: false
|
|
209
212
|
notes: Output files can be deleted manually; no side effects beyond file writes.
|
|
@@ -258,6 +261,50 @@ md-pipe init --theme business-report
|
|
|
258
261
|
|
|
259
262
|
**Exit 1:** Initialization error (file write failure, etc.).
|
|
260
263
|
|
|
264
|
+
- **stderr:** format=`text`
|
|
265
|
+
|
|
266
|
+
| Property | Type | Required | Description |
|
|
267
|
+
|---|---|---|---|
|
|
268
|
+
| `message` | `string` | Yes | Error message. |
|
|
269
|
+
| `file` | `string` | No | File path where the error occurred. |
|
|
270
|
+
| `line` | `integer` | No | Line number where the error occurred. |
|
|
271
|
+
| `detail` | `string` | No | Detailed error information. |
|
|
272
|
+
|
|
273
|
+
<details>
|
|
274
|
+
<summary>JSON Schema</summary>
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"type": "object",
|
|
279
|
+
"required": [
|
|
280
|
+
"message"
|
|
281
|
+
],
|
|
282
|
+
"properties": {
|
|
283
|
+
"message": {
|
|
284
|
+
"type": "string",
|
|
285
|
+
"description": "Error message."
|
|
286
|
+
},
|
|
287
|
+
"file": {
|
|
288
|
+
"type": "string",
|
|
289
|
+
"description": "File path where the error occurred."
|
|
290
|
+
},
|
|
291
|
+
"line": {
|
|
292
|
+
"type": "integer",
|
|
293
|
+
"description": "Line number where the error occurred."
|
|
294
|
+
},
|
|
295
|
+
"detail": {
|
|
296
|
+
"type": "string",
|
|
297
|
+
"description": "Detailed error information."
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
</details>
|
|
304
|
+
|
|
305
|
+
**Exit 2:** Input error (unknown option, missing option argument, excess argument, etc.). Reserved for faults md-pipe raises against the invocation, which retrying unchanged cannot clear.
|
|
306
|
+
|
|
307
|
+
|
|
261
308
|
- **stderr:** format=`text`
|
|
262
309
|
|
|
263
310
|
| Property | Type | Required | Description |
|
package/package.json
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "md-pipe",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "A rendering engine that transforms Markdown to HTML/PDF via directive-driven pipelines",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/cli.js",
|
|
7
6
|
"bin": {
|
|
8
7
|
"md-pipe": "dist/md-pipe.bundle.mjs"
|
|
9
8
|
},
|
|
10
9
|
"scripts": {
|
|
11
10
|
"generate": "cli-contracts generate",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"bundle": "node esbuild.bundle.mjs",
|
|
15
|
-
"bundle:min": "node esbuild.bundle.mjs --minify",
|
|
11
|
+
"build": "tsc && tsc -p tsconfig.peer-floor.json",
|
|
12
|
+
"bundle": "node esbuild.bundle.mjs --minify",
|
|
16
13
|
"clean": "rm -rf dist",
|
|
14
|
+
"browser:install": "puppeteer browsers install chrome",
|
|
17
15
|
"test": "vitest run",
|
|
18
16
|
"test:unit": "vitest run test/unit",
|
|
19
|
-
"prepublishOnly": "npm run clean && npm run build && npm run bundle:min",
|
|
20
17
|
"test:ci": "vitest run"
|
|
21
18
|
},
|
|
22
19
|
"keywords": [
|
|
@@ -36,12 +33,19 @@
|
|
|
36
33
|
"README.md"
|
|
37
34
|
],
|
|
38
35
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
36
|
+
"node": ">=22.12.0"
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
|
-
"puppeteer": "^25.0.2",
|
|
43
39
|
"tsx": "^4.21.0"
|
|
44
40
|
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"puppeteer": ">=22.15.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"puppeteer": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
45
49
|
"devDependencies": {
|
|
46
50
|
"@types/js-yaml": "^4.0.9",
|
|
47
51
|
"@types/node": "^22.15.21",
|
|
@@ -52,6 +56,8 @@
|
|
|
52
56
|
"handlebars": "^4.7.9",
|
|
53
57
|
"js-yaml": "^4.1.1",
|
|
54
58
|
"marked": "^18.0.3",
|
|
59
|
+
"puppeteer": "^25.0.2",
|
|
60
|
+
"puppeteer-floor": "npm:puppeteer@22.15.0",
|
|
55
61
|
"typescript": "^6.0.3",
|
|
56
62
|
"vitest": "^4.1.7"
|
|
57
63
|
}
|
package/dist/cli.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { register } from "tsx/esm/api";
|
|
3
|
-
register();
|
|
4
|
-
import * as fs from "node:fs";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { createProgram } from "./generated/program.js";
|
|
8
|
-
import { loadProjectConfig, parseFrontmatter, resolveConfig, loadTransforms, } from "./config.js";
|
|
9
|
-
import { runPipeline } from "./pipeline/index.js";
|
|
10
|
-
import { runInit } from "./commands/init.js";
|
|
11
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf-8"));
|
|
13
|
-
async function readInput(filePath) {
|
|
14
|
-
if (filePath) {
|
|
15
|
-
if (!fs.existsSync(filePath)) {
|
|
16
|
-
throw new Error(`Input file not found: ${filePath}`);
|
|
17
|
-
}
|
|
18
|
-
return fs.readFileSync(filePath, "utf-8");
|
|
19
|
-
}
|
|
20
|
-
if (process.stdin.isTTY) {
|
|
21
|
-
throw new Error("No input file specified and stdin is a terminal");
|
|
22
|
-
}
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
let data = "";
|
|
25
|
-
process.stdin.setEncoding("utf-8");
|
|
26
|
-
process.stdin.on("data", (chunk) => (data += chunk));
|
|
27
|
-
process.stdin.on("end", () => resolve(data));
|
|
28
|
-
process.stdin.on("error", reject);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
const handlers = {
|
|
32
|
-
async render(input, opts, globalOpts) {
|
|
33
|
-
try {
|
|
34
|
-
const source = await readInput(input);
|
|
35
|
-
const inputPath = input ? path.resolve(input) : undefined;
|
|
36
|
-
const inputDir = inputPath ? path.dirname(inputPath) : process.cwd();
|
|
37
|
-
const project = loadProjectConfig(globalOpts.config);
|
|
38
|
-
const { frontmatter, body } = parseFrontmatter(source);
|
|
39
|
-
const normalizedOpts = {
|
|
40
|
-
...opts,
|
|
41
|
-
styles: opts.styles ? (Array.isArray(opts.styles) ? opts.styles : [opts.styles]) : undefined,
|
|
42
|
-
scripts: opts.scripts ? (Array.isArray(opts.scripts) ? opts.scripts : [opts.scripts]) : undefined,
|
|
43
|
-
paperSize: opts.paperSize ?? "A4",
|
|
44
|
-
};
|
|
45
|
-
const config = resolveConfig(normalizedOpts, {
|
|
46
|
-
config: globalOpts.config,
|
|
47
|
-
verbose: globalOpts.verbose,
|
|
48
|
-
strict: globalOpts.strict,
|
|
49
|
-
}, frontmatter, project, inputDir);
|
|
50
|
-
if (project.transforms && project.transforms.length > 0) {
|
|
51
|
-
config.transforms = await loadTransforms(project.transforms, inputDir);
|
|
52
|
-
}
|
|
53
|
-
const startIsSource = config.pipeline.start === "preprocess";
|
|
54
|
-
const content = startIsSource ? body : source;
|
|
55
|
-
const result = await runPipeline(content, config, input);
|
|
56
|
-
if (result !== "" && config.pipeline.end !== "pdf") {
|
|
57
|
-
if (config.output) {
|
|
58
|
-
const outPath = path.resolve(config.output);
|
|
59
|
-
const dir = path.dirname(outPath);
|
|
60
|
-
if (!fs.existsSync(dir)) {
|
|
61
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
62
|
-
}
|
|
63
|
-
fs.writeFileSync(outPath, result, "utf-8");
|
|
64
|
-
if (config.verbose) {
|
|
65
|
-
process.stderr.write(`[md-pipe] Written to ${outPath}\n`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
process.stdout.write(result);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
process.stderr.write(`${err.message}\n`);
|
|
75
|
-
process.exit(err.message?.includes("not found") ||
|
|
76
|
-
err.message?.includes("Invalid pipeline")
|
|
77
|
-
? 2
|
|
78
|
-
: 1);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
async init(opts) {
|
|
82
|
-
runInit({ theme: opts.theme ?? "default", force: opts.force ?? false });
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
const program = createProgram(handlers, pkg.version);
|
|
86
|
-
program.parse();
|
|
87
|
-
//# sourceMappingURL=cli.js.map
|