md-pipe 0.0.1 → 0.1.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/README.md +189 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +85 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +28 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +158 -0
- package/dist/config.js.map +1 -0
- package/dist/generated/commands.d.ts +7 -0
- package/dist/generated/commands.js +63 -0
- package/dist/generated/commands.js.map +1 -0
- package/dist/generated/index.d.ts +6 -0
- package/dist/generated/index.js +7 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/policy.d.ts +101 -0
- package/dist/generated/policy.js +148 -0
- package/dist/generated/policy.js.map +1 -0
- package/dist/generated/program.d.ts +19 -0
- package/dist/generated/program.js +52 -0
- package/dist/generated/program.js.map +1 -0
- package/dist/generated/schemas.d.ts +26 -0
- package/dist/generated/schemas.js +30 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +65 -0
- package/dist/generated/types.js +3 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/pipeline/html.d.ts +2 -0
- package/dist/pipeline/html.js +49 -0
- package/dist/pipeline/html.js.map +1 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +48 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/pdf.d.ts +2 -0
- package/dist/pipeline/pdf.js +76 -0
- package/dist/pipeline/pdf.js.map +1 -0
- package/dist/pipeline/preprocess.d.ts +2 -0
- package/dist/pipeline/preprocess.js +134 -0
- package/dist/pipeline/preprocess.js.map +1 -0
- package/dist/pipeline/render.d.ts +1 -0
- package/dist/pipeline/render.js +5 -0
- package/dist/pipeline/render.js.map +1 -0
- package/dist/pipeline/transform.d.ts +2 -0
- package/dist/pipeline/transform.js +75 -0
- package/dist/pipeline/transform.js.map +1 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -8
- package/index.js +0 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { DerivedPolicy, IntrospectionResult } from "cli-contracts/policy";
|
|
2
|
+
export type { DerivedPolicy, IntrospectionResult };
|
|
3
|
+
export declare const commandDefinitions: {
|
|
4
|
+
readonly render: {
|
|
5
|
+
readonly effects: {
|
|
6
|
+
readonly riskLevel: "low";
|
|
7
|
+
readonly writes: readonly [{
|
|
8
|
+
readonly target: "output file";
|
|
9
|
+
readonly description: "Writes the rendered result to a file (when -o is specified).";
|
|
10
|
+
readonly overwrite: true;
|
|
11
|
+
readonly idempotent: true;
|
|
12
|
+
readonly idempotentNote: "Produces identical output given the same input and settings.";
|
|
13
|
+
}];
|
|
14
|
+
};
|
|
15
|
+
readonly options: readonly [{
|
|
16
|
+
readonly name: "output";
|
|
17
|
+
readonly schema: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
};
|
|
20
|
+
readonly file: {
|
|
21
|
+
readonly mode: "write";
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "pipeline";
|
|
25
|
+
readonly schema: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "theme";
|
|
30
|
+
readonly schema: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "styles";
|
|
35
|
+
readonly schema: {
|
|
36
|
+
readonly type: "array";
|
|
37
|
+
readonly items: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "scripts";
|
|
43
|
+
readonly schema: {
|
|
44
|
+
readonly type: "array";
|
|
45
|
+
readonly items: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "paper-size";
|
|
51
|
+
readonly schema: {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
readonly enum: readonly ["A4", "A3", "Letter", "Legal", "Tabloid"];
|
|
54
|
+
readonly default: "A4";
|
|
55
|
+
};
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "landscape";
|
|
58
|
+
readonly schema: {
|
|
59
|
+
readonly type: "boolean";
|
|
60
|
+
readonly default: false;
|
|
61
|
+
};
|
|
62
|
+
}, {
|
|
63
|
+
readonly name: "header";
|
|
64
|
+
readonly schema: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "margin";
|
|
69
|
+
readonly schema: {
|
|
70
|
+
readonly type: "string";
|
|
71
|
+
};
|
|
72
|
+
}];
|
|
73
|
+
};
|
|
74
|
+
readonly init: {
|
|
75
|
+
readonly effects: {
|
|
76
|
+
readonly riskLevel: "medium";
|
|
77
|
+
readonly writes: readonly [{
|
|
78
|
+
readonly target: "md-pipe.config.yml";
|
|
79
|
+
readonly description: "Generates a config file template.";
|
|
80
|
+
}];
|
|
81
|
+
};
|
|
82
|
+
readonly options: readonly [{
|
|
83
|
+
readonly name: "theme";
|
|
84
|
+
readonly schema: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
readonly default: "default";
|
|
87
|
+
};
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "force";
|
|
90
|
+
readonly schema: {
|
|
91
|
+
readonly type: "boolean";
|
|
92
|
+
readonly default: false;
|
|
93
|
+
};
|
|
94
|
+
readonly effects: {
|
|
95
|
+
readonly riskLevel: "high";
|
|
96
|
+
readonly overwrites: true;
|
|
97
|
+
};
|
|
98
|
+
}];
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export declare function deriveCommandPolicy(commandId: string, optionValues: Record<string, unknown>): IntrospectionResult;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
import { derivePolicy, isOptionActive } from "cli-contracts/policy";
|
|
3
|
+
export const commandDefinitions = {
|
|
4
|
+
"render": {
|
|
5
|
+
"effects": {
|
|
6
|
+
"riskLevel": "low",
|
|
7
|
+
"writes": [
|
|
8
|
+
{
|
|
9
|
+
"target": "output file",
|
|
10
|
+
"description": "Writes the rendered result to a file (when -o is specified).",
|
|
11
|
+
"overwrite": true,
|
|
12
|
+
"idempotent": true,
|
|
13
|
+
"idempotentNote": "Produces identical output given the same input and settings."
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"options": [
|
|
18
|
+
{
|
|
19
|
+
"name": "output",
|
|
20
|
+
"schema": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"file": {
|
|
24
|
+
"mode": "write"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "pipeline",
|
|
29
|
+
"schema": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "theme",
|
|
35
|
+
"schema": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "styles",
|
|
41
|
+
"schema": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "scripts",
|
|
50
|
+
"schema": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "paper-size",
|
|
59
|
+
"schema": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"enum": [
|
|
62
|
+
"A4",
|
|
63
|
+
"A3",
|
|
64
|
+
"Letter",
|
|
65
|
+
"Legal",
|
|
66
|
+
"Tabloid"
|
|
67
|
+
],
|
|
68
|
+
"default": "A4"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "landscape",
|
|
73
|
+
"schema": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"default": false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "header",
|
|
80
|
+
"schema": {
|
|
81
|
+
"type": "string"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "margin",
|
|
86
|
+
"schema": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"init": {
|
|
93
|
+
"effects": {
|
|
94
|
+
"riskLevel": "medium",
|
|
95
|
+
"writes": [
|
|
96
|
+
{
|
|
97
|
+
"target": "md-pipe.config.yml",
|
|
98
|
+
"description": "Generates a config file template."
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"options": [
|
|
103
|
+
{
|
|
104
|
+
"name": "theme",
|
|
105
|
+
"schema": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"default": "default"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "force",
|
|
112
|
+
"schema": {
|
|
113
|
+
"type": "boolean",
|
|
114
|
+
"default": false
|
|
115
|
+
},
|
|
116
|
+
"effects": {
|
|
117
|
+
"riskLevel": "high",
|
|
118
|
+
"overwrites": true
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
export function deriveCommandPolicy(commandId, optionValues) {
|
|
125
|
+
const def = commandDefinitions[commandId];
|
|
126
|
+
if (!def)
|
|
127
|
+
throw new Error(`Unknown command: ${commandId}`);
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
const cmdDef = def;
|
|
130
|
+
const options = {};
|
|
131
|
+
const activeOptions = [];
|
|
132
|
+
for (const optDef of cmdDef.options ?? []) {
|
|
133
|
+
const value = optionValues[optDef.name];
|
|
134
|
+
const specified = optDef.name in optionValues && value !== undefined;
|
|
135
|
+
options[optDef.name] = { value, specified, definition: optDef };
|
|
136
|
+
if (isOptionActive(optDef, value, specified)) {
|
|
137
|
+
activeOptions.push(optDef.name);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const policy = derivePolicy({
|
|
141
|
+
commandId,
|
|
142
|
+
commandEffects: cmdDef.effects,
|
|
143
|
+
options,
|
|
144
|
+
env: cmdDef.env,
|
|
145
|
+
});
|
|
146
|
+
return { command: commandId, activeOptions, policy };
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/generated/policy.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKpE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE;gBACR;oBACE,QAAQ,EAAE,aAAa;oBACvB,aAAa,EAAE,8DAA8D;oBAC7E,WAAW,EAAE,IAAI;oBACjB,YAAY,EAAE,IAAI;oBAClB,gBAAgB,EAAE,8DAA8D;iBACjF;aACF;SACF;QACD,SAAS,EAAE;YACT;gBACE,MAAM,EAAE,QAAQ;gBAChB,QAAQ,EAAE;oBACR,MAAM,EAAE,QAAQ;iBACjB;gBACD,MAAM,EAAE;oBACN,MAAM,EAAE,OAAO;iBAChB;aACF;YACD;gBACE,MAAM,EAAE,UAAU;gBAClB,QAAQ,EAAE;oBACR,MAAM,EAAE,QAAQ;iBACjB;aACF;YACD;gBACE,MAAM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
+
render: (input: string | undefined, options: {
|
|
4
|
+
output?: string;
|
|
5
|
+
pipeline?: string;
|
|
6
|
+
theme?: string;
|
|
7
|
+
styles?: string;
|
|
8
|
+
scripts?: string;
|
|
9
|
+
paperSize?: string;
|
|
10
|
+
landscape?: boolean;
|
|
11
|
+
header?: string;
|
|
12
|
+
margin?: string;
|
|
13
|
+
}, parentOpts: Record<string, unknown>) => Promise<void>;
|
|
14
|
+
init: (options: {
|
|
15
|
+
theme?: string;
|
|
16
|
+
force?: boolean;
|
|
17
|
+
}, parentOpts: Record<string, unknown>) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createProgram(handlers: CommandHandlers, version: string): Command;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { deriveCommandPolicy } from "./policy.js";
|
|
4
|
+
export function createProgram(handlers, version) {
|
|
5
|
+
const program = new Command();
|
|
6
|
+
program
|
|
7
|
+
.name("md-pipe")
|
|
8
|
+
.version(version, "-V, --version")
|
|
9
|
+
.description("Extended Markdown rendering toolchain.");
|
|
10
|
+
program.option("-c, --config <value>", "Path to the project config file. Auto-detects md-pipe.config.yml when omitted.");
|
|
11
|
+
program.option("-v, --verbose", "Enable verbose logging.", false);
|
|
12
|
+
program.option("--strict", "Treat undefined directives as errors. Overrides the config strictDirectives setting. Recommended for CI usage.\n", false);
|
|
13
|
+
program.option("--introspect", "Output derived policy as JSON without executing the command");
|
|
14
|
+
program
|
|
15
|
+
.command("render", { isDefault: true, hidden: true })
|
|
16
|
+
.description("Render a Markdown file through the pipeline.")
|
|
17
|
+
.argument("[input]", "Input Markdown file. Reads from stdin when omitted.")
|
|
18
|
+
.option("-o, --output <value>", "Output file path. Writes to stdout when omitted.")
|
|
19
|
+
.option("-p, --pipeline <value>", "Pipeline range in [start.]end format. Omitting start begins from the .md source. Examples: .html (source→html), .pdf (source→pdf), .render (source→render), render.html, transform.pdf, html.pdf. When omitted, inferred from -o extension (.html → html, .pdf → pdf). When -o is also omitted, follows frontmatter / config (default: html).\n")
|
|
20
|
+
.option("-t, --theme <value>", "Theme name. Applies a preset defined in the project config themes section. Overrides frontmatter theme setting.\n")
|
|
21
|
+
.option("--styles <value>", "Additional CSS file paths. Multiple values allowed. Appended after theme assets in load order.\n")
|
|
22
|
+
.option("--scripts <value>", "Additional JavaScript file paths. Multiple values allowed. Appended after theme assets in load order.\n")
|
|
23
|
+
.option("--paper-size <value>", "Paper size for the pdf stage. Overrides frontmatter paper.size.", "A4")
|
|
24
|
+
.option("--landscape", "Landscape orientation for the pdf stage.", false)
|
|
25
|
+
.option("--header <value>", "Page header text for the pdf stage.")
|
|
26
|
+
.option("--margin <value>", "Page margin for the pdf stage. Example: 16mm, 18mm.")
|
|
27
|
+
.action(async (input, opts, cmd) => {
|
|
28
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
29
|
+
if (globalOpts.introspect) {
|
|
30
|
+
const policy = deriveCommandPolicy("render", opts);
|
|
31
|
+
console.log(JSON.stringify(policy, null, 2));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
await handlers.render(input, opts, globalOpts);
|
|
35
|
+
});
|
|
36
|
+
program
|
|
37
|
+
.command("init")
|
|
38
|
+
.description("Initialize a md-pipe project.")
|
|
39
|
+
.option("-t, --theme <value>", "Initial theme name to scaffold.", "default")
|
|
40
|
+
.option("-f, --force", "Overwrite existing config file.", false)
|
|
41
|
+
.action(async (opts, cmd) => {
|
|
42
|
+
const globalOpts = cmd.optsWithGlobals();
|
|
43
|
+
if (globalOpts.introspect) {
|
|
44
|
+
const policy = deriveCommandPolicy("init", opts);
|
|
45
|
+
console.log(JSON.stringify(policy, null, 2));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
await handlers.init(opts, globalOpts);
|
|
49
|
+
});
|
|
50
|
+
return program;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -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AACjB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const schemas: {
|
|
2
|
+
readonly ErrorMessage: {
|
|
3
|
+
readonly type: "object";
|
|
4
|
+
readonly required: readonly ["message"];
|
|
5
|
+
readonly properties: {
|
|
6
|
+
readonly message: {
|
|
7
|
+
readonly type: "string";
|
|
8
|
+
readonly description: "Error message.";
|
|
9
|
+
};
|
|
10
|
+
readonly file: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "File path where the error occurred.";
|
|
13
|
+
};
|
|
14
|
+
readonly line: {
|
|
15
|
+
readonly type: "integer";
|
|
16
|
+
readonly description: "Line number where the error occurred.";
|
|
17
|
+
};
|
|
18
|
+
readonly detail: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Detailed error information.";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const renderExitCodes: readonly [0, 1, 2];
|
|
26
|
+
export declare const initExitCodes: readonly [0, 1, 3];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
export const schemas = {
|
|
3
|
+
ErrorMessage: {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": [
|
|
6
|
+
"message"
|
|
7
|
+
],
|
|
8
|
+
"properties": {
|
|
9
|
+
"message": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Error message."
|
|
12
|
+
},
|
|
13
|
+
"file": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "File path where the error occurred."
|
|
16
|
+
},
|
|
17
|
+
"line": {
|
|
18
|
+
"type": "integer",
|
|
19
|
+
"description": "Line number where the error occurred."
|
|
20
|
+
},
|
|
21
|
+
"detail": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Detailed error information."
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const renderExitCodes = [0, 1, 2];
|
|
29
|
+
export const initExitCodes = [0, 1, 3];
|
|
30
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/generated/schemas.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,YAAY,EAAE;QACZ,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE;YACV,SAAS;SACV;QACD,YAAY,EAAE;YACZ,SAAS,EAAE;gBACT,MAAM,EAAE,QAAQ;gBAChB,aAAa,EAAE,gBAAgB;aAChC;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,QAAQ;gBAChB,aAAa,EAAE,qCAAqC;aACrD;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;gBACjB,aAAa,EAAE,uCAAuC;aACvD;YACD,QAAQ,EAAE;gBACR,MAAM,EAAE,QAAQ;gBAChB,aAAa,EAAE,6BAA6B;aAC7C;SACF;KACF;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface RenderArgs {
|
|
2
|
+
input?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface RenderOptions {
|
|
5
|
+
output?: string;
|
|
6
|
+
pipeline?: string;
|
|
7
|
+
theme?: string;
|
|
8
|
+
styles?: string[];
|
|
9
|
+
scripts?: string[];
|
|
10
|
+
paperSize?: "A4" | "A3" | "Letter" | "Legal" | "Tabloid";
|
|
11
|
+
landscape?: boolean;
|
|
12
|
+
header?: string;
|
|
13
|
+
margin?: string;
|
|
14
|
+
}
|
|
15
|
+
export type RenderExitCode = 0 | 1 | 2;
|
|
16
|
+
export type RenderExitResult = {
|
|
17
|
+
exitCode: 0;
|
|
18
|
+
} | {
|
|
19
|
+
exitCode: 1;
|
|
20
|
+
stderr: {
|
|
21
|
+
message: string;
|
|
22
|
+
file?: string;
|
|
23
|
+
line?: number;
|
|
24
|
+
detail?: string;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
exitCode: 2;
|
|
28
|
+
stderr: {
|
|
29
|
+
message: string;
|
|
30
|
+
file?: string;
|
|
31
|
+
line?: number;
|
|
32
|
+
detail?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export interface InitOptions {
|
|
36
|
+
theme?: string;
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type InitExitCode = 0 | 1 | 3;
|
|
40
|
+
export type InitExitResult = {
|
|
41
|
+
exitCode: 0;
|
|
42
|
+
stdout: string;
|
|
43
|
+
} | {
|
|
44
|
+
exitCode: 1;
|
|
45
|
+
stderr: {
|
|
46
|
+
message: string;
|
|
47
|
+
file?: string;
|
|
48
|
+
line?: number;
|
|
49
|
+
detail?: string;
|
|
50
|
+
};
|
|
51
|
+
} | {
|
|
52
|
+
exitCode: 3;
|
|
53
|
+
stderr: {
|
|
54
|
+
message: string;
|
|
55
|
+
file?: string;
|
|
56
|
+
line?: number;
|
|
57
|
+
detail?: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export interface ErrorMessage {
|
|
61
|
+
message: string;
|
|
62
|
+
file?: string;
|
|
63
|
+
line?: number;
|
|
64
|
+
detail?: string;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/generated/types.ts"],"names":[],"mappings":"AAAA,gDAAgD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
function readAsset(filePath, baseDir) {
|
|
4
|
+
const abs = path.resolve(baseDir, filePath);
|
|
5
|
+
return fs.readFileSync(abs, "utf-8");
|
|
6
|
+
}
|
|
7
|
+
export function buildHtml(body, config) {
|
|
8
|
+
const baseDir = config.inputDir ?? process.cwd();
|
|
9
|
+
const cssBlocks = config.styles
|
|
10
|
+
.map((s) => {
|
|
11
|
+
try {
|
|
12
|
+
return `<style>\n${readAsset(s, baseDir)}\n</style>`;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
if (config.verbose) {
|
|
16
|
+
process.stderr.write(`[WARN] Could not read CSS: ${s}\n`);
|
|
17
|
+
}
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join("\n");
|
|
23
|
+
const jsBlocks = config.scripts
|
|
24
|
+
.map((s) => {
|
|
25
|
+
try {
|
|
26
|
+
return `<script>\n${readAsset(s, baseDir)}\n</script>`;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
if (config.verbose) {
|
|
30
|
+
process.stderr.write(`[WARN] Could not read script: ${s}\n`);
|
|
31
|
+
}
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.join("\n");
|
|
37
|
+
return `<!DOCTYPE html>
|
|
38
|
+
<html>
|
|
39
|
+
<head>
|
|
40
|
+
<meta charset="utf-8">
|
|
41
|
+
${cssBlocks}
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
${body}
|
|
45
|
+
${jsBlocks}
|
|
46
|
+
</body>
|
|
47
|
+
</html>`;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/pipeline/html.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,SAAS,S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;;;EAGT,IAAI;EACJ,QAAQ;;QAEF,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { STAGE_ORDER } from "../types.js";
|
|
4
|
+
import { preprocess } from "./preprocess.js";
|
|
5
|
+
import { renderMarkdown } from "./render.js";
|
|
6
|
+
import { applyTransforms } from "./transform.js";
|
|
7
|
+
import { buildHtml } from "./html.js";
|
|
8
|
+
import { generatePdf } from "./pdf.js";
|
|
9
|
+
export async function runPipeline(input, config, inputPath) {
|
|
10
|
+
const startIdx = STAGE_ORDER.indexOf(config.pipeline.start);
|
|
11
|
+
const endIdx = STAGE_ORDER.indexOf(config.pipeline.end);
|
|
12
|
+
let content = input;
|
|
13
|
+
for (let i = startIdx; i <= endIdx; i++) {
|
|
14
|
+
const stage = STAGE_ORDER[i];
|
|
15
|
+
if (config.verbose) {
|
|
16
|
+
process.stderr.write(`[md-pipe] Running stage: ${stage}\n`);
|
|
17
|
+
}
|
|
18
|
+
content = await executeStage(stage, content, config, inputPath);
|
|
19
|
+
}
|
|
20
|
+
return content;
|
|
21
|
+
}
|
|
22
|
+
async function executeStage(stage, input, config, inputPath) {
|
|
23
|
+
switch (stage) {
|
|
24
|
+
case "preprocess":
|
|
25
|
+
return preprocess(input, config);
|
|
26
|
+
case "render":
|
|
27
|
+
return renderMarkdown(input);
|
|
28
|
+
case "transform":
|
|
29
|
+
return await applyTransforms(input, config);
|
|
30
|
+
case "html":
|
|
31
|
+
return buildHtml(input, config);
|
|
32
|
+
case "pdf": {
|
|
33
|
+
if (!config.output) {
|
|
34
|
+
throw new Error("PDF output requires -o <file>");
|
|
35
|
+
}
|
|
36
|
+
const outPath = path.resolve(config.output);
|
|
37
|
+
const dir = path.dirname(outPath);
|
|
38
|
+
if (!fs.existsSync(dir)) {
|
|
39
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
await generatePdf(input, config, outPath, inputPath);
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`Unknown stage: ${stage}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pipeline/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAa,EACb,MAAsB,EACtB,SAAkB;IAElB,MAAM,QAAQ,GAAI,WAAiC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnF,MAAM,MAAM,GAAI,WAAiC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE/E,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,KAAK,IAAI,CAAC,CAAC;QAC9D,CAAC;QACD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