@dkothule/md2pdf 1.0.0 → 1.0.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 +77 -151
- package/package.json +21 -1
package/README.md
CHANGED
|
@@ -4,244 +4,170 @@
|
|
|
4
4
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
+
`@dkothule/md2pdf` is a Markdown to PDF CLI for macOS and Linux with first-class Mermaid support.
|
|
8
|
+
It keeps Mermaid diagrams sharp in PDF by rendering vector assets (SVG by default) and includes automatic fallback logic for Mermaid flowcharts/graphs when needed.
|
|
7
9
|
|
|
8
|
-
## Why
|
|
10
|
+
## Why md2pdf
|
|
9
11
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- Auto
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- Cleans Mermaid temp assets by default after conversion.
|
|
19
|
-
|
|
20
|
-
## Package layout
|
|
21
|
-
|
|
22
|
-
- `bin/`: user-facing CLI commands (`md2pdf`, Finder Quick Action installers).
|
|
23
|
-
- `lib/`: internal runtime helpers (Pandoc Mermaid filter + wrapper).
|
|
24
|
-
- `assets/`: bundled static assets (`table-style.tex`, `mermaid.config.json`).
|
|
25
|
-
- `scripts/`: helper scripts exposed as secondary commands.
|
|
26
|
-
- `tests/`: repo-only smoke tests and Mermaid samples (not published to npm).
|
|
27
|
-
|
|
28
|
-
## Platform support
|
|
29
|
-
|
|
30
|
-
- macOS: fully supported (CLI + Finder Quick Action).
|
|
31
|
-
- Linux: supported for CLI conversion.
|
|
32
|
-
- Finder context menu integration: macOS only.
|
|
12
|
+
- Markdown to PDF from the terminal.
|
|
13
|
+
- Mermaid to PDF with high-resolution vector rendering.
|
|
14
|
+
- SVG-first pipeline for crisp diagrams at any zoom level.
|
|
15
|
+
- Auto fallback to Mermaid PDF for diagrams that use `foreignObject` labels.
|
|
16
|
+
- Fit-to-content PDF fallback (`--pdfFit`) to avoid full-page diagram artifacts.
|
|
17
|
+
- Better edge-label readability in flowchart/graph diagrams.
|
|
18
|
+
- Configurable defaults (`~/.config/md2pdf/config.env`, project `.md2pdfrc`, or `--config`).
|
|
19
|
+
- Optional Finder Quick Action integration on macOS.
|
|
33
20
|
|
|
34
21
|
## Install
|
|
35
22
|
|
|
36
23
|
### 1) Install system dependencies
|
|
37
24
|
|
|
38
|
-
From repo checkout:
|
|
25
|
+
From repo checkout, install required tools:
|
|
39
26
|
|
|
40
27
|
```bash
|
|
41
28
|
./install-system-deps.sh
|
|
42
29
|
```
|
|
43
30
|
|
|
44
|
-
|
|
31
|
+
### 2) Install md2pdf CLI
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm i -g @dkothule/md2pdf
|
|
35
|
+
python3 -m pip install pandocfilters
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## System requirements
|
|
39
|
+
|
|
45
40
|
- `pandoc`
|
|
46
|
-
-
|
|
41
|
+
- LaTeX PDF engine (`xelatex` default)
|
|
47
42
|
- `librsvg` / `rsvg-convert`
|
|
48
|
-
- `node` + `npm`
|
|
49
43
|
- `python3`
|
|
50
|
-
-
|
|
44
|
+
- `node` + `npm`
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
## macOS Finder Quick Action (Optional)
|
|
53
47
|
|
|
54
|
-
|
|
48
|
+
Install Finder context menu action:
|
|
55
49
|
|
|
56
50
|
```bash
|
|
57
|
-
|
|
58
|
-
python3 -m pip install pandocfilters
|
|
51
|
+
md2pdf-install-finder-action
|
|
59
52
|
```
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
Uninstall Finder context menu action:
|
|
62
55
|
|
|
63
56
|
```bash
|
|
64
|
-
|
|
57
|
+
md2pdf-uninstall-finder-action
|
|
65
58
|
```
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
If Finder menu does not refresh immediately:
|
|
68
61
|
|
|
69
62
|
```bash
|
|
70
|
-
|
|
63
|
+
killall Finder
|
|
71
64
|
```
|
|
72
65
|
|
|
73
|
-
|
|
66
|
+
After installation, right-click any `.md` file in Finder:
|
|
67
|
+
|
|
68
|
+
`Quick Actions` -> `Convert Markdown to PDF`
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
## Quick start
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
Convert Markdown to PDF (output goes beside input by default):
|
|
76
75
|
|
|
77
76
|
```bash
|
|
78
|
-
md2pdf
|
|
77
|
+
md2pdf ./notes.md
|
|
79
78
|
```
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
Custom output path:
|
|
82
81
|
|
|
83
82
|
```bash
|
|
84
|
-
md2pdf
|
|
85
|
-
md2pdf --version
|
|
86
|
-
md2pdf --init
|
|
87
|
-
md2pdf --init /path/to/config.env --force
|
|
83
|
+
md2pdf ./notes.md -o ./build/notes.pdf
|
|
88
84
|
```
|
|
89
85
|
|
|
90
|
-
|
|
86
|
+
Keep generated Mermaid assets for debugging:
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
```bash
|
|
89
|
+
md2pdf ./notes.md --keep-mermaid-assets
|
|
90
|
+
```
|
|
93
91
|
|
|
94
|
-
|
|
95
|
-
- executable command: `$(npm prefix -g)/bin/md2pdf`
|
|
92
|
+
## Mermaid support details
|
|
96
93
|
|
|
97
|
-
|
|
94
|
+
md2pdf uses:
|
|
98
95
|
|
|
99
|
-
-
|
|
100
|
-
-
|
|
96
|
+
- `MERMAID_LATEX_FORMAT=svg` by default for vector quality in PDF.
|
|
97
|
+
- `MERMAID_AUTO_PDF_FALLBACK=true` by default to preserve flowchart/graph node labels when SVG uses `foreignObject`.
|
|
98
|
+
- `MERMAID_PDF_FIT=true` by default so Mermaid PDF fallback assets use tight bounds and do not force one-diagram-per-page.
|
|
101
99
|
|
|
102
100
|
## Configuration
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
Config precedence (later overrides earlier):
|
|
105
103
|
|
|
106
104
|
1. `$HOME/.config/md2pdf/config.env`
|
|
107
105
|
2. `<input-markdown-directory>/.md2pdfrc`
|
|
108
106
|
3. `--config /path/to/config.env`
|
|
109
|
-
4.
|
|
107
|
+
4. Environment variables
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
Create starter config:
|
|
112
110
|
|
|
113
111
|
```bash
|
|
114
112
|
md2pdf --init
|
|
115
113
|
```
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- `~/.config/md2pdf/config.env`
|
|
120
|
-
|
|
121
|
-
Initialize to a custom path:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
md2pdf --init ./md2pdf.config.env
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
If target file already exists, re-run with `--force` to overwrite.
|
|
128
|
-
|
|
129
|
-
Manual template copy (optional):
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
mkdir -p ~/.config/md2pdf
|
|
133
|
-
cp ./md2pdf.config.example ~/.config/md2pdf/config.env
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
If installed globally from npm, template path is:
|
|
115
|
+
Create starter config at custom path:
|
|
137
116
|
|
|
138
117
|
```bash
|
|
139
|
-
|
|
118
|
+
md2pdf --init ./md2pdf.config.env --force
|
|
140
119
|
```
|
|
141
120
|
|
|
142
121
|
Example config:
|
|
143
122
|
|
|
144
123
|
```bash
|
|
145
124
|
PDF_ENGINE=xelatex
|
|
146
|
-
|
|
125
|
+
LR_MARGIN=0.7in
|
|
126
|
+
TB_MARGIN=0.5in
|
|
147
127
|
MERMAID_LATEX_FORMAT=svg
|
|
148
128
|
MERMAID_PDF_FIT=true
|
|
149
129
|
MERMAID_AUTO_PDF_FALLBACK=true
|
|
150
|
-
LR_MARGIN=0.7in
|
|
151
|
-
TB_MARGIN=0.5in
|
|
152
130
|
CLEANUP_MERMAID_ASSETS=true
|
|
153
131
|
MERMAID_ASSET_PREFIX=md2pdf-mermaid
|
|
154
132
|
```
|
|
155
133
|
|
|
156
|
-
|
|
134
|
+
## CLI reference
|
|
157
135
|
|
|
158
136
|
```bash
|
|
159
|
-
md2pdf
|
|
160
|
-
md2pdf
|
|
161
|
-
md2pdf
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Mermaid temp assets
|
|
165
|
-
|
|
166
|
-
When Mermaid blocks are present, md2pdf creates:
|
|
167
|
-
|
|
168
|
-
- `<MERMAID_ASSET_PREFIX>-<run-id>-images/`
|
|
169
|
-
|
|
170
|
-
By default, this folder is deleted after conversion (`CLEANUP_MERMAID_ASSETS=true`).
|
|
171
|
-
|
|
172
|
-
## macOS Finder Quick Action
|
|
173
|
-
|
|
174
|
-
Install:
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
md2pdf-install-finder-action
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Or from repo:
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
./scripts/install_md2pdf_quick_action.sh
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Use in Finder:
|
|
187
|
-
|
|
188
|
-
- Right click `.md` file -> `Quick Actions` -> `Convert Markdown to PDF`
|
|
189
|
-
|
|
190
|
-
Remove:
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
md2pdf-uninstall-finder-action
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Or from repo:
|
|
197
|
-
|
|
198
|
-
```bash
|
|
199
|
-
./scripts/uninstall_md2pdf_quick_action.sh
|
|
137
|
+
md2pdf --help
|
|
138
|
+
md2pdf --version
|
|
139
|
+
md2pdf --init
|
|
200
140
|
```
|
|
201
141
|
|
|
202
|
-
|
|
142
|
+
Common options:
|
|
203
143
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
144
|
+
- `-o, --output <file>`: output PDF path
|
|
145
|
+
- `--config <file>`: load additional config file
|
|
146
|
+
- `--keep-mermaid-assets`: keep generated Mermaid temp files
|
|
147
|
+
- `--cleanup-mermaid-assets`: remove generated Mermaid temp files (default)
|
|
207
148
|
|
|
208
|
-
##
|
|
149
|
+
## Test samples
|
|
209
150
|
|
|
210
|
-
-
|
|
211
|
-
-
|
|
212
|
-
- Mermaid all-diagram sample pack: `tests/samples/mermaid-all-diagram-types.md`
|
|
151
|
+
- Smoke test: `tests/architecture-smoke-test.md`
|
|
152
|
+
- Mermaid sample pack: `tests/samples/mermaid-all-diagram-types.md`
|
|
213
153
|
|
|
214
|
-
Run
|
|
154
|
+
Run:
|
|
215
155
|
|
|
216
156
|
```bash
|
|
217
157
|
md2pdf ./tests/architecture-smoke-test.md
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Run the full Mermaid sample suite:
|
|
221
|
-
|
|
222
|
-
```bash
|
|
223
158
|
md2pdf ./tests/samples/mermaid-all-diagram-types.md --keep-mermaid-assets
|
|
224
159
|
```
|
|
225
160
|
|
|
226
|
-
##
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
npm login
|
|
230
|
-
npm pack --dry-run
|
|
231
|
-
npm publish
|
|
232
|
-
```
|
|
161
|
+
## Troubleshooting
|
|
233
162
|
|
|
234
|
-
|
|
163
|
+
- `mmdc not found`: install dependencies and verify `MERMAID_BIN`.
|
|
164
|
+
- Flowchart/graph labels missing in PDF: keep `MERMAID_AUTO_PDF_FALLBACK=true`.
|
|
165
|
+
- Diagram taking a full page: keep `MERMAID_PDF_FIT=true`.
|
|
166
|
+
- PDF engine missing: install `xelatex` or set `PDF_ENGINE`.
|
|
235
167
|
|
|
236
|
-
##
|
|
168
|
+
## Keywords
|
|
237
169
|
|
|
238
|
-
|
|
239
|
-
- Flowchart/graph node labels missing in PDF: keep `MERMAID_AUTO_PDF_FALLBACK=true` (default) so affected SVG diagrams auto-fallback to Mermaid PDF per-diagram.
|
|
240
|
-
- To force pure SVG only (disable fallback): set `MERMAID_AUTO_PDF_FALLBACK=false`.
|
|
241
|
-
- Mermaid diagrams consuming a full page in output PDF: keep `MERMAID_PDF_FIT=true` (default) so Mermaid PDF assets use tight bounds.
|
|
242
|
-
- Mermaid still generating `.svg` instead of `.pdf`: check `~/.config/md2pdf/config.env` and remove/adjust `MERMAID_LATEX_FORMAT=svg`.
|
|
243
|
-
- PDF engine not found: install `xelatex` or set `PDF_ENGINE` to an installed engine.
|
|
244
|
-
- Finder Quick Action not visible: run `killall Finder`.
|
|
170
|
+
markdown to pdf, md to pdf, mermaid to pdf, mermaid svg, pandoc markdown pdf, markdown pdf cli, macOS markdown pdf, Linux markdown pdf
|
|
245
171
|
|
|
246
172
|
## License
|
|
247
173
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dkothule/md2pdf",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Markdown to PDF converter with high-resolution Mermaid diagram rendering",
|
|
5
5
|
"author": "Deepak Kothule",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"markdown",
|
|
9
|
+
"md",
|
|
10
|
+
"pdf",
|
|
11
|
+
"markdown-to-pdf",
|
|
12
|
+
"md2pdf",
|
|
13
|
+
"mermaid",
|
|
14
|
+
"mermaid-cli",
|
|
15
|
+
"pandoc",
|
|
16
|
+
"documentation",
|
|
17
|
+
"cli"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/dkothule/md2pdf.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/dkothule/md2pdf#readme",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/dkothule/md2pdf/issues"
|
|
26
|
+
},
|
|
7
27
|
"publishConfig": {
|
|
8
28
|
"access": "public"
|
|
9
29
|
},
|