@speajus/markdown-to-pdf 1.0.11 → 1.0.12
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 +2 -1
- package/README.pdf +0 -0
- package/dist/renderer.js +10 -1
- package/dist/styles.js +3 -2
- package/dist/themes/index.js +8 -8
- package/dist/types.d.ts +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,6 +88,7 @@ interface PdfOptions {
|
|
|
88
88
|
syntaxHighlight?: boolean; // Enable syntax highlighting (default: true)
|
|
89
89
|
lineNumbers?: boolean; // Show line numbers in code blocks (default: false)
|
|
90
90
|
languages?: string[]; // Prism.js languages to load (default: all)
|
|
91
|
+
zebraStripes?: boolean; // Zebra-stripe table rows (default: true)
|
|
91
92
|
}
|
|
92
93
|
```
|
|
93
94
|
|
|
@@ -134,7 +135,7 @@ The full `ThemeConfig` interface exposes styles for:
|
|
|
134
135
|
| `code.inline` | Font, size, color, and background color |
|
|
135
136
|
| `code.block` | Font, size, color, background color, and padding |
|
|
136
137
|
| `blockquote` | Border color, border width, italic flag, and indent |
|
|
137
|
-
| `table` | Header background, border color, and
|
|
138
|
+
| `table` | Header background, border color, cell padding, and zebra color |
|
|
138
139
|
| `linkColor` | Color for hyperlink text |
|
|
139
140
|
| `horizontalRuleColor` | Color for `---` dividers |
|
|
140
141
|
|
package/README.pdf
CHANGED
|
Binary file
|
package/dist/renderer.js
CHANGED
|
@@ -23,6 +23,7 @@ async function renderMarkdownToPdf(markdown, options) {
|
|
|
23
23
|
(0, highlight_prism_js_1.loadHighlightLanguages)(options?.languages);
|
|
24
24
|
}
|
|
25
25
|
const lineNumbers = options?.lineNumbers ?? false;
|
|
26
|
+
const zebraStripes = options?.zebraStripes !== false;
|
|
26
27
|
const emojiFontOpt = options?.emojiFont ?? true;
|
|
27
28
|
// Use provided image renderer or create default Node.js renderer
|
|
28
29
|
const imageRenderer = options?.renderImage ?? defaults_js_1.DEFAULTS.renderImage(basePath);
|
|
@@ -549,8 +550,16 @@ async function renderMarkdownToPdf(markdown, options) {
|
|
|
549
550
|
doc.restore();
|
|
550
551
|
y += rowH;
|
|
551
552
|
// Body rows
|
|
552
|
-
|
|
553
|
+
const zebraColor = theme.table.zebraColor ?? '#f9f9f9';
|
|
554
|
+
for (let r = 0; r < table.rows.length; r++) {
|
|
555
|
+
const row = table.rows[r];
|
|
553
556
|
ensureSpace(rowH);
|
|
557
|
+
// Zebra stripe: fill even rows (0-indexed, so odd visual rows) with a tinted background
|
|
558
|
+
if (zebraStripes && r % 2 === 1) {
|
|
559
|
+
doc.save();
|
|
560
|
+
doc.rect(startX, y, contentWidth, rowH).fill(zebraColor);
|
|
561
|
+
doc.restore();
|
|
562
|
+
}
|
|
554
563
|
for (let c = 0; c < colCount; c++) {
|
|
555
564
|
const cellX = startX + c * colWidth;
|
|
556
565
|
await renderCellTokens(row[c], cellX + cellPad, y + textInsetY, colWidth - cellPad * 2, table.align[c] || 'left', false);
|
package/dist/styles.js
CHANGED
|
@@ -55,8 +55,8 @@ exports.defaultTheme = {
|
|
|
55
55
|
inline: {
|
|
56
56
|
font: 'Courier',
|
|
57
57
|
fontSize: 10,
|
|
58
|
-
color: '#
|
|
59
|
-
backgroundColor: '#
|
|
58
|
+
color: '#1a1a1a',
|
|
59
|
+
backgroundColor: '#f0f0f0',
|
|
60
60
|
},
|
|
61
61
|
block: {
|
|
62
62
|
font: 'Courier',
|
|
@@ -78,6 +78,7 @@ exports.defaultTheme = {
|
|
|
78
78
|
headerBackground: '#f0f0f0',
|
|
79
79
|
borderColor: '#cccccc',
|
|
80
80
|
cellPadding: 6,
|
|
81
|
+
zebraColor: '#f9f9f9',
|
|
81
82
|
},
|
|
82
83
|
syntaxHighlight: exports.defaultSyntaxHighlightTheme,
|
|
83
84
|
};
|
package/dist/themes/index.js
CHANGED
|
@@ -16,13 +16,13 @@ exports.modernTheme = {
|
|
|
16
16
|
},
|
|
17
17
|
body: { font: 'Helvetica', fontSize: 11, color: '#2d3436', lineGap: 5 },
|
|
18
18
|
code: {
|
|
19
|
-
inline: { font: 'Courier', fontSize: 10, color: '#
|
|
19
|
+
inline: { font: 'Courier', fontSize: 10, color: '#2d3436', backgroundColor: '#e8e8e8' },
|
|
20
20
|
block: { font: 'Courier', fontSize: 9, color: '#2d3436', backgroundColor: '#dfe6e9', padding: 10 },
|
|
21
21
|
},
|
|
22
22
|
blockquote: { borderColor: '#0d7377', borderWidth: 3, italic: true, indent: 20 },
|
|
23
23
|
linkColor: '#0984e3',
|
|
24
24
|
horizontalRuleColor: '#b2bec3',
|
|
25
|
-
table: { headerBackground: '#dfe6e9', borderColor: '#b2bec3', cellPadding: 7 },
|
|
25
|
+
table: { headerBackground: '#dfe6e9', borderColor: '#b2bec3', cellPadding: 7, zebraColor: '#f0f5f5' },
|
|
26
26
|
syntaxHighlight: {
|
|
27
27
|
background: '#e8f0f2',
|
|
28
28
|
gutter: '#636e72',
|
|
@@ -52,13 +52,13 @@ exports.academicTheme = {
|
|
|
52
52
|
},
|
|
53
53
|
body: { font: 'Times-Roman', fontSize: 12, color: '#1a1a2e', lineGap: 4 },
|
|
54
54
|
code: {
|
|
55
|
-
inline: { font: 'Courier', fontSize: 10, color: '#
|
|
55
|
+
inline: { font: 'Courier', fontSize: 10, color: '#1a1a2e', backgroundColor: '#ececec' },
|
|
56
56
|
block: { font: 'Courier', fontSize: 9, color: '#1a1a2e', backgroundColor: '#f2f3f4', padding: 8 },
|
|
57
57
|
},
|
|
58
58
|
blockquote: { borderColor: '#6c3483', borderWidth: 2, italic: true, indent: 24 },
|
|
59
59
|
linkColor: '#2e4057',
|
|
60
60
|
horizontalRuleColor: '#aab7b8',
|
|
61
|
-
table: { headerBackground: '#eaecee', borderColor: '#aab7b8', cellPadding: 6 },
|
|
61
|
+
table: { headerBackground: '#eaecee', borderColor: '#aab7b8', cellPadding: 6, zebraColor: '#f7f8f8' },
|
|
62
62
|
syntaxHighlight: {
|
|
63
63
|
background: '#f2f3f4',
|
|
64
64
|
gutter: '#7f8c8d',
|
|
@@ -88,13 +88,13 @@ exports.minimalTheme = {
|
|
|
88
88
|
},
|
|
89
89
|
body: { font: 'Helvetica', fontSize: 10, color: '#444444', lineGap: 5 },
|
|
90
90
|
code: {
|
|
91
|
-
inline: { font: 'Courier', fontSize: 9, color: '#
|
|
91
|
+
inline: { font: 'Courier', fontSize: 9, color: '#333333', backgroundColor: '#eeeeee' },
|
|
92
92
|
block: { font: 'Courier', fontSize: 9, color: '#444444', backgroundColor: '#fafafa', padding: 10 },
|
|
93
93
|
},
|
|
94
94
|
blockquote: { borderColor: '#cccccc', borderWidth: 2, italic: false, indent: 18 },
|
|
95
95
|
linkColor: '#555555',
|
|
96
96
|
horizontalRuleColor: '#e0e0e0',
|
|
97
|
-
table: { headerBackground: '#fafafa', borderColor: '#e0e0e0', cellPadding: 8 },
|
|
97
|
+
table: { headerBackground: '#fafafa', borderColor: '#e0e0e0', cellPadding: 8, zebraColor: '#f5f5f5' },
|
|
98
98
|
syntaxHighlight: {
|
|
99
99
|
background: '#f8f8f8',
|
|
100
100
|
gutter: '#999999',
|
|
@@ -124,13 +124,13 @@ exports.oceanTheme = {
|
|
|
124
124
|
},
|
|
125
125
|
body: { font: 'Helvetica', fontSize: 11, color: '#2c3e50', lineGap: 4 },
|
|
126
126
|
code: {
|
|
127
|
-
inline: { font: 'Courier', fontSize: 10, color: '#
|
|
127
|
+
inline: { font: 'Courier', fontSize: 10, color: '#1b2631', backgroundColor: '#e0e0e0' },
|
|
128
128
|
block: { font: 'Courier', fontSize: 9, color: '#2c3e50', backgroundColor: '#eaf2f8', padding: 8 },
|
|
129
129
|
},
|
|
130
130
|
blockquote: { borderColor: '#2980b9', borderWidth: 3, italic: true, indent: 20 },
|
|
131
131
|
linkColor: '#2471a3',
|
|
132
132
|
horizontalRuleColor: '#aed6f1',
|
|
133
|
-
table: { headerBackground: '#d4e6f1', borderColor: '#85c1e9', cellPadding: 6 },
|
|
133
|
+
table: { headerBackground: '#d4e6f1', borderColor: '#85c1e9', cellPadding: 6, zebraColor: '#eaf2f8' },
|
|
134
134
|
syntaxHighlight: {
|
|
135
135
|
background: '#eaf2f8',
|
|
136
136
|
gutter: '#5d6d7e',
|
package/dist/types.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ export interface TableStyles {
|
|
|
34
34
|
headerBackground: string;
|
|
35
35
|
borderColor: string;
|
|
36
36
|
cellPadding: number;
|
|
37
|
+
/** Background color for alternating (even) body rows when zebra striping is enabled.
|
|
38
|
+
* @default '#f9f9f9'
|
|
39
|
+
*/
|
|
40
|
+
zebraColor?: string;
|
|
37
41
|
}
|
|
38
42
|
export interface TokenColors {
|
|
39
43
|
[key: string]: string;
|
|
@@ -107,6 +111,14 @@ export interface PdfOptions {
|
|
|
107
111
|
* @default false
|
|
108
112
|
*/
|
|
109
113
|
lineNumbers?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Enable zebra striping (alternating row backgrounds) on tables.
|
|
116
|
+
*
|
|
117
|
+
* The stripe color is controlled by `theme.table.zebraColor`.
|
|
118
|
+
*
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
121
|
+
zebraStripes?: boolean;
|
|
110
122
|
/**
|
|
111
123
|
* Emoji font configuration.
|
|
112
124
|
*
|