@dimm-city/print-md 0.1.11
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 +246 -0
- package/dist/CGATS21_CRPC1-g0e3k7kr.icc +0 -0
- package/dist/cli.js +94560 -0
- package/dist/favicon-wkbm9cjn.ico +0 -0
- package/dist/manifest.schema-16z94mx1.json +325 -0
- package/dist/paged.polyfill-hwhs8hd5.js +33287 -0
- package/dist/pagedjs-bridge-39th325p.js +104 -0
- package/dist/pagedjs-interface-vzkzgeb9.js +94 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# @dimm-city/print-md
|
|
2
|
+
|
|
3
|
+
Command-line interface for print-md — markdown to print-ready PDF.
|
|
4
|
+
|
|
5
|
+
The CLI is for power users who want to script builds, run in CI, batch-process projects, or work outside the desktop app. If you just want to write a book and export a PDF, use the [desktop app](../../README.md#get-the-desktop-app) instead.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
### Standalone binary (no Node, no Bun required)
|
|
10
|
+
|
|
11
|
+
Download for your platform from the [latest release](https://github.com/dimm-city/print-md/releases/latest):
|
|
12
|
+
|
|
13
|
+
| Platform | Binary |
|
|
14
|
+
|---|---|
|
|
15
|
+
| Linux x64 | `print-md-cli-linux-x64` |
|
|
16
|
+
| Linux ARM64 | `print-md-cli-linux-arm64` |
|
|
17
|
+
| macOS Apple Silicon | `print-md-cli-macos-arm64` |
|
|
18
|
+
| macOS Intel | `print-md-cli-macos-x64` |
|
|
19
|
+
| Windows x64 | `print-md-cli-windows-x64.exe` |
|
|
20
|
+
|
|
21
|
+
Move the binary somewhere on your `PATH`, mark it executable (`chmod +x`), and you're done.
|
|
22
|
+
|
|
23
|
+
### From npm
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install -g @dimm-city/print-md
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This installs the CLI for `node`-based projects. Same surface area as the binary.
|
|
30
|
+
|
|
31
|
+
### With Docker (full PDF/X pipeline pre-installed)
|
|
32
|
+
|
|
33
|
+
No need to install Chromium, Ghostscript, or qpdf — the image bundles
|
|
34
|
+
everything the `lint → build → validate` pipeline needs, including the PDF/X
|
|
35
|
+
(CMYK) pre-print path. (All other validation runs in-process; Poppler and
|
|
36
|
+
ImageMagick are no longer used.) Mount your project at `/work`:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/work" \
|
|
40
|
+
ghcr.io/dimm-city/print-md build my-book --out dist/my-book.pdf --format pdfx
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See [docs/docker.md](../../docs/docker.md) for the full guide.
|
|
44
|
+
|
|
45
|
+
### From source (development only)
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
git clone https://github.com/dimm-city/print-md.git
|
|
49
|
+
cd print-md
|
|
50
|
+
bun install
|
|
51
|
+
bun packages/cli/src/cli.ts --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## System requirements
|
|
55
|
+
|
|
56
|
+
The CLI needs a Chromium-based browser for PDF generation, and a few external tools for PDF post-processing and validation depending on which features you use. See [User Guide: Chapter 8 — System Setup](../../examples/print-md-user-guide/08-system-setup.md) for the full per-feature requirements matrix.
|
|
57
|
+
|
|
58
|
+
The short version: you almost certainly want **Ghostscript** installed for PDF output, and **Chrome** / **Chromium** / **Edge** for the actual render.
|
|
59
|
+
|
|
60
|
+
## Quick start
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
# Build a PDF from a project directory
|
|
64
|
+
print-md build ./my-book
|
|
65
|
+
|
|
66
|
+
# Live preview server (Paged.js + websocket-driven full-reload on file change)
|
|
67
|
+
print-md preview ./my-book
|
|
68
|
+
|
|
69
|
+
# Custom output path
|
|
70
|
+
print-md build ./my-book --out dist/my-book.pdf
|
|
71
|
+
|
|
72
|
+
# Print-ready PDF/X (CMYK + ICC profile, validation enabled)
|
|
73
|
+
print-md build ./my-book --format pdfx --icc path/to/profile.icc
|
|
74
|
+
|
|
75
|
+
# HTML output (a self-contained directory with book.html + assets)
|
|
76
|
+
print-md build ./my-book --format html --out dist/my-book/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Project layout
|
|
80
|
+
|
|
81
|
+
A print-md project is a directory. The CLI doesn't impose much structure; the most common shape is:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
my-book/
|
|
85
|
+
├─ manifest.yaml ← optional but recommended; metadata + config
|
|
86
|
+
├─ chapter-01.md ← markdown files, processed in alphabetical order
|
|
87
|
+
├─ chapter-02.md (or in the order listed in manifest.yaml#source.files)
|
|
88
|
+
├─ css/ ← your stylesheets
|
|
89
|
+
│ └─ print.css
|
|
90
|
+
├─ fonts/ ← font files referenced from CSS @font-face
|
|
91
|
+
└─ images/ ← images referenced from markdown or CSS
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
See [User Guide: Chapter 1 — Getting Started](../../examples/print-md-user-guide/01-getting-started.md) for a full first-project walkthrough and [examples/](../../examples/) for working starters.
|
|
95
|
+
|
|
96
|
+
## Manifest
|
|
97
|
+
|
|
98
|
+
`manifest.yaml` is where you control everything that isn't authored in markdown — book title, the page-size preset, custom styles, plugin loading, validation rules, PDF/X configuration. The schema lives in [`docs/schema-autocomplete.md`](../../docs/schema-autocomplete.md) for YAML autocomplete in editors.
|
|
99
|
+
|
|
100
|
+
Minimal example:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
title: "My Book"
|
|
104
|
+
authors:
|
|
105
|
+
- "Your Name Here"
|
|
106
|
+
|
|
107
|
+
# Pick a page-size preset or supply page.width / page.height yourself
|
|
108
|
+
preset: dtrpg
|
|
109
|
+
|
|
110
|
+
styles:
|
|
111
|
+
- css/print.css
|
|
112
|
+
|
|
113
|
+
source:
|
|
114
|
+
files:
|
|
115
|
+
- chapter-01.md
|
|
116
|
+
- chapter-02.md
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The full configuration cascade is `CLI flags > manifest.yaml > preset defaults`. See [docs/user-guide.md](../../docs/user-guide.md#configuration) for the comprehensive reference.
|
|
120
|
+
|
|
121
|
+
## Commands
|
|
122
|
+
|
|
123
|
+
### `print-md build`
|
|
124
|
+
|
|
125
|
+
Build a PDF (default) or HTML output. Pipeline: `lint → validate:pre → convert → assets → build → validate:post`.
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
print-md build [input-dir] [options]
|
|
129
|
+
|
|
130
|
+
--format pdf | pdfx | html (default: pdf)
|
|
131
|
+
--out Output file or directory
|
|
132
|
+
--title Override manifest title
|
|
133
|
+
--skip-lint Skip the CSS print-safety pass
|
|
134
|
+
--skip-pre-validate
|
|
135
|
+
--skip-post-validate
|
|
136
|
+
--strip-annotations PDF/X only: flatten form annotations (default: true)
|
|
137
|
+
--icc <path> PDF/X only: ICC profile for CMYK conversion
|
|
138
|
+
--pdfx-flavor x1a | x3 (default: x3)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `print-md preview`
|
|
142
|
+
|
|
143
|
+
Start a live preview server. Serves `book.html` and triggers full-reload via WebSocket when files change.
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
print-md preview [input-dir] [options]
|
|
147
|
+
|
|
148
|
+
--port <n> Bind port (default: 3579)
|
|
149
|
+
--host <h> Bind host (default: 127.0.0.1)
|
|
150
|
+
--no-watch Skip file watcher
|
|
151
|
+
--open Open default browser (default: false)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Preview itself uses no external tools — pure JS rendering. Paged.js runs in your browser when you open the URL.
|
|
155
|
+
|
|
156
|
+
### `print-md lint`
|
|
157
|
+
|
|
158
|
+
Run print-md's print-safety CSS checks (postcss-based: remote URLs, rasterizing effects, Paged.js crash-prone selectors) against the project's CSS files.
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
print-md lint [input-dir] [--files <glob>]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Common print-unsafe patterns the plugin flags: remote `url(...)` references in CSS, paged.js-crashing `:is()`-with-sibling selectors, properties with no print equivalent.
|
|
165
|
+
|
|
166
|
+
### `print-md validate`
|
|
167
|
+
|
|
168
|
+
Run the validation pipeline (pre-build source checks and/or post-build PDF checks). Tools that aren't installed are skipped with a warning — they don't fail the run. See [User Guide: Chapter 7 — Validation](../../examples/print-md-user-guide/07-validation.md) for the full check list and [User Guide: Chapter 8 — System Setup](../../examples/print-md-user-guide/08-system-setup.md) for which external tools each check needs.
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
print-md validate [input-dir] [options]
|
|
172
|
+
|
|
173
|
+
--phase <p> pre | post | all (default: all)
|
|
174
|
+
--category <c> source | asset | pdf | heuristic
|
|
175
|
+
--only <ids> Comma-separated check IDs
|
|
176
|
+
--skip <ids> Comma-separated check IDs
|
|
177
|
+
--format text | json (default: text)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Plugins
|
|
181
|
+
|
|
182
|
+
print-md uses [markdown-it](https://github.com/markdown-it/markdown-it) under the hood, so any plugin that follows the `(md, options) => void` signature works out of the box. Load them in `manifest.yaml`:
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
plugins:
|
|
186
|
+
# npm package
|
|
187
|
+
- markdown-it-attrs
|
|
188
|
+
# local file
|
|
189
|
+
- ./plugins/my-custom-plugin.js
|
|
190
|
+
# with options
|
|
191
|
+
- name: markdown-it-footnote
|
|
192
|
+
options:
|
|
193
|
+
includeSubsections: false
|
|
194
|
+
# explicit priority (lower runs first)
|
|
195
|
+
- name: markdown-it-anchor
|
|
196
|
+
priority: 10
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
See [User Guide: Chapter 6 — Plugins](../../examples/print-md-user-guide/06-plugins.md) for authoring custom plugins.
|
|
200
|
+
|
|
201
|
+
## CI / scripting
|
|
202
|
+
|
|
203
|
+
The standalone binary is the easiest way — drop it in a GitHub Actions step and you're done:
|
|
204
|
+
|
|
205
|
+
```yaml
|
|
206
|
+
- name: Build PDF
|
|
207
|
+
run: |
|
|
208
|
+
curl -L -o print-md \
|
|
209
|
+
https://github.com/dimm-city/print-md/releases/latest/download/print-md-cli-linux-x64
|
|
210
|
+
chmod +x print-md
|
|
211
|
+
sudo apt-get install -y google-chrome-stable ghostscript
|
|
212
|
+
./print-md build ./my-book --out dist/my-book.pdf
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The binary is self-contained except for the system tools described in [User Guide: Chapter 8 — System Setup](../../examples/print-md-user-guide/08-system-setup.md). On a runner with Chrome and Ghostscript present, you don't need a separate Node or Bun install.
|
|
216
|
+
|
|
217
|
+
## Troubleshooting
|
|
218
|
+
|
|
219
|
+
- **`spawn gs ENOENT`** — Ghostscript not installed. Plain `--format pdf` keeps working (only loses the `/Creator` metadata stamp). PDF/X builds genuinely need it. See [User Guide: Chapter 8 — System Setup](../../examples/print-md-user-guide/08-system-setup.md).
|
|
220
|
+
- **`No Chrome or Chromium binary found`** — install Chrome/Chromium/Edge, or set `CHROMIUM_PATH=/path/to/chrome` in your environment.
|
|
221
|
+
- **`Tool "X" not found — skipping`** during validate — that's the graceful path; the check requires `X` and isn't available. Install the tool or accept the skip.
|
|
222
|
+
- **All validate checks skipped on Windows** — was a bug pre-0.1.7 (used `which`, which isn't on stock Windows); fixed to use `where.exe`.
|
|
223
|
+
|
|
224
|
+
## Development
|
|
225
|
+
|
|
226
|
+
This package is part of the [print-md monorepo](../../README.md). The CLI itself is a thin shell over [`@dimm-city/print-md-lib`](../lib/) — almost all logic lives there.
|
|
227
|
+
|
|
228
|
+
```sh
|
|
229
|
+
# From repo root
|
|
230
|
+
bun install
|
|
231
|
+
|
|
232
|
+
# Run CLI from source
|
|
233
|
+
bun packages/cli/src/cli.ts build ./examples/dc-design-guide
|
|
234
|
+
|
|
235
|
+
# Build the standalone binary for the current platform
|
|
236
|
+
bun --cwd packages/cli scripts/compile.ts bun-linux-x64 ./dist/print-md-cli-linux-x64
|
|
237
|
+
|
|
238
|
+
# Build the npm tarball
|
|
239
|
+
bun --cwd packages/cli scripts/build-npm.ts
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
See [`CONTRIBUTING.md`](../../CONTRIBUTING.md) for the contributor workflow and [`docs/ARCHITECTURE.md`](../../docs/ARCHITECTURE.md) for the architectural rules of this package (no bundlers at runtime, lazy-loaded heavy deps, etc).
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
[MPL-2.0](../../LICENSE)
|
|
Binary file
|