md-pipe 0.0.1 → 0.1.1
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 +159 -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 +77 -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 +94 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -8
- package/index.js +0 -2
package/README.md
CHANGED
|
@@ -1 +1,189 @@
|
|
|
1
|
-
#
|
|
1
|
+
# md-pipe
|
|
2
|
+
|
|
3
|
+
A rendering engine that transforms Markdown manuscripts into HTML/PDF through HTML-comment directives and DOM transformations — without polluting the Markdown source.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
- Keep Markdown clean — no `<div>` tags or framework-specific syntax in your source
|
|
8
|
+
- HTML comments are invisible on GitHub, so your docs stay readable
|
|
9
|
+
- Full HTML/CSS power for rendering: themes, custom layouts, print styles
|
|
10
|
+
- Pipeline architecture lets you stop, inspect, and resume at any stage
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g md-pipe
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Markdown → HTML
|
|
22
|
+
md-pipe report.md -o report.html
|
|
23
|
+
|
|
24
|
+
# Markdown → PDF
|
|
25
|
+
md-pipe report.md --pipeline .pdf -o report.pdf
|
|
26
|
+
|
|
27
|
+
# Initialize a project config
|
|
28
|
+
md-pipe init
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## How It Works
|
|
32
|
+
|
|
33
|
+
md-pipe uses HTML comments as directives. They're invisible on GitHub but control rendering:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
<!--md-pipe: .feature-cards .compact-->
|
|
37
|
+
|
|
38
|
+
| title | description | status |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| Auth | Login & permissions | Done |
|
|
41
|
+
| Notifications | Email & Push | WIP |
|
|
42
|
+
|
|
43
|
+
<!--/md-pipe-->
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This renders as a normal table on GitHub, but md-pipe wraps it in a styled `<div class="feature-cards compact">` for HTML/PDF output.
|
|
47
|
+
|
|
48
|
+
### Directives
|
|
49
|
+
|
|
50
|
+
| Syntax | Description |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `<!--name: .class #id key=value-->` | Block start |
|
|
53
|
+
| `<!--/name-->` | Block end |
|
|
54
|
+
| `<!--name: .class /-->` | Self-closing |
|
|
55
|
+
|
|
56
|
+
Directive-to-element mapping is defined in config:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
# md-pipe.config.yml
|
|
60
|
+
directives:
|
|
61
|
+
md-pipe: div
|
|
62
|
+
page-break: div
|
|
63
|
+
note: aside .note-block
|
|
64
|
+
feature-cards: div feature_cards()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Pipeline
|
|
68
|
+
|
|
69
|
+
Processing flows through five stages:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
preprocess → render → transform → html → pdf
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Use `--pipeline` to control the range:
|
|
76
|
+
|
|
77
|
+
| Flag | Stages | Description |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `.html` | all except pdf | Source to final HTML (default) |
|
|
80
|
+
| `.pdf` | all | Source to PDF |
|
|
81
|
+
| `.render` | preprocess + render | Stop after Markdown→HTML |
|
|
82
|
+
| `render.html` | render → html | Resume from intermediate HTML |
|
|
83
|
+
| `transform.pdf` | transform → pdf | Resume from transformed HTML |
|
|
84
|
+
|
|
85
|
+
### Pipe Chaining
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cat report.md | md-pipe --pipeline .transform | md-pipe --pipeline transform.pdf -o report.pdf
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
### Frontmatter
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
---
|
|
97
|
+
title: Monthly Report
|
|
98
|
+
theme: business-report
|
|
99
|
+
pipeline: .pdf
|
|
100
|
+
output: ./dist/report.pdf
|
|
101
|
+
---
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Project Config (`md-pipe.config.yml`)
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
theme: business-report
|
|
108
|
+
|
|
109
|
+
themes:
|
|
110
|
+
business-report:
|
|
111
|
+
styles:
|
|
112
|
+
- ./styles/base.css
|
|
113
|
+
- ./styles/report.css
|
|
114
|
+
|
|
115
|
+
directives:
|
|
116
|
+
md-pipe: div
|
|
117
|
+
page-break: div
|
|
118
|
+
feature-cards: div feature_cards()
|
|
119
|
+
|
|
120
|
+
transforms:
|
|
121
|
+
- ./transforms/feature-cards.ts
|
|
122
|
+
|
|
123
|
+
pipeline: .pdf
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Precedence
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
CLI args > frontmatter > project config > tool default
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## CLI Reference
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
md-pipe [input] [options]
|
|
136
|
+
|
|
137
|
+
Options:
|
|
138
|
+
-o, --output <file> Output file path
|
|
139
|
+
-p, --pipeline <range> Pipeline range ([start.]end)
|
|
140
|
+
-t, --theme <name> Theme name
|
|
141
|
+
-c, --config <file> Config file path
|
|
142
|
+
--styles <files...> Additional CSS files
|
|
143
|
+
--scripts <files...> Additional JS files
|
|
144
|
+
--paper-size <size> PDF paper size (A4, A3, Letter, Legal, Tabloid)
|
|
145
|
+
--landscape PDF landscape orientation
|
|
146
|
+
--header <text> PDF header text
|
|
147
|
+
--margin <size> PDF page margin (e.g. 16mm)
|
|
148
|
+
--strict Error on undefined directives
|
|
149
|
+
-v, --verbose Verbose logging
|
|
150
|
+
|
|
151
|
+
Commands:
|
|
152
|
+
init [options] Generate md-pipe.config.yml
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Transform Plugins
|
|
156
|
+
|
|
157
|
+
Custom DOM transforms are TypeScript modules:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import type { TransformFn } from "md-pipe";
|
|
161
|
+
|
|
162
|
+
export default {
|
|
163
|
+
feature_cards({ $, el, helpers }) {
|
|
164
|
+
const table = $(el).find("table").first();
|
|
165
|
+
const rows = helpers.tableToObjects(table);
|
|
166
|
+
const html = rows.map(row =>
|
|
167
|
+
`<article class="feature-card">
|
|
168
|
+
<h3>${helpers.escapeHtml(row.title ?? "")}</h3>
|
|
169
|
+
<p>${helpers.escapeHtml(row.description ?? "")}</p>
|
|
170
|
+
</article>`
|
|
171
|
+
).join("");
|
|
172
|
+
$(el).replaceWith(`<section class="feature-cards">${html}</section>`);
|
|
173
|
+
}
|
|
174
|
+
} satisfies Record<string, TransformFn>;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Register in config:
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
directives:
|
|
181
|
+
feature-cards: div feature_cards()
|
|
182
|
+
|
|
183
|
+
transforms:
|
|
184
|
+
- ./transforms/feature-cards.ts
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
ISC
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { createProgram } from "./generated/program.js";
|
|
6
|
+
import { loadProjectConfig, parseFrontmatter, resolveConfig, loadTransforms, } from "./config.js";
|
|
7
|
+
import { runPipeline } from "./pipeline/index.js";
|
|
8
|
+
import { runInit } from "./commands/init.js";
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf-8"));
|
|
11
|
+
async function readInput(filePath) {
|
|
12
|
+
if (filePath) {
|
|
13
|
+
if (!fs.existsSync(filePath)) {
|
|
14
|
+
throw new Error(`Input file not found: ${filePath}`);
|
|
15
|
+
}
|
|
16
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
17
|
+
}
|
|
18
|
+
if (process.stdin.isTTY) {
|
|
19
|
+
throw new Error("No input file specified and stdin is a terminal");
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
let data = "";
|
|
23
|
+
process.stdin.setEncoding("utf-8");
|
|
24
|
+
process.stdin.on("data", (chunk) => (data += chunk));
|
|
25
|
+
process.stdin.on("end", () => resolve(data));
|
|
26
|
+
process.stdin.on("error", reject);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const handlers = {
|
|
30
|
+
async render(input, opts, globalOpts) {
|
|
31
|
+
try {
|
|
32
|
+
const source = await readInput(input);
|
|
33
|
+
const inputPath = input ? path.resolve(input) : undefined;
|
|
34
|
+
const inputDir = inputPath ? path.dirname(inputPath) : process.cwd();
|
|
35
|
+
const project = loadProjectConfig(globalOpts.config);
|
|
36
|
+
const { frontmatter, body } = parseFrontmatter(source);
|
|
37
|
+
const normalizedOpts = {
|
|
38
|
+
...opts,
|
|
39
|
+
styles: opts.styles ? (Array.isArray(opts.styles) ? opts.styles : [opts.styles]) : undefined,
|
|
40
|
+
scripts: opts.scripts ? (Array.isArray(opts.scripts) ? opts.scripts : [opts.scripts]) : undefined,
|
|
41
|
+
paperSize: opts.paperSize ?? "A4",
|
|
42
|
+
};
|
|
43
|
+
const config = resolveConfig(normalizedOpts, {
|
|
44
|
+
config: globalOpts.config,
|
|
45
|
+
verbose: globalOpts.verbose,
|
|
46
|
+
strict: globalOpts.strict,
|
|
47
|
+
}, frontmatter, project, inputDir);
|
|
48
|
+
if (project.transforms && project.transforms.length > 0) {
|
|
49
|
+
config.transforms = await loadTransforms(project.transforms, inputDir);
|
|
50
|
+
}
|
|
51
|
+
const startIsSource = config.pipeline.start === "preprocess";
|
|
52
|
+
const content = startIsSource ? body : source;
|
|
53
|
+
const result = await runPipeline(content, config, input);
|
|
54
|
+
if (result !== "" && config.pipeline.end !== "pdf") {
|
|
55
|
+
if (config.output) {
|
|
56
|
+
const outPath = path.resolve(config.output);
|
|
57
|
+
const dir = path.dirname(outPath);
|
|
58
|
+
if (!fs.existsSync(dir)) {
|
|
59
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
fs.writeFileSync(outPath, result, "utf-8");
|
|
62
|
+
if (config.verbose) {
|
|
63
|
+
process.stderr.write(`[md-pipe] Written to ${outPath}\n`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
process.stdout.write(result);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
process.stderr.write(`${err.message}\n`);
|
|
73
|
+
process.exit(err.message?.includes("not found") ||
|
|
74
|
+
err.message?.includes("Invalid pipeline")
|
|
75
|
+
? 2
|
|
76
|
+
: 1);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
async init(opts) {
|
|
80
|
+
runInit({ theme: opts.theme ?? "default", force: opts.force ?? false });
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const program = createProgram(handlers, pkg.version);
|
|
84
|
+
program.parse();
|
|
85
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAwB,MAAM,wBAAwB,CAAC;AAE7E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb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AO,IAAI,CAAC,CAAC;oBAC5D,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CACV,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC;gBAClC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC;gBACvC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,CAAC,CACN,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAI;QACb,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF,CAAC;AAEF,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACrD,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
const CONFIG_FILENAME = "md-pipe.config.yml";
|
|
5
|
+
export function runInit(options) {
|
|
6
|
+
const target = path.join(process.cwd(), CONFIG_FILENAME);
|
|
7
|
+
if (fs.existsSync(target) && !options.force) {
|
|
8
|
+
process.stderr.write(`${CONFIG_FILENAME} already exists. Use --force to overwrite.\n`);
|
|
9
|
+
process.exit(3);
|
|
10
|
+
}
|
|
11
|
+
const config = {
|
|
12
|
+
theme: options.theme,
|
|
13
|
+
themes: {
|
|
14
|
+
[options.theme]: {
|
|
15
|
+
styles: ["./styles/base.css"],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
directives: {
|
|
19
|
+
"md-pipe": "div",
|
|
20
|
+
"page-break": "div",
|
|
21
|
+
},
|
|
22
|
+
pipeline: ".html",
|
|
23
|
+
};
|
|
24
|
+
const content = yaml.dump(config, { lineWidth: 120 });
|
|
25
|
+
fs.writeFileSync(target, content, "utf-8");
|
|
26
|
+
process.stdout.write(`Created ${CONFIG_FILENAME}\n`);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAO7C,MAAM,UAAU,OAAO,CAAC,OAAoB;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;IAEzD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,GAAG,eAAe,8CAA8C,CACjE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAwB;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE;YACN,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACf,MAAM,EAAE,CAAC,mBAAmB,CAAC;aAC9B;SACF;QACD,UAAU,EAAE;YACV,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK;SACpB;QACD,QAAQ,EAAE,OAAO;KAClB,CAAC;IAEF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;IACtD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAE3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,eAAe,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ProjectConfig, Frontmatter, ResolvedConfig, DirectiveDef, StageName, TransformFn } from "./types.js";
|
|
2
|
+
import type { RenderOptions } from "./generated/types.js";
|
|
3
|
+
export declare function findConfigFile(explicit?: string): string | undefined;
|
|
4
|
+
export declare function loadProjectConfig(filePath?: string): ProjectConfig;
|
|
5
|
+
export declare function parseFrontmatter(source: string): {
|
|
6
|
+
frontmatter: Frontmatter;
|
|
7
|
+
body: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseDirectiveDef(raw: string): DirectiveDef;
|
|
10
|
+
export declare function parsePipelineRange(spec: string | undefined, outputPath: string | undefined, frontmatter: Frontmatter, config: ProjectConfig): {
|
|
11
|
+
start: StageName;
|
|
12
|
+
end: StageName;
|
|
13
|
+
};
|
|
14
|
+
export declare function loadTransforms(paths: string[], baseDir: string): Promise<Map<string, TransformFn>>;
|
|
15
|
+
export declare function resolveConfig(opts: RenderOptions, globalOpts: {
|
|
16
|
+
config?: string;
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
strict?: boolean;
|
|
19
|
+
}, frontmatter: Frontmatter, project: ProjectConfig, inputDir: string): ResolvedConfig;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
import { STAGE_ORDER } from "./types.js";
|
|
5
|
+
const CONFIG_FILENAME = "md-pipe.config.yml";
|
|
6
|
+
export function findConfigFile(explicit) {
|
|
7
|
+
if (explicit)
|
|
8
|
+
return explicit;
|
|
9
|
+
let dir = process.cwd();
|
|
10
|
+
while (true) {
|
|
11
|
+
const candidate = path.join(dir, CONFIG_FILENAME);
|
|
12
|
+
if (fs.existsSync(candidate))
|
|
13
|
+
return candidate;
|
|
14
|
+
const parent = path.dirname(dir);
|
|
15
|
+
if (parent === dir)
|
|
16
|
+
return undefined;
|
|
17
|
+
dir = parent;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function loadProjectConfig(filePath) {
|
|
21
|
+
const resolved = findConfigFile(filePath);
|
|
22
|
+
if (!resolved)
|
|
23
|
+
return {};
|
|
24
|
+
const raw = fs.readFileSync(resolved, "utf-8");
|
|
25
|
+
return yaml.load(raw) ?? {};
|
|
26
|
+
}
|
|
27
|
+
export function parseFrontmatter(source) {
|
|
28
|
+
const match = source.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
|
|
29
|
+
if (!match)
|
|
30
|
+
return { frontmatter: {}, body: source };
|
|
31
|
+
const fm = yaml.load(match[1]) ?? {};
|
|
32
|
+
return { frontmatter: fm, body: match[2] };
|
|
33
|
+
}
|
|
34
|
+
export function parseDirectiveDef(raw) {
|
|
35
|
+
const tokens = raw.trim().split(/\s+/);
|
|
36
|
+
const element = tokens[0] ?? "div";
|
|
37
|
+
const classes = [];
|
|
38
|
+
let id;
|
|
39
|
+
const attrs = {};
|
|
40
|
+
const transformNames = [];
|
|
41
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
42
|
+
const t = tokens[i];
|
|
43
|
+
if (t.endsWith("()")) {
|
|
44
|
+
transformNames.push(t.slice(0, -2));
|
|
45
|
+
}
|
|
46
|
+
else if (t.startsWith(".")) {
|
|
47
|
+
classes.push(t.slice(1));
|
|
48
|
+
}
|
|
49
|
+
else if (t.startsWith("#")) {
|
|
50
|
+
id = t.slice(1);
|
|
51
|
+
}
|
|
52
|
+
else if (t.includes("=")) {
|
|
53
|
+
const [k, ...rest] = t.split("=");
|
|
54
|
+
attrs[k] = rest.join("=");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { element, classes, id, attrs, transformNames };
|
|
58
|
+
}
|
|
59
|
+
export function parsePipelineRange(spec, outputPath, frontmatter, config) {
|
|
60
|
+
let raw = spec ??
|
|
61
|
+
inferPipelineFromOutput(outputPath) ??
|
|
62
|
+
frontmatter.pipeline ??
|
|
63
|
+
config.pipeline ??
|
|
64
|
+
".html";
|
|
65
|
+
if (raw.startsWith(".")) {
|
|
66
|
+
const end = raw.slice(1);
|
|
67
|
+
if (!STAGE_ORDER.includes(end)) {
|
|
68
|
+
throw new Error(`Invalid pipeline end stage: ${end}`);
|
|
69
|
+
}
|
|
70
|
+
return { start: "preprocess", end };
|
|
71
|
+
}
|
|
72
|
+
const [startStr, endStr] = raw.split(".");
|
|
73
|
+
const start = startStr;
|
|
74
|
+
const end = endStr;
|
|
75
|
+
if (!STAGE_ORDER.includes(start) || !STAGE_ORDER.includes(end)) {
|
|
76
|
+
throw new Error(`Invalid pipeline range: ${raw}`);
|
|
77
|
+
}
|
|
78
|
+
if (STAGE_ORDER.indexOf(start) >= STAGE_ORDER.indexOf(end)) {
|
|
79
|
+
throw new Error(`Pipeline start (${start}) must precede end (${end})`);
|
|
80
|
+
}
|
|
81
|
+
return { start, end };
|
|
82
|
+
}
|
|
83
|
+
function inferPipelineFromOutput(outputPath) {
|
|
84
|
+
if (!outputPath)
|
|
85
|
+
return undefined;
|
|
86
|
+
const ext = path.extname(outputPath).toLowerCase();
|
|
87
|
+
if (ext === ".pdf")
|
|
88
|
+
return ".pdf";
|
|
89
|
+
if (ext === ".html" || ext === ".htm")
|
|
90
|
+
return ".html";
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
export async function loadTransforms(paths, baseDir) {
|
|
94
|
+
const map = new Map();
|
|
95
|
+
for (const p of paths) {
|
|
96
|
+
const abs = path.resolve(baseDir, p);
|
|
97
|
+
const mod = await import(abs);
|
|
98
|
+
const exported = mod.default ?? mod;
|
|
99
|
+
for (const [name, fn] of Object.entries(exported)) {
|
|
100
|
+
if (typeof fn === "function") {
|
|
101
|
+
map.set(name, fn);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return map;
|
|
106
|
+
}
|
|
107
|
+
export function resolveConfig(opts, globalOpts, frontmatter, project, inputDir) {
|
|
108
|
+
const themeName = opts.theme ?? frontmatter.theme ?? project.theme;
|
|
109
|
+
const themeDef = themeName ? project.themes?.[themeName] : undefined;
|
|
110
|
+
const styles = [
|
|
111
|
+
...(themeDef?.styles ?? []),
|
|
112
|
+
...(project.styles ?? []),
|
|
113
|
+
...(frontmatter.styles ?? []),
|
|
114
|
+
...(opts.styles ?? []),
|
|
115
|
+
];
|
|
116
|
+
const scripts = [
|
|
117
|
+
...(themeDef?.scripts ?? []),
|
|
118
|
+
...(project.scripts ?? []),
|
|
119
|
+
...(frontmatter.scripts ?? []),
|
|
120
|
+
...(opts.scripts ?? []),
|
|
121
|
+
];
|
|
122
|
+
const rawDirectives = {
|
|
123
|
+
...project.directives,
|
|
124
|
+
...frontmatter.directives,
|
|
125
|
+
};
|
|
126
|
+
const directives = {};
|
|
127
|
+
for (const [name, def] of Object.entries(rawDirectives)) {
|
|
128
|
+
directives[name] = parseDirectiveDef(def);
|
|
129
|
+
}
|
|
130
|
+
const pipeline = parsePipelineRange(opts.pipeline, opts.output ?? frontmatter.output ?? project.output, frontmatter, project);
|
|
131
|
+
const fmPaper = frontmatter.paper ?? frontmatter.pdf?.paper;
|
|
132
|
+
const projPaper = project.pdf?.paper;
|
|
133
|
+
const paperSize = opts.paperSize && opts.paperSize !== "A4"
|
|
134
|
+
? opts.paperSize
|
|
135
|
+
: (fmPaper?.size ?? projPaper?.size ?? "A4");
|
|
136
|
+
const margin = opts.margin ??
|
|
137
|
+
(typeof fmPaper?.margin === "string" ? fmPaper.margin : undefined) ??
|
|
138
|
+
(typeof projPaper?.margin === "string" ? projPaper.margin : undefined);
|
|
139
|
+
return {
|
|
140
|
+
theme: themeName,
|
|
141
|
+
styles,
|
|
142
|
+
scripts,
|
|
143
|
+
directives,
|
|
144
|
+
transforms: new Map(),
|
|
145
|
+
pipeline,
|
|
146
|
+
output: opts.output ?? frontmatter.output ?? project.output,
|
|
147
|
+
strict: globalOpts.strict ?? false,
|
|
148
|
+
verbose: globalOpts.verbose ?? false,
|
|
149
|
+
pdf: {
|
|
150
|
+
paperSize,
|
|
151
|
+
landscape: opts.landscape || frontmatter.landscape || false,
|
|
152
|
+
header: opts.header ?? frontmatter.header,
|
|
153
|
+
margin,
|
|
154
|
+
scale: frontmatter.pdf?.scale ?? 1,
|
|
155
|
+
},
|
|
156
|
+
inputDir,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,SAAS,CAAC;AAS3B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAE7C,MAAM,UAAU,cAAc,CAAC,QAAiB;IAC9C,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACxB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,OAA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AAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEzE,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,MAAM;QACN,OAAO;QACP,UAAU;QACV,UAAU,EAAE,IAAI,GAAG,EAAE;QACrB,QAAQ;QACR,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM;QAC3D,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,KAAK;QAClC,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,KAAK;QACpC,GAAG,EAAE;YACH,SAAS;YACT,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,SAAS,IAAI,KAAK;YAC3D,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM;YACzC,MAAM;YACN,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC;SACnC;QACD,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ExecResult {
|
|
2
|
+
exitCode: number;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function mdPipeRender(executable: string, args: import("./types.js").RenderArgs, options?: Partial<import("./types.js").RenderOptions>): Promise<ExecResult>;
|
|
7
|
+
export declare function mdPipeInit(executable: string, options?: Partial<import("./types.js").InitOptions>): Promise<ExecResult>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
export async function mdPipeRender(executable, args, options) {
|
|
6
|
+
const cmdArgs = [];
|
|
7
|
+
if (args.input !== undefined)
|
|
8
|
+
cmdArgs.push(String(args.input));
|
|
9
|
+
if (options) {
|
|
10
|
+
if (options.output !== undefined)
|
|
11
|
+
cmdArgs.push("--output", String(options.output));
|
|
12
|
+
if (options.pipeline !== undefined)
|
|
13
|
+
cmdArgs.push("--pipeline", String(options.pipeline));
|
|
14
|
+
if (options.theme !== undefined)
|
|
15
|
+
cmdArgs.push("--theme", String(options.theme));
|
|
16
|
+
if (options.styles !== undefined)
|
|
17
|
+
cmdArgs.push("--styles", String(options.styles));
|
|
18
|
+
if (options.scripts !== undefined)
|
|
19
|
+
cmdArgs.push("--scripts", String(options.scripts));
|
|
20
|
+
if (options.paperSize !== undefined)
|
|
21
|
+
cmdArgs.push("--paper-size", String(options.paperSize));
|
|
22
|
+
if (options.landscape)
|
|
23
|
+
cmdArgs.push("--landscape");
|
|
24
|
+
if (options.header !== undefined)
|
|
25
|
+
cmdArgs.push("--header", String(options.header));
|
|
26
|
+
if (options.margin !== undefined)
|
|
27
|
+
cmdArgs.push("--margin", String(options.margin));
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const result = await execFileAsync(executable, cmdArgs);
|
|
31
|
+
return { exitCode: 0, stdout: result.stdout, stderr: result.stderr };
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const e = err;
|
|
35
|
+
return {
|
|
36
|
+
exitCode: typeof e.code === 'number' ? e.code : 1,
|
|
37
|
+
stdout: e.stdout ?? '',
|
|
38
|
+
stderr: e.stderr ?? '',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function mdPipeInit(executable, options) {
|
|
43
|
+
const cmdArgs = ["init"];
|
|
44
|
+
if (options) {
|
|
45
|
+
if (options.theme !== undefined)
|
|
46
|
+
cmdArgs.push("--theme", String(options.theme));
|
|
47
|
+
if (options.force)
|
|
48
|
+
cmdArgs.push("--force");
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const result = await execFileAsync(executable, cmdArgs);
|
|
52
|
+
return { exitCode: 0, stdout: result.stdout, stderr: result.stderr };
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
const e = err;
|
|
56
|
+
return {
|
|
57
|
+
exitCode: typeof e.code === 'number' ? e.code : 1,
|
|
58
|
+
stdout: e.stdout ?? '',
|
|
59
|
+
stderr: e.stderr ?? '',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/generated/commands.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAQ1C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,IAAqC,EACrC,OAAqD;IAErD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACnF,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzF,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAChF,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,UAA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AM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,OAAmD;IAEnD,MAAM,OAAO,GAAa,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAChF,IAAI,OAAO,CAAC,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACvE,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,GAA0D,CAAC;QACrE,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;YACtB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;SACvB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Auto-generated by cli-contracts. Do not edit.
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./commands.js";
|
|
4
|
+
export * from "./schemas.js";
|
|
5
|
+
export { createProgram } from "./program.js";
|
|
6
|
+
export { commandDefinitions, deriveCommandPolicy } from "./policy.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|