md-tech-pdf 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/LICENSE +176 -0
- package/README.ja.md +330 -0
- package/README.md +315 -0
- package/dist/cli/index.d.ts +10 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +96 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/config-resolver.d.ts +19 -0
- package/dist/config/config-resolver.d.ts.map +1 -0
- package/dist/config/config-resolver.js +41 -0
- package/dist/config/config-resolver.js.map +1 -0
- package/dist/config/document-options.d.ts +52 -0
- package/dist/config/document-options.d.ts.map +1 -0
- package/dist/config/document-options.js +8 -0
- package/dist/config/document-options.js.map +1 -0
- package/dist/config/error.d.ts +12 -0
- package/dist/config/error.d.ts.map +1 -0
- package/dist/config/error.js +12 -0
- package/dist/config/error.js.map +1 -0
- package/dist/config/frontmatter-parser.d.ts +16 -0
- package/dist/config/frontmatter-parser.d.ts.map +1 -0
- package/dist/config/frontmatter-parser.js +271 -0
- package/dist/config/frontmatter-parser.js.map +1 -0
- package/dist/core/converter.d.ts +34 -0
- package/dist/core/converter.d.ts.map +1 -0
- package/dist/core/converter.js +109 -0
- package/dist/core/converter.js.map +1 -0
- package/dist/html/default-style.d.ts +6 -0
- package/dist/html/default-style.d.ts.map +1 -0
- package/dist/html/default-style.js +237 -0
- package/dist/html/default-style.js.map +1 -0
- package/dist/html/google-fonts.d.ts +20 -0
- package/dist/html/google-fonts.d.ts.map +1 -0
- package/dist/html/google-fonts.js +50 -0
- package/dist/html/google-fonts.js.map +1 -0
- package/dist/html/html-builder.d.ts +20 -0
- package/dist/html/html-builder.d.ts.map +1 -0
- package/dist/html/html-builder.js +88 -0
- package/dist/html/html-builder.js.map +1 -0
- package/dist/html/html-renderer.d.ts +25 -0
- package/dist/html/html-renderer.d.ts.map +1 -0
- package/dist/html/html-renderer.js +148 -0
- package/dist/html/html-renderer.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/attributes-parser.d.ts +13 -0
- package/dist/parser/attributes-parser.d.ts.map +1 -0
- package/dist/parser/attributes-parser.js +110 -0
- package/dist/parser/attributes-parser.js.map +1 -0
- package/dist/parser/error.d.ts +15 -0
- package/dist/parser/error.d.ts.map +1 -0
- package/dist/parser/error.js +15 -0
- package/dist/parser/error.js.map +1 -0
- package/dist/parser/markdown-parser.d.ts +17 -0
- package/dist/parser/markdown-parser.d.ts.map +1 -0
- package/dist/parser/markdown-parser.js +86 -0
- package/dist/parser/markdown-parser.js.map +1 -0
- package/dist/pdf/default-options.d.ts +6 -0
- package/dist/pdf/default-options.d.ts.map +1 -0
- package/dist/pdf/default-options.js +12 -0
- package/dist/pdf/default-options.js.map +1 -0
- package/dist/pdf/error.d.ts +9 -0
- package/dist/pdf/error.d.ts.map +1 -0
- package/dist/pdf/error.js +10 -0
- package/dist/pdf/error.js.map +1 -0
- package/dist/pdf/pdf-generator.d.ts +16 -0
- package/dist/pdf/pdf-generator.d.ts.map +1 -0
- package/dist/pdf/pdf-generator.js +95 -0
- package/dist/pdf/pdf-generator.js.map +1 -0
- package/dist/pdf/types.d.ts +16 -0
- package/dist/pdf/types.d.ts.map +1 -0
- package/dist/pdf/types.js +2 -0
- package/dist/pdf/types.js.map +1 -0
- package/dist/renderer/diagram-renderer.d.ts +11 -0
- package/dist/renderer/diagram-renderer.d.ts.map +1 -0
- package/dist/renderer/diagram-renderer.js +2 -0
- package/dist/renderer/diagram-renderer.js.map +1 -0
- package/dist/renderer/error.d.ts +10 -0
- package/dist/renderer/error.d.ts.map +1 -0
- package/dist/renderer/error.js +10 -0
- package/dist/renderer/error.js.map +1 -0
- package/dist/renderer/mermaid-executor.d.ts +16 -0
- package/dist/renderer/mermaid-executor.d.ts.map +1 -0
- package/dist/renderer/mermaid-executor.js +99 -0
- package/dist/renderer/mermaid-executor.js.map +1 -0
- package/dist/renderer/mermaid-renderer.d.ts +25 -0
- package/dist/renderer/mermaid-renderer.d.ts.map +1 -0
- package/dist/renderer/mermaid-renderer.js +35 -0
- package/dist/renderer/mermaid-renderer.js.map +1 -0
- package/dist/renderer/plantuml-executor.d.ts +11 -0
- package/dist/renderer/plantuml-executor.d.ts.map +1 -0
- package/dist/renderer/plantuml-executor.js +100 -0
- package/dist/renderer/plantuml-executor.js.map +1 -0
- package/dist/renderer/plantuml-renderer.d.ts +26 -0
- package/dist/renderer/plantuml-renderer.d.ts.map +1 -0
- package/dist/renderer/plantuml-renderer.js +95 -0
- package/dist/renderer/plantuml-renderer.js.map +1 -0
- package/dist/types/diagram.d.ts +34 -0
- package/dist/types/diagram.d.ts.map +1 -0
- package/dist/types/diagram.js +2 -0
- package/dist/types/diagram.js.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# md-tech-pdf
|
|
2
|
+
|
|
3
|
+
English | [日本語](./README.ja.md)
|
|
4
|
+
|
|
5
|
+
An open-source technical document PDF generator from Markdown with flexible, print-oriented diagram layout and vector typography.
|
|
6
|
+
|
|
7
|
+
Unlike conventional Markdown-to-PDF converters that treat diagrams as fixed raster images or apply crude page scaling, **md-tech-pdf** renders Mermaid and PlantUML diagrams as crisp vector SVGs with independent width and height control, custom aspect ratio fitting (`fit=contain` / `fill`), and alignment (`left` / `center` / `right`).
|
|
8
|
+
|
|
9
|
+
While future editor integrations (such as a VS Code extension) are planned, the core PDF generation engine is architected as an independent, decoupled library suitable for automated documentation pipelines and CLI workflows.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Markdown to High-Quality Vector PDF**: Precise rendering engine built on headless Playwright Chromium.
|
|
16
|
+
- **Mermaid & PlantUML Support**: Inline vector SVG rendering for flowcharts, sequence diagrams, architecture maps, and class diagrams.
|
|
17
|
+
- **Independent Diagram Sizing**: Precise control over diagram `width` and `height` using real-world physical units (`mm`, `cm`, `in`) or digital units (`px`, `pt`, `%`).
|
|
18
|
+
- **Flexible Aspect Ratio & Alignment**: Choose between `fit=contain` (maintain aspect ratio) and `fit=fill`, aligned to `left`, `center`, or `right`.
|
|
19
|
+
- **YAML Front Matter**: Configure page format (A4), orientation (portrait/landscape), margins, fonts, and default diagram settings per document.
|
|
20
|
+
- **Font Customization**:
|
|
21
|
+
- Local OS font support for body text (`family`) and code blocks (`codeFamily`).
|
|
22
|
+
- Google Fonts integration via the CSS2 API with automatic loading completion detection.
|
|
23
|
+
- **Print-Ready Layout Optimizations**: Orphan heading prevention (`break-inside: avoid`), automated wrapping for long code lines, and multi-column table styling.
|
|
24
|
+
- **Developer-Friendly CLI**: Simple command-line interface with custom output paths, automatic directory creation, and versioning.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- **Node.js**: `>= 20.0.0`
|
|
31
|
+
- **Playwright / Chromium**: Required for PDF rendering (installed automatically with project dependencies).
|
|
32
|
+
- **Java Runtime & PlantUML JAR**: Required **only** if you render PlantUML diagrams. If you only use Mermaid diagrams, Java is **not** required.
|
|
33
|
+
- **Internet Connection**: Required **only** if downloading Google Fonts at compilation time (automatically falls back to system fonts when offline).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Install globally via npm or pnpm to use the CLI command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Using npm
|
|
43
|
+
npm install -g md-tech-pdf
|
|
44
|
+
|
|
45
|
+
# Using pnpm
|
|
46
|
+
pnpm add -g md-tech-pdf
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Alternatively, run directly without global installation using `npx`:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx md-tech-pdf document.md -o output.pdf
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quick Start & CLI Usage
|
|
58
|
+
|
|
59
|
+
### Basic Conversion
|
|
60
|
+
|
|
61
|
+
Convert a Markdown file to PDF. When omitted, the output file will be created in the same directory as the source Markdown file:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Generates document.pdf in the current directory
|
|
65
|
+
md-tech-pdf document.md
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Specifying Output Path
|
|
69
|
+
|
|
70
|
+
Use `-o` or `--output` to define the destination file path. Non-existent directories are created automatically:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
md-tech-pdf document.md -o output.pdf
|
|
74
|
+
|
|
75
|
+
# Auto-creates the build/ directory if missing
|
|
76
|
+
md-tech-pdf docs/architecture.md -o build/architecture.pdf
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Help and Version
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Show command-line help
|
|
83
|
+
md-tech-pdf --help
|
|
84
|
+
md-tech-pdf -h
|
|
85
|
+
|
|
86
|
+
# Show version number
|
|
87
|
+
md-tech-pdf --version
|
|
88
|
+
md-tech-pdf -v
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Document Configuration & Diagrams
|
|
94
|
+
|
|
95
|
+
### YAML Front Matter
|
|
96
|
+
|
|
97
|
+
Place Front Matter at the top of your Markdown document to customize PDF page margins, default diagram sizing, and typography:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
---
|
|
101
|
+
pdf:
|
|
102
|
+
format: A4
|
|
103
|
+
landscape: false
|
|
104
|
+
margin:
|
|
105
|
+
top: 20mm
|
|
106
|
+
right: 20mm
|
|
107
|
+
bottom: 20mm
|
|
108
|
+
left: 20mm
|
|
109
|
+
|
|
110
|
+
diagram:
|
|
111
|
+
width: 120mm
|
|
112
|
+
height: 70mm
|
|
113
|
+
fit: contain
|
|
114
|
+
align: center
|
|
115
|
+
|
|
116
|
+
style:
|
|
117
|
+
font:
|
|
118
|
+
family: 'Noto Sans JP'
|
|
119
|
+
codeFamily: 'Roboto Mono'
|
|
120
|
+
google:
|
|
121
|
+
families:
|
|
122
|
+
- name: 'Noto Sans JP'
|
|
123
|
+
weights: [400, 500, 700]
|
|
124
|
+
- name: 'Roboto Mono'
|
|
125
|
+
weights: [400, 700]
|
|
126
|
+
---
|
|
127
|
+
# System Architecture Specification
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Diagram Layout Options
|
|
131
|
+
|
|
132
|
+
You can customize individual diagram blocks using curly brace attributes `{...}` following the code block language identifier:
|
|
133
|
+
|
|
134
|
+
- `width`: Target width (supported units: `mm`, `cm`, `in`, `px`, `pt`, `%`).
|
|
135
|
+
- `height`: Target height (supported units: `mm`, `cm`, `in`, `px`, `pt`, `%`).
|
|
136
|
+
- `fit`: Scaling behavior (`contain` to preserve aspect ratio, or `fill` to stretch).
|
|
137
|
+
- `align`: Horizontal position (`left`, `center`, or `right`).
|
|
138
|
+
|
|
139
|
+
### Mermaid Diagrams
|
|
140
|
+
|
|
141
|
+
Specify `mermaid` as the code fence identifier. Diagrams are rendered as scalable vector SVGs directly embedded in the HTML:
|
|
142
|
+
|
|
143
|
+
````markdown
|
|
144
|
+
```mermaid {width=140mm align=center}
|
|
145
|
+
graph TD
|
|
146
|
+
Client[Client] --> API[API Gateway]
|
|
147
|
+
API --> DB[(Database)]
|
|
148
|
+
```
|
|
149
|
+
````
|
|
150
|
+
|
|
151
|
+
### PlantUML Diagrams
|
|
152
|
+
|
|
153
|
+
Specify `plantuml` as the code fence identifier. Rendering is executed locally via your system's Java runtime, ensuring confidential architecture designs are **never** transmitted to third-party PlantUML cloud servers:
|
|
154
|
+
|
|
155
|
+
````markdown
|
|
156
|
+
```plantuml {width=100mm align=center}
|
|
157
|
+
@startuml
|
|
158
|
+
actor User
|
|
159
|
+
participant Server
|
|
160
|
+
User -> Server: Request
|
|
161
|
+
Server --> User: Response
|
|
162
|
+
@enduml
|
|
163
|
+
```
|
|
164
|
+
````
|
|
165
|
+
|
|
166
|
+
> **Note on PlantUML Prerequisites**:
|
|
167
|
+
> PlantUML requires a **Java runtime** and a local **PlantUML .jar file**. If necessary, specify custom paths in Front Matter:
|
|
168
|
+
>
|
|
169
|
+
> ```yaml
|
|
170
|
+
> plantuml:
|
|
171
|
+
> javaPath: '/usr/bin/java'
|
|
172
|
+
> jarPath: '/path/to/plantuml.jar'
|
|
173
|
+
> ```
|
|
174
|
+
|
|
175
|
+
### Font Configuration (style.font)
|
|
176
|
+
|
|
177
|
+
Configure document body text (`family`) and code block typography (`codeFamily`).
|
|
178
|
+
|
|
179
|
+
#### 1. Local OS Fonts
|
|
180
|
+
|
|
181
|
+
Use system fonts installed on the host machine. Fast, lightweight, and offline-compatible:
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
style:
|
|
185
|
+
font:
|
|
186
|
+
family: 'Hiragino Sans'
|
|
187
|
+
codeFamily: 'Menlo'
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
- Standard `sans-serif` is automatically appended to body text as a fallback.
|
|
191
|
+
- Standard `monospace` is automatically appended to code blocks (`code`, `pre`) as a fallback.
|
|
192
|
+
|
|
193
|
+
#### 2. Google Fonts
|
|
194
|
+
|
|
195
|
+
Download web fonts dynamically at build time using the Google Fonts CSS2 API:
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
style:
|
|
199
|
+
font:
|
|
200
|
+
family: 'Noto Sans JP'
|
|
201
|
+
codeFamily: 'Roboto Mono'
|
|
202
|
+
google:
|
|
203
|
+
families:
|
|
204
|
+
- name: 'Noto Sans JP'
|
|
205
|
+
weights: [400, 500, 700]
|
|
206
|
+
- name: 'Roboto Mono'
|
|
207
|
+
weights: [400, 700]
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
- Supported weights: `100, 200, 300, 400, 500, 600, 700, 800, 900`.
|
|
211
|
+
- The generator waits for `document.fonts.ready` before rendering PDF pages.
|
|
212
|
+
- If offline or on network failure, rendering gracefully falls back to system fonts.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Examples
|
|
217
|
+
|
|
218
|
+
Explore sample Markdown documents and configuration patterns in the [examples/](./examples/) directory:
|
|
219
|
+
|
|
220
|
+
- [examples/real-world/system-design.md](./examples/real-world/system-design.md): A comprehensive system design document with Mermaid, PlantUML, custom fonts, and multi-column tables.
|
|
221
|
+
- [examples/frontmatter-test.md](./examples/frontmatter-test.md): Document-level margin and layout settings.
|
|
222
|
+
- [examples/mermaid-test.md](./examples/mermaid-test.md): Various Mermaid chart types and sizing attributes.
|
|
223
|
+
- [examples/plantuml-test.md](./examples/plantuml-test.md): PlantUML sequence and component diagrams.
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Architecture Overview
|
|
228
|
+
|
|
229
|
+
**md-tech-pdf** enforces a strict separation of concerns between client interfaces (CLI, future extensions) and the core conversion engine.
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
+---------------------------------------+
|
|
233
|
+
| Client Layer |
|
|
234
|
+
| +----------------+ +---------------+ |
|
|
235
|
+
| | CLI | | VSCode Ext | |
|
|
236
|
+
| | (src/cli) | | (Future) | |
|
|
237
|
+
| +-------+--------+ +-------+-------+ |
|
|
238
|
+
+----------|------------------|---------+
|
|
239
|
+
| (thin wrapper) |
|
|
240
|
+
v v
|
|
241
|
+
+---------------------------------------+
|
|
242
|
+
| Core Layer |
|
|
243
|
+
| (src/index.ts) |
|
|
244
|
+
| - Markdown Parser |
|
|
245
|
+
| - Diagram Engine (Mermaid/PlantUML) |
|
|
246
|
+
| - Layout Engine & PDF Generator |
|
|
247
|
+
+---------------------------------------+
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- **CLI (`src/cli/index.ts`)**: Thin command-line wrapper handling argument parsing and calling the Core API.
|
|
251
|
+
- **Core (`src/index.ts`)**: Standalone library handling document parsing, diagram execution, layout generation, and Playwright PDF printing.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Development
|
|
256
|
+
|
|
257
|
+
### Prerequisites
|
|
258
|
+
|
|
259
|
+
- Node.js `>= 20.0.0`
|
|
260
|
+
- pnpm `>= 9.0.0`
|
|
261
|
+
|
|
262
|
+
### Setup
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Install dependencies
|
|
266
|
+
pnpm install
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Scripts
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Compile TypeScript to dist/
|
|
273
|
+
pnpm build
|
|
274
|
+
|
|
275
|
+
# Run unit and integration tests with Vitest
|
|
276
|
+
pnpm test
|
|
277
|
+
|
|
278
|
+
# Run ESLint static analysis
|
|
279
|
+
pnpm lint
|
|
280
|
+
|
|
281
|
+
# Check code formatting with Prettier
|
|
282
|
+
pnpm format:check
|
|
283
|
+
|
|
284
|
+
# Format codebase with Prettier
|
|
285
|
+
pnpm format
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Known Limitations
|
|
291
|
+
|
|
292
|
+
Current known limitations in the v0.1.0 release:
|
|
293
|
+
|
|
294
|
+
1. **Table Header Pagination (`<thead>`)**: Table headers do not repeat at the top of subsequent pages when a large table breaks across page boundaries.
|
|
295
|
+
2. **Pre-Diagram Whitespace for Tall Diagrams**: Very tall diagrams (>150mm) are moved to the next page to avoid cross-page diagram clipping (`break-inside: avoid`), which may leave whitespace at the bottom of the preceding page.
|
|
296
|
+
3. **PlantUML System Dependencies**: Rendering PlantUML requires a local Java runtime and PlantUML JAR file (Mermaid has no Java dependencies).
|
|
297
|
+
4. **Google Fonts Network Dependency**: Downloading Google Fonts requires an active internet connection at compilation time (falls back to local system fonts if unavailable).
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Changelog
|
|
302
|
+
|
|
303
|
+
Detailed release notes and version history are documented in [CHANGELOG.md](./CHANGELOG.md).
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Contributing
|
|
308
|
+
|
|
309
|
+
Contributions, issues, and feature requests are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and contribution guidelines. By participating, you agree to abide by our [Code of Conduct](./CODE_OF_CONDUCT.md).
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
This project is licensed under the [Apache License 2.0](./LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* md-tech-pdf CLI Entrypoint
|
|
4
|
+
* This layer parses CLI arguments, validates options, and delegates to the Core converter API.
|
|
5
|
+
* Business logic and rendering algorithms must NOT be placed here.
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
export declare function createCliCommand(): Command;
|
|
9
|
+
export declare function runCli(argv?: string[]): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBpC,wBAAgB,gBAAgB,IAAI,OAAO,CA2D1C;AAED,wBAAsB,MAAM,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzE"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* md-tech-pdf CLI Entrypoint
|
|
4
|
+
* This layer parses CLI arguments, validates options, and delegates to the Core converter API.
|
|
5
|
+
* Business logic and rendering algorithms must NOT be placed here.
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { Command } from 'commander';
|
|
11
|
+
import { convertMarkdownToPdf, resolveOutputPath } from '../core/converter.js';
|
|
12
|
+
function getPackageVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const packageJsonPath = path.resolve(currentDir, '../../package.json');
|
|
16
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
17
|
+
const content = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
18
|
+
const pkg = JSON.parse(content);
|
|
19
|
+
return pkg.version ?? '0.1.0';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Fallback if package.json cannot be read
|
|
24
|
+
}
|
|
25
|
+
return '0.1.0';
|
|
26
|
+
}
|
|
27
|
+
export function createCliCommand() {
|
|
28
|
+
const program = new Command();
|
|
29
|
+
program
|
|
30
|
+
.name('md-tech-pdf')
|
|
31
|
+
.description('Technical document PDF generator from Markdown with flexible diagram layout')
|
|
32
|
+
.version(getPackageVersion(), '-v, --version')
|
|
33
|
+
.argument('[input]', 'Path to the input Markdown document')
|
|
34
|
+
.option('-o, --output <path>', 'Destination path for the output PDF document')
|
|
35
|
+
.helpOption('-h, --help', 'Display help for command')
|
|
36
|
+
.action(async (input, options) => {
|
|
37
|
+
if (!input || input.trim() === '') {
|
|
38
|
+
console.error('Error: Input file is required.');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
const inputPath = input.trim();
|
|
42
|
+
const outputPath = resolveOutputPath(inputPath, options.output);
|
|
43
|
+
const displayInput = path.isAbsolute(inputPath)
|
|
44
|
+
? path.relative(process.cwd(), inputPath) || inputPath
|
|
45
|
+
: inputPath;
|
|
46
|
+
const displayOutput = path.isAbsolute(outputPath)
|
|
47
|
+
? path.relative(process.cwd(), outputPath) || outputPath
|
|
48
|
+
: outputPath;
|
|
49
|
+
console.log('md-tech-pdf');
|
|
50
|
+
console.log('');
|
|
51
|
+
console.log('Input:');
|
|
52
|
+
console.log(` ${displayInput}`);
|
|
53
|
+
console.log('');
|
|
54
|
+
console.log('Output:');
|
|
55
|
+
console.log(` ${displayOutput}`);
|
|
56
|
+
console.log('');
|
|
57
|
+
try {
|
|
58
|
+
await convertMarkdownToPdf(inputPath, {
|
|
59
|
+
output: options.output,
|
|
60
|
+
onProgress: (event) => {
|
|
61
|
+
console.log(event.message);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
console.log('');
|
|
65
|
+
console.log('Done.');
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.error('');
|
|
69
|
+
if (err instanceof Error) {
|
|
70
|
+
console.error(`Error: ${err.message}`);
|
|
71
|
+
if (err.cause && err.cause instanceof Error && err.cause.message !== err.message) {
|
|
72
|
+
console.error(`Reason: ${err.cause.message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
console.error(`Error: ${String(err)}`);
|
|
77
|
+
}
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return program;
|
|
82
|
+
}
|
|
83
|
+
export async function runCli(argv = process.argv) {
|
|
84
|
+
const program = createCliCommand();
|
|
85
|
+
await program.parseAsync(argv);
|
|
86
|
+
}
|
|
87
|
+
const isDirectExecution = process.argv[1]?.endsWith('/cli/index.js') ||
|
|
88
|
+
process.argv[1]?.endsWith('/cli/index.ts') ||
|
|
89
|
+
process.argv[1]?.endsWith('/md-tech-pdf');
|
|
90
|
+
if (isDirectExecution) {
|
|
91
|
+
runCli().catch((err) => {
|
|
92
|
+
console.error('Unexpected CLI error:', err);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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EAAE,QAAQ,CAAC,eAAe,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;AAE5C,IAAI,iBAAiB,EAAE,CAAC;IACtB,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QAC9B,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PdfOptions } from '../pdf/types.js';
|
|
2
|
+
import type { RawDiagramOptions, ResolvedDiagramOptions } from '../types/diagram.js';
|
|
3
|
+
import { type DiagramDefaultOptions, type PdfDocumentOptions } from './document-options.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves diagram options following the strict precedence hierarchy:
|
|
6
|
+
* 1. Code block individual attribute (RawDiagramOptions)
|
|
7
|
+
* 2. Document Front Matter (DiagramDefaultOptions)
|
|
8
|
+
* 3. Application default (DiagramDefaultOptions)
|
|
9
|
+
* 4. Built-in system default (fit: 'contain', align: 'center')
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveDiagramOptions(raw: RawDiagramOptions, docDefault?: DiagramDefaultOptions, appDefault?: DiagramDefaultOptions): ResolvedDiagramOptions;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves PDF rendering options following the precedence hierarchy:
|
|
14
|
+
* 1. Application-level options (e.g. CLI flag / API argument)
|
|
15
|
+
* 2. Document Front Matter (PdfDocumentOptions)
|
|
16
|
+
* 3. Built-in system default (A4, portrait, 15mm margins, printBackground: true)
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolvePdfOptions(docPdf?: PdfDocumentOptions, appPdf?: PdfOptions): PdfOptions;
|
|
19
|
+
//# sourceMappingURL=config-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-resolver.d.ts","sourceRoot":"","sources":["../../src/config/config-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,iBAAiB,EACtB,UAAU,CAAC,EAAE,qBAAqB,EAClC,UAAU,CAAC,EAAE,qBAAqB,GACjC,sBAAsB,CAaxB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAY9F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DEFAULT_PDF_OPTIONS } from '../pdf/default-options.js';
|
|
2
|
+
import { BUILTIN_DEFAULT_DIAGRAM_OPTIONS, } from './document-options.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves diagram options following the strict precedence hierarchy:
|
|
5
|
+
* 1. Code block individual attribute (RawDiagramOptions)
|
|
6
|
+
* 2. Document Front Matter (DiagramDefaultOptions)
|
|
7
|
+
* 3. Application default (DiagramDefaultOptions)
|
|
8
|
+
* 4. Built-in system default (fit: 'contain', align: 'center')
|
|
9
|
+
*/
|
|
10
|
+
export function resolveDiagramOptions(raw, docDefault, appDefault) {
|
|
11
|
+
const width = raw.width ?? docDefault?.width ?? appDefault?.width ?? undefined;
|
|
12
|
+
const height = raw.height ?? docDefault?.height ?? appDefault?.height ?? undefined;
|
|
13
|
+
const fit = raw.fit ?? docDefault?.fit ?? appDefault?.fit ?? BUILTIN_DEFAULT_DIAGRAM_OPTIONS.fit;
|
|
14
|
+
const align = raw.align ?? docDefault?.align ?? appDefault?.align ?? BUILTIN_DEFAULT_DIAGRAM_OPTIONS.align;
|
|
15
|
+
return {
|
|
16
|
+
width,
|
|
17
|
+
height,
|
|
18
|
+
fit,
|
|
19
|
+
align,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolves PDF rendering options following the precedence hierarchy:
|
|
24
|
+
* 1. Application-level options (e.g. CLI flag / API argument)
|
|
25
|
+
* 2. Document Front Matter (PdfDocumentOptions)
|
|
26
|
+
* 3. Built-in system default (A4, portrait, 15mm margins, printBackground: true)
|
|
27
|
+
*/
|
|
28
|
+
export function resolvePdfOptions(docPdf, appPdf) {
|
|
29
|
+
return {
|
|
30
|
+
format: appPdf?.format ?? docPdf?.format ?? DEFAULT_PDF_OPTIONS.format,
|
|
31
|
+
landscape: appPdf?.landscape ?? docPdf?.landscape ?? DEFAULT_PDF_OPTIONS.landscape,
|
|
32
|
+
printBackground: appPdf?.printBackground ?? DEFAULT_PDF_OPTIONS.printBackground,
|
|
33
|
+
margin: {
|
|
34
|
+
top: appPdf?.margin?.top ?? docPdf?.margin?.top ?? DEFAULT_PDF_OPTIONS.margin.top,
|
|
35
|
+
right: appPdf?.margin?.right ?? docPdf?.margin?.right ?? DEFAULT_PDF_OPTIONS.margin.right,
|
|
36
|
+
bottom: appPdf?.margin?.bottom ?? docPdf?.margin?.bottom ?? DEFAULT_PDF_OPTIONS.margin.bottom,
|
|
37
|
+
left: appPdf?.margin?.left ?? docPdf?.margin?.left ?? DEFAULT_PDF_OPTIONS.margin.left,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=config-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-resolver.js","sourceRoot":"","sources":["../../src/config/config-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EACL,+BAA+B,GAGhC,MAAM,uBAAuB,C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EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM;YAC7F,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,mBAAmB,CAAC,MAAM,CAAC,IAAI;SACtF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { DiagramAlign, DiagramFit, ResolvedDiagramOptions } from '../types/diagram.js';
|
|
2
|
+
export interface PdfMarginOptions {
|
|
3
|
+
top?: string;
|
|
4
|
+
right?: string;
|
|
5
|
+
bottom?: string;
|
|
6
|
+
left?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PdfDocumentOptions {
|
|
9
|
+
format?: 'A4';
|
|
10
|
+
landscape?: boolean;
|
|
11
|
+
margin?: PdfMarginOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface DiagramDefaultOptions {
|
|
14
|
+
width?: string;
|
|
15
|
+
height?: string;
|
|
16
|
+
fit?: DiagramFit;
|
|
17
|
+
align?: DiagramAlign;
|
|
18
|
+
}
|
|
19
|
+
export interface MermaidDocumentOptions {
|
|
20
|
+
theme?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PlantUmlDocumentOptions {
|
|
23
|
+
javaPath?: string;
|
|
24
|
+
jarPath?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface GoogleFontFamily {
|
|
27
|
+
name: string;
|
|
28
|
+
weights?: number[];
|
|
29
|
+
}
|
|
30
|
+
export interface GoogleFontsOptions {
|
|
31
|
+
families: GoogleFontFamily[];
|
|
32
|
+
}
|
|
33
|
+
export interface FontOptions {
|
|
34
|
+
family?: string;
|
|
35
|
+
codeFamily?: string;
|
|
36
|
+
google?: GoogleFontsOptions;
|
|
37
|
+
}
|
|
38
|
+
export interface StyleDocumentOptions {
|
|
39
|
+
font?: FontOptions;
|
|
40
|
+
}
|
|
41
|
+
export interface DocumentOptions {
|
|
42
|
+
pdf?: PdfDocumentOptions;
|
|
43
|
+
diagram?: DiagramDefaultOptions;
|
|
44
|
+
mermaid?: MermaidDocumentOptions;
|
|
45
|
+
plantuml?: PlantUmlDocumentOptions;
|
|
46
|
+
style?: StyleDocumentOptions;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Built-in default options for diagrams.
|
|
50
|
+
*/
|
|
51
|
+
export declare const BUILTIN_DEFAULT_DIAGRAM_OPTIONS: Readonly<ResolvedDiagramOptions>;
|
|
52
|
+
//# sourceMappingURL=document-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-options.d.ts","sourceRoot":"","sources":["../../src/config/document-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE5F,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,kBAAkB,CAAC;IACzB,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,sBAAsB,CAG5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-options.js","sourceRoot":"","sources":["../../src/config/document-options.ts"],"names":[],"mappings":"AA0DA;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAqC;IAC/E,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,QAAQ;CAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface FrontMatterErrorOptions {
|
|
2
|
+
path?: string;
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when YAML Front Matter has syntax errors or invalid configuration values.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FrontMatterError extends Error {
|
|
9
|
+
readonly path?: string;
|
|
10
|
+
constructor(message: string, options?: FrontMatterErrorOptions);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/config/error.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB;CAK/D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when YAML Front Matter has syntax errors or invalid configuration values.
|
|
3
|
+
*/
|
|
4
|
+
export class FrontMatterError extends Error {
|
|
5
|
+
path;
|
|
6
|
+
constructor(message, options) {
|
|
7
|
+
super(message, { cause: options?.cause });
|
|
8
|
+
this.name = 'FrontMatterError';
|
|
9
|
+
this.path = options?.path;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/config/error.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzB,IAAI,CAAU;IAE9B,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DocumentOptions } from './document-options.js';
|
|
2
|
+
export interface ParsedFrontMatter {
|
|
3
|
+
content: string;
|
|
4
|
+
options: DocumentOptions;
|
|
5
|
+
rawFrontMatter?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Extracts and validates YAML Front Matter from Markdown source text.
|
|
9
|
+
* Strips the Front Matter block from the returned content.
|
|
10
|
+
*
|
|
11
|
+
* @param source Raw Markdown document text
|
|
12
|
+
* @returns Parsed content and validated DocumentOptions
|
|
13
|
+
* @throws {FrontMatterError} On YAML syntax errors or invalid configuration values
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseFrontMatter(source: string): ParsedFrontMatter;
|
|
16
|
+
//# sourceMappingURL=frontmatter-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-parser.d.ts","sourceRoot":"","sources":["../../src/config/frontmatter-parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAQhB,MAAM,uBAAuB,CAAC;AAgU/B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAqElE"}
|