printdown 1.1.1 → 1.2.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 +177 -0
- package/dist/{chunk-ZB6NLLOD.js → chunk-BLKOSAAA.js} +861 -59
- package/dist/chunk-BLKOSAAA.js.map +1 -0
- package/dist/{chunk-GEQQR3U7.js → chunk-QYKBYAYW.js} +221 -4
- package/dist/chunk-QYKBYAYW.js.map +1 -0
- package/dist/cli.js +24 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +89 -2
- package/dist/index.js +19 -5
- package/dist/themes/default/index.d.ts +8 -2
- package/dist/themes/default/index.js +5 -1
- package/dist/themes/default/style.css +211 -3
- package/package.json +3 -1
- package/dist/chunk-GEQQR3U7.js.map +0 -1
- package/dist/chunk-ZB6NLLOD.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Printdown turns Markdown into clean, publication-grade PDFs, PNGs, JPEGs, and We
|
|
|
13
13
|
- **Badges & Labels**: Badges with `<Badge>` / `[badge:...]` supporting `solid`, `soft`, and `outline` variants.
|
|
14
14
|
- **Keyboard Keys**: Styled keyboard keys with `<Kbd icon="command" />` / `[kbd:...]` and embedded icon masks.
|
|
15
15
|
- **Center Alignment**: Center text, headings, or blocks with `::: center`, `-> text <-`, `<center>`, or `[center:...]`.
|
|
16
|
+
- **Page Breaks**: Force page breaks in PDFs using `<!-- pagebreak -->`, `\pagebreak`, `[pagebreak]`, `<pagebreak />`, or `{.page-break}` on headings.
|
|
16
17
|
- **Heading Border Control**: Remove underline/border from individual headings using `{.no-border}` or `{-}`.
|
|
17
18
|
- **Code Highlighting**: Syntax highlighting powered by **Shiki** with dark theme support.
|
|
18
19
|
- **Custom CSS & Variables**: Full control over styling by overriding OKLCH CSS variables or injecting custom CSS.
|
|
@@ -82,6 +83,10 @@ npx printdown document.md -o page.png -f png --pages
|
|
|
82
83
|
# Set image output scale (e.g. 1x, 2x, 3x)
|
|
83
84
|
npx printdown document.md -o output-3x.png -f png --scale 3
|
|
84
85
|
|
|
86
|
+
# Add headers, footers, and page numbers
|
|
87
|
+
npx printdown document.md --header "My Document | {date}" -n
|
|
88
|
+
npx printdown document.md --footer "Confidential | Page {page} of {total}"
|
|
89
|
+
|
|
85
90
|
# Apply custom CSS
|
|
86
91
|
npx printdown document.md -o output.pdf --css ./custom.css
|
|
87
92
|
|
|
@@ -236,6 +241,167 @@ In Printdown's default theme, `h1` has a bottom border/underline. You can remove
|
|
|
236
241
|
<h1 no-border>Title Without Underline</h1>
|
|
237
242
|
```
|
|
238
243
|
|
|
244
|
+
## Page Breaks (PDF & Print)
|
|
245
|
+
|
|
246
|
+
Printdown supports manual page breaks in PDF output:
|
|
247
|
+
|
|
248
|
+
### Standalone Page Break Syntax
|
|
249
|
+
|
|
250
|
+
```markdown
|
|
251
|
+
Page 1 Content...
|
|
252
|
+
|
|
253
|
+
<!-- pagebreak -->
|
|
254
|
+
|
|
255
|
+
Page 2 Content...
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
You can also use any of the following equivalents:
|
|
259
|
+
|
|
260
|
+
```markdown
|
|
261
|
+
\pagebreak
|
|
262
|
+
\newpage
|
|
263
|
+
[pagebreak]
|
|
264
|
+
<pagebreak />
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Container Block Syntax
|
|
268
|
+
|
|
269
|
+
```markdown
|
|
270
|
+
::: pagebreak
|
|
271
|
+
:::
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Heading Page Break Attribute
|
|
275
|
+
|
|
276
|
+
Force a heading to always start at the top of a new page:
|
|
277
|
+
|
|
278
|
+
```markdown
|
|
279
|
+
# Next Chapter {.page-break}
|
|
280
|
+
|
|
281
|
+
# Section Title {.break-before}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Cover Pages
|
|
285
|
+
|
|
286
|
+
Printdown provides a built-in cover page generator that automatically formats a full-page cover with vertically and horizontally centered typography, optional metadata, and automatic page breaks.
|
|
287
|
+
|
|
288
|
+
### Container Block Syntax
|
|
289
|
+
|
|
290
|
+
```markdown
|
|
291
|
+
::: cover
|
|
292
|
+
|
|
293
|
+
# Document Title
|
|
294
|
+
|
|
295
|
+
A concise subtitle or description of the document
|
|
296
|
+
|
|
297
|
+
[badge(soft):Official Guide] [badge(soft,amber):v1.1.2]
|
|
298
|
+
|
|
299
|
+
::: cover-meta
|
|
300
|
+
**Author**: Engineering Team
|
|
301
|
+
**Date**: 2026-08-30
|
|
302
|
+
**Status**: Ready for Review
|
|
303
|
+
:::
|
|
304
|
+
:::
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### HTML Tag Syntax
|
|
308
|
+
|
|
309
|
+
```markdown
|
|
310
|
+
<cover>
|
|
311
|
+
|
|
312
|
+
# Technical Proposal
|
|
313
|
+
|
|
314
|
+
Subheading description
|
|
315
|
+
|
|
316
|
+
<div class="printdown-cover-meta">
|
|
317
|
+
<strong>Author</strong>: Architecture Team
|
|
318
|
+
</div>
|
|
319
|
+
</cover>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Mathematical Formulas (KaTeX)
|
|
323
|
+
|
|
324
|
+
Printdown includes built-in math formula typesetting powered by KaTeX, preloaded with KaTeX web fonts for offline and fast rendering.
|
|
325
|
+
|
|
326
|
+
### Inline Math
|
|
327
|
+
|
|
328
|
+
Use `$ ... $` or `\( ... \)` for inline formulas:
|
|
329
|
+
|
|
330
|
+
```markdown
|
|
331
|
+
The mass-energy equivalence is defined as $E = mc^2$.
|
|
332
|
+
Euler's formula states that \(e^{i\pi} + 1 = 0\).
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Display / Block Math
|
|
336
|
+
|
|
337
|
+
Use `$$ ... $$` for display equations:
|
|
338
|
+
|
|
339
|
+
```markdown
|
|
340
|
+
$$
|
|
341
|
+
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
|
|
342
|
+
$$
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Fenced Code Blocks & Container Syntax
|
|
346
|
+
|
|
347
|
+
You can also use `math` or `latex` code blocks:
|
|
348
|
+
|
|
349
|
+
````markdown
|
|
350
|
+
```math
|
|
351
|
+
f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!} (x - a)^n
|
|
352
|
+
```
|
|
353
|
+
````
|
|
354
|
+
|
|
355
|
+
Or container blocks:
|
|
356
|
+
|
|
357
|
+
```markdown
|
|
358
|
+
::: math
|
|
359
|
+
\mathbf{F} = m \mathbf{a}
|
|
360
|
+
:::
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Headers, Footers & Page Numbers
|
|
364
|
+
|
|
365
|
+
Printdown supports configurable headers, footers, and page numbers for PDF generation and multi-page image exports.
|
|
366
|
+
|
|
367
|
+
### Template Placeholders
|
|
368
|
+
|
|
369
|
+
- `{page}`: Current page number
|
|
370
|
+
- `{total}` or `{totalPages}`: Total number of pages
|
|
371
|
+
- `{title}`: Document title
|
|
372
|
+
- `{date}`: Formatted print date
|
|
373
|
+
|
|
374
|
+
Use the `|` delimiter to create multi-column layouts (e.g. `Left | Right` or `Left | Center | Right`).
|
|
375
|
+
|
|
376
|
+
### Programmatic Usage
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
import { render } from "printdown";
|
|
380
|
+
|
|
381
|
+
await render(markdown, {
|
|
382
|
+
output: "document.pdf",
|
|
383
|
+
// Simple header and footer
|
|
384
|
+
header: "Project Specification | {date}",
|
|
385
|
+
footer: "Confidential | Page {page} of {total}",
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// Shortcut for page numbers
|
|
389
|
+
await render(markdown, {
|
|
390
|
+
output: "document.pdf",
|
|
391
|
+
pageNumber: true, // Displays "{page} / {total}" centered in footer
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### CLI Usage
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Add header with date and page numbers in footer
|
|
399
|
+
npx printdown report.md --header "Report Title | {date}" -n
|
|
400
|
+
|
|
401
|
+
# Custom footer format
|
|
402
|
+
npx printdown report.md --footer "Confidential | Page {page} of {total}"
|
|
403
|
+
```
|
|
404
|
+
|
|
239
405
|
## CSS Customization
|
|
240
406
|
|
|
241
407
|
Printdown loads styles in a predictable cascade:
|
|
@@ -313,6 +479,12 @@ function render(markdown: string, options?: RenderOptions): Promise<Buffer | Buf
|
|
|
313
479
|
- `height?: number`: Viewport height in pixels (default: 800).
|
|
314
480
|
- `deviceScaleFactor?: number`: Alias for `scale`.
|
|
315
481
|
- `quality?: number`: Quality for JPEG and WebP output (0-100, default: 90).
|
|
482
|
+
- `header?: string | boolean`: Header text/template for PDF and multi-page output.
|
|
483
|
+
- `footer?: string | boolean`: Footer text/template for PDF and multi-page output.
|
|
484
|
+
- `pageNumber?: boolean | string`: Shortcut to enable page numbers in footer.
|
|
485
|
+
- `headerTemplate?: string`: Raw HTML header template for PDF output.
|
|
486
|
+
- `footerTemplate?: string`: Raw HTML footer template for PDF output.
|
|
487
|
+
- `displayHeaderFooter?: boolean`: Whether to show header and footer in PDF.
|
|
316
488
|
- `pdf?: PDFExportOptions`: Playwright PDF options (margin, format, landscape, etc.).
|
|
317
489
|
- `image?: ImageExportOptions`: Playwright screenshot options (fullPage, clip, etc.).
|
|
318
490
|
- `markdown?: MarkdownRenderOptions`: Markdown parser and Shiki highlighter options.
|
|
@@ -366,6 +538,11 @@ Options:
|
|
|
366
538
|
--page-height <height> Page height in pixels for pages mode
|
|
367
539
|
--margin-top <margin> Top margin in pixels for pages mode
|
|
368
540
|
--margin-bottom <margin> Bottom margin in pixels for pages mode
|
|
541
|
+
--header <text> Header text (supports {title}, {date}, {page}, {total}, and |)
|
|
542
|
+
--footer <text> Footer text (supports {title}, {date}, {page}, {total}, and |)
|
|
543
|
+
-n, --page-number [format] Show page number in footer (e.g., -n or -n 'Page {page} of {total}')
|
|
544
|
+
--header-template <html> Custom HTML template for PDF print header
|
|
545
|
+
--footer-template <html> Custom HTML template for PDF print footer
|
|
369
546
|
--quality <quality> JPEG / WebP image quality (0-100, default: 90)
|
|
370
547
|
-v, --version Display version number
|
|
371
548
|
-h, --help Display this message
|