@speajus/markdown-to-pdf 1.0.3 → 1.0.5

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/dist/styles.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPageLayout = exports.defaultTheme = exports.defaultSyntaxHighlightTheme = void 0;
4
+ /** Prism.js default light theme — used as the default (print-friendly). */
5
+ exports.defaultSyntaxHighlightTheme = {
6
+ background: '#f5f2f0',
7
+ gutter: '#708090',
8
+ defaultText: '#000000',
9
+ lineHighlight: '#b3d4fc',
10
+ tokens: {
11
+ comment: '#708090',
12
+ prolog: '#708090',
13
+ doctype: '#708090',
14
+ cdata: '#708090',
15
+ keyword: '#0077aa',
16
+ 'control-flow': '#0077aa',
17
+ builtin: '#669900',
18
+ 'class-name': '#DD4A68',
19
+ function: '#DD4A68',
20
+ 'function-variable': '#DD4A68',
21
+ string: '#669900',
22
+ 'template-string': '#669900',
23
+ 'template-punctuation': '#669900',
24
+ regex: '#ee9900',
25
+ number: '#990055',
26
+ boolean: '#990055',
27
+ null: '#990055',
28
+ undefined: '#990055',
29
+ operator: '#9a6e3a',
30
+ punctuation: '#999999',
31
+ parameter: '#000000',
32
+ property: '#990055',
33
+ 'literal-property': '#990055',
34
+ annotation: '#0077aa',
35
+ 'generic-function': '#DD4A68',
36
+ default: '#000000',
37
+ },
38
+ };
39
+ exports.defaultTheme = {
40
+ headings: {
41
+ h1: { font: 'Helvetica-Bold', fontSize: 28, color: '#1a1a1a', bold: true },
42
+ h2: { font: 'Helvetica-Bold', fontSize: 22, color: '#2a2a2a', bold: true },
43
+ h3: { font: 'Helvetica-Bold', fontSize: 18, color: '#3a3a3a', bold: true },
44
+ h4: { font: 'Helvetica-Bold', fontSize: 16, color: '#4a4a4a', bold: true },
45
+ h5: { font: 'Helvetica-Bold', fontSize: 14, color: '#5a5a5a', bold: true },
46
+ h6: { font: 'Helvetica-Bold', fontSize: 12, color: '#6a6a6a', bold: true },
47
+ },
48
+ body: {
49
+ font: 'Helvetica',
50
+ fontSize: 11,
51
+ color: '#333333',
52
+ lineGap: 4,
53
+ },
54
+ code: {
55
+ inline: {
56
+ font: 'Courier',
57
+ fontSize: 10,
58
+ color: '#c7254e',
59
+ backgroundColor: '#f9f2f4',
60
+ },
61
+ block: {
62
+ font: 'Courier',
63
+ fontSize: 9,
64
+ color: '#333333',
65
+ backgroundColor: '#f5f5f5',
66
+ padding: 8,
67
+ },
68
+ },
69
+ blockquote: {
70
+ borderColor: '#3498db',
71
+ borderWidth: 3,
72
+ italic: true,
73
+ indent: 20,
74
+ },
75
+ linkColor: '#2980b9',
76
+ horizontalRuleColor: '#cccccc',
77
+ table: {
78
+ headerBackground: '#f0f0f0',
79
+ borderColor: '#cccccc',
80
+ cellPadding: 6,
81
+ },
82
+ syntaxHighlight: exports.defaultSyntaxHighlightTheme,
83
+ };
84
+ exports.defaultPageLayout = {
85
+ pageSize: 'LETTER',
86
+ margins: {
87
+ top: 50,
88
+ right: 50,
89
+ bottom: 50,
90
+ left: 50,
91
+ },
92
+ };
@@ -0,0 +1,12 @@
1
+ import type { ThemeConfig } from '../types.js';
2
+ export { defaultTheme } from '../styles.js';
3
+ /** Modern — clean sans-serif with teal accents */
4
+ export declare const modernTheme: ThemeConfig;
5
+ /** Academic — serif fonts, formal look inspired by LaTeX */
6
+ export declare const academicTheme: ThemeConfig;
7
+ /** Minimal — lots of whitespace, muted greys */
8
+ export declare const minimalTheme: ThemeConfig;
9
+ /** Ocean — deep blue palette */
10
+ export declare const oceanTheme: ThemeConfig;
11
+ /** Record of all built-in themes keyed by display name */
12
+ export declare const themes: Record<string, ThemeConfig>;
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.themes = exports.oceanTheme = exports.minimalTheme = exports.academicTheme = exports.modernTheme = exports.defaultTheme = void 0;
4
+ const styles_js_1 = require("../styles.js");
5
+ var styles_js_2 = require("../styles.js");
6
+ Object.defineProperty(exports, "defaultTheme", { enumerable: true, get: function () { return styles_js_2.defaultTheme; } });
7
+ /** Modern — clean sans-serif with teal accents */
8
+ exports.modernTheme = {
9
+ headings: {
10
+ h1: { font: 'Helvetica-Bold', fontSize: 30, color: '#0d7377', bold: true },
11
+ h2: { font: 'Helvetica-Bold', fontSize: 23, color: '#14919b', bold: true },
12
+ h3: { font: 'Helvetica-Bold', fontSize: 18, color: '#0d7377', bold: true },
13
+ h4: { font: 'Helvetica-Bold', fontSize: 15, color: '#14919b', bold: true },
14
+ h5: { font: 'Helvetica-Bold', fontSize: 13, color: '#0d7377', bold: true },
15
+ h6: { font: 'Helvetica-Bold', fontSize: 11, color: '#14919b', bold: true },
16
+ },
17
+ body: { font: 'Helvetica', fontSize: 11, color: '#2d3436', lineGap: 5 },
18
+ code: {
19
+ inline: { font: 'Courier', fontSize: 10, color: '#e17055', backgroundColor: '#ffeaa7' },
20
+ block: { font: 'Courier', fontSize: 9, color: '#2d3436', backgroundColor: '#dfe6e9', padding: 10 },
21
+ },
22
+ blockquote: { borderColor: '#0d7377', borderWidth: 3, italic: true, indent: 20 },
23
+ linkColor: '#0984e3',
24
+ horizontalRuleColor: '#b2bec3',
25
+ table: { headerBackground: '#dfe6e9', borderColor: '#b2bec3', cellPadding: 7 },
26
+ syntaxHighlight: {
27
+ background: '#e8f0f2',
28
+ gutter: '#636e72',
29
+ defaultText: '#2d3436',
30
+ lineHighlight: '#d4e6ec',
31
+ tokens: {
32
+ comment: '#636e72', prolog: '#636e72', doctype: '#636e72', cdata: '#636e72',
33
+ keyword: '#0984e3', 'control-flow': '#6c5ce7', builtin: '#00a388',
34
+ 'class-name': '#e17055', function: '#e17055', 'function-variable': '#e17055',
35
+ string: '#00a388', 'template-string': '#00a388', 'template-punctuation': '#00a388', regex: '#d63031',
36
+ number: '#6c5ce7', boolean: '#0984e3', null: '#0984e3', undefined: '#0984e3',
37
+ operator: '#636e72', punctuation: '#636e72', parameter: '#2d3436', property: '#6c5ce7',
38
+ 'literal-property': '#6c5ce7', annotation: '#0984e3', 'generic-function': '#e17055',
39
+ default: '#2d3436',
40
+ },
41
+ },
42
+ };
43
+ /** Academic — serif fonts, formal look inspired by LaTeX */
44
+ exports.academicTheme = {
45
+ headings: {
46
+ h1: { font: 'Times-Bold', fontSize: 26, color: '#1a1a2e', bold: true },
47
+ h2: { font: 'Times-Bold', fontSize: 21, color: '#16213e', bold: true },
48
+ h3: { font: 'Times-Bold', fontSize: 17, color: '#1a1a2e', bold: true },
49
+ h4: { font: 'Times-Bold', fontSize: 15, color: '#16213e', bold: true },
50
+ h5: { font: 'Times-Bold', fontSize: 13, color: '#1a1a2e', bold: true },
51
+ h6: { font: 'Times-Bold', fontSize: 11, color: '#16213e', bold: true },
52
+ },
53
+ body: { font: 'Times-Roman', fontSize: 12, color: '#1a1a2e', lineGap: 4 },
54
+ code: {
55
+ inline: { font: 'Courier', fontSize: 10, color: '#6c3483', backgroundColor: '#f4ecf7' },
56
+ block: { font: 'Courier', fontSize: 9, color: '#1a1a2e', backgroundColor: '#f2f3f4', padding: 8 },
57
+ },
58
+ blockquote: { borderColor: '#6c3483', borderWidth: 2, italic: true, indent: 24 },
59
+ linkColor: '#2e4057',
60
+ horizontalRuleColor: '#aab7b8',
61
+ table: { headerBackground: '#eaecee', borderColor: '#aab7b8', cellPadding: 6 },
62
+ syntaxHighlight: {
63
+ background: '#f2f3f4',
64
+ gutter: '#7f8c8d',
65
+ defaultText: '#1a1a2e',
66
+ lineHighlight: '#e8e8ec',
67
+ tokens: {
68
+ comment: '#7f8c8d', prolog: '#7f8c8d', doctype: '#7f8c8d', cdata: '#7f8c8d',
69
+ keyword: '#6c3483', 'control-flow': '#8e44ad', builtin: '#27ae60',
70
+ 'class-name': '#c0392b', function: '#c0392b', 'function-variable': '#c0392b',
71
+ string: '#27ae60', 'template-string': '#27ae60', 'template-punctuation': '#27ae60', regex: '#e67e22',
72
+ number: '#8e44ad', boolean: '#6c3483', null: '#6c3483', undefined: '#6c3483',
73
+ operator: '#7f8c8d', punctuation: '#7f8c8d', parameter: '#1a1a2e', property: '#8e44ad',
74
+ 'literal-property': '#8e44ad', annotation: '#6c3483', 'generic-function': '#c0392b',
75
+ default: '#1a1a2e',
76
+ },
77
+ },
78
+ };
79
+ /** Minimal — lots of whitespace, muted greys */
80
+ exports.minimalTheme = {
81
+ headings: {
82
+ h1: { font: 'Helvetica-Bold', fontSize: 26, color: '#000000', bold: true },
83
+ h2: { font: 'Helvetica-Bold', fontSize: 20, color: '#111111', bold: true },
84
+ h3: { font: 'Helvetica-Bold', fontSize: 16, color: '#222222', bold: true },
85
+ h4: { font: 'Helvetica-Bold', fontSize: 14, color: '#333333', bold: true },
86
+ h5: { font: 'Helvetica-Bold', fontSize: 12, color: '#444444', bold: true },
87
+ h6: { font: 'Helvetica-Bold', fontSize: 11, color: '#555555', bold: true },
88
+ },
89
+ body: { font: 'Helvetica', fontSize: 10, color: '#444444', lineGap: 5 },
90
+ code: {
91
+ inline: { font: 'Courier', fontSize: 9, color: '#555555', backgroundColor: '#f7f7f7' },
92
+ block: { font: 'Courier', fontSize: 9, color: '#444444', backgroundColor: '#fafafa', padding: 10 },
93
+ },
94
+ blockquote: { borderColor: '#cccccc', borderWidth: 2, italic: false, indent: 18 },
95
+ linkColor: '#555555',
96
+ horizontalRuleColor: '#e0e0e0',
97
+ table: { headerBackground: '#fafafa', borderColor: '#e0e0e0', cellPadding: 8 },
98
+ syntaxHighlight: {
99
+ background: '#f8f8f8',
100
+ gutter: '#999999',
101
+ defaultText: '#333333',
102
+ lineHighlight: '#f0f0f0',
103
+ tokens: {
104
+ comment: '#999999', prolog: '#999999', doctype: '#999999', cdata: '#999999',
105
+ keyword: '#333333', 'control-flow': '#333333', builtin: '#555555',
106
+ 'class-name': '#555555', function: '#333333', 'function-variable': '#333333',
107
+ string: '#666666', 'template-string': '#666666', 'template-punctuation': '#666666', regex: '#777777',
108
+ number: '#444444', boolean: '#333333', null: '#333333', undefined: '#333333',
109
+ operator: '#333333', punctuation: '#666666', parameter: '#555555', property: '#555555',
110
+ 'literal-property': '#555555', annotation: '#333333', 'generic-function': '#333333',
111
+ default: '#333333',
112
+ },
113
+ },
114
+ };
115
+ /** Ocean — deep blue palette */
116
+ exports.oceanTheme = {
117
+ headings: {
118
+ h1: { font: 'Helvetica-Bold', fontSize: 28, color: '#1b4f72', bold: true },
119
+ h2: { font: 'Helvetica-Bold', fontSize: 22, color: '#1a5276', bold: true },
120
+ h3: { font: 'Helvetica-Bold', fontSize: 18, color: '#21618c', bold: true },
121
+ h4: { font: 'Helvetica-Bold', fontSize: 16, color: '#2874a6', bold: true },
122
+ h5: { font: 'Helvetica-Bold', fontSize: 14, color: '#2e86c1', bold: true },
123
+ h6: { font: 'Helvetica-Bold', fontSize: 12, color: '#3498db', bold: true },
124
+ },
125
+ body: { font: 'Helvetica', fontSize: 11, color: '#2c3e50', lineGap: 4 },
126
+ code: {
127
+ inline: { font: 'Courier', fontSize: 10, color: '#c0392b', backgroundColor: '#eaf2f8' },
128
+ block: { font: 'Courier', fontSize: 9, color: '#2c3e50', backgroundColor: '#eaf2f8', padding: 8 },
129
+ },
130
+ blockquote: { borderColor: '#2980b9', borderWidth: 3, italic: true, indent: 20 },
131
+ linkColor: '#2471a3',
132
+ horizontalRuleColor: '#aed6f1',
133
+ table: { headerBackground: '#d4e6f1', borderColor: '#85c1e9', cellPadding: 6 },
134
+ syntaxHighlight: {
135
+ background: '#eaf2f8',
136
+ gutter: '#5d6d7e',
137
+ defaultText: '#1b2631',
138
+ lineHighlight: '#d4e6f1',
139
+ tokens: {
140
+ comment: '#5d6d7e', prolog: '#5d6d7e', doctype: '#5d6d7e', cdata: '#5d6d7e',
141
+ keyword: '#2471a3', 'control-flow': '#7d3c98', builtin: '#1e8449',
142
+ 'class-name': '#c0392b', function: '#c0392b', 'function-variable': '#c0392b',
143
+ string: '#1e8449', 'template-string': '#1e8449', 'template-punctuation': '#1e8449', regex: '#d35400',
144
+ number: '#7d3c98', boolean: '#2471a3', null: '#2471a3', undefined: '#2471a3',
145
+ operator: '#5d6d7e', punctuation: '#5d6d7e', parameter: '#1b2631', property: '#7d3c98',
146
+ 'literal-property': '#7d3c98', annotation: '#2471a3', 'generic-function': '#c0392b',
147
+ default: '#1b2631',
148
+ },
149
+ },
150
+ };
151
+ /** Record of all built-in themes keyed by display name */
152
+ exports.themes = {
153
+ Default: styles_js_1.defaultTheme,
154
+ Modern: exports.modernTheme,
155
+ Academic: exports.academicTheme,
156
+ Minimal: exports.minimalTheme,
157
+ Ocean: exports.oceanTheme,
158
+ };
@@ -0,0 +1,128 @@
1
+ export interface TextStyle {
2
+ font: string;
3
+ fontSize: number;
4
+ color: string;
5
+ lineGap?: number;
6
+ bold?: boolean;
7
+ italic?: boolean;
8
+ }
9
+ export interface PageLayout {
10
+ pageSize: string;
11
+ margins: {
12
+ top: number;
13
+ right: number;
14
+ bottom: number;
15
+ left: number;
16
+ };
17
+ }
18
+ export interface CodeStyle {
19
+ font: string;
20
+ fontSize: number;
21
+ color: string;
22
+ backgroundColor: string;
23
+ }
24
+ export interface CodeBlockStyle extends CodeStyle {
25
+ padding: number;
26
+ }
27
+ export interface BlockquoteStyle {
28
+ borderColor: string;
29
+ borderWidth: number;
30
+ italic: boolean;
31
+ indent: number;
32
+ }
33
+ export interface TableStyles {
34
+ headerBackground: string;
35
+ borderColor: string;
36
+ cellPadding: number;
37
+ }
38
+ export interface TokenColors {
39
+ [key: string]: string;
40
+ }
41
+ export interface SyntaxHighlightTheme {
42
+ background: string;
43
+ gutter: string;
44
+ defaultText: string;
45
+ lineHighlight: string;
46
+ tokens: TokenColors;
47
+ }
48
+ export interface ThemeConfig {
49
+ headings: {
50
+ h1: TextStyle;
51
+ h2: TextStyle;
52
+ h3: TextStyle;
53
+ h4: TextStyle;
54
+ h5: TextStyle;
55
+ h6: TextStyle;
56
+ };
57
+ body: TextStyle;
58
+ code: {
59
+ inline: CodeStyle;
60
+ block: CodeBlockStyle;
61
+ };
62
+ blockquote: BlockquoteStyle;
63
+ linkColor: string;
64
+ horizontalRuleColor: string;
65
+ table: TableStyles;
66
+ /**
67
+ * Syntax highlighting colors for fenced code blocks.
68
+ * When omitted, falls back to a VS Code Dark+ inspired palette.
69
+ */
70
+ syntaxHighlight?: SyntaxHighlightTheme;
71
+ }
72
+ /** Converts a single emoji string to a PNG `Buffer`. */
73
+ export type ColorEmojiRenderer = (emoji: string) => Promise<Buffer>;
74
+ export interface PdfOptions {
75
+ theme?: ThemeConfig;
76
+ pageLayout?: PageLayout;
77
+ /** Base directory for resolving relative image paths */
78
+ basePath?: string;
79
+ /**
80
+ * Custom image renderer function.
81
+ * Takes an image URL/path and returns a Buffer containing the image data (PNG/JPEG).
82
+ * If not provided, a default Node.js implementation will be used.
83
+ */
84
+ renderImage?: (imageUrl: string) => Promise<Buffer>;
85
+ /**
86
+ * Enable syntax highlighting for fenced code blocks with a language tag.
87
+ * Uses Prism.js for tokenization.
88
+ * @default true
89
+ */
90
+ syntaxHighlight?: boolean;
91
+ /**
92
+ * Which Prism.js language grammars to load for syntax highlighting.
93
+ *
94
+ * - `undefined` (default) — load **all** available Prism.js languages (~300).
95
+ * - An array of language identifiers (e.g. `['javascript', 'python', 'bash']`)
96
+ * to load only the specified grammars (and their dependencies).
97
+ *
98
+ * Has no effect when `syntaxHighlight` is `false`.
99
+ */
100
+ languages?: string[];
101
+ /**
102
+ * Emoji font configuration.
103
+ *
104
+ * - `true` (default) — use the bundled Noto Emoji font (Node.js only;
105
+ * silently skipped in browser environments).
106
+ * - `false` — disable emoji font switching; emoji will render with the
107
+ * current body font (which usually means missing glyphs).
108
+ * - A `string` path to a custom `.ttf` / `.otf` emoji font file (Node.js).
109
+ * - A `Buffer` containing raw font data (works in both Node.js and browser).
110
+ *
111
+ * @default true
112
+ */
113
+ emojiFont?: boolean | string | Buffer;
114
+ /**
115
+ * Color emoji renderer.
116
+ *
117
+ * When provided, emoji characters are rendered as inline color PNG images
118
+ * (sourced from Twemoji SVGs) instead of monochrome font glyphs.
119
+ *
120
+ * Use `createNodeColorEmojiRenderer()` (Node.js) or
121
+ * `createBrowserColorEmojiRenderer()` (browser) to obtain a renderer.
122
+ *
123
+ * Takes priority over `emojiFont` for emoji that are successfully rendered.
124
+ * Emoji that fail to render (e.g. missing from Twemoji) fall back to the
125
+ * monochrome font or the body font.
126
+ */
127
+ colorEmoji?: ColorEmojiRenderer;
128
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,24 +1,27 @@
1
1
  {
2
2
  "name": "@speajus/markdown-to-pdf",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A new project created with Intent by Augment.",
5
- "main": "dist/src/index.js",
6
- "types": "dist/src/index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "markdown-to-pdf": "dist/cli.js"
9
+ },
7
10
  "exports": {
8
11
  "node": {
9
- "require": "./dist/src/index.js",
10
- "import": "./dist/src/index.js"
12
+ "require": "./dist/index.js",
13
+ "import": "./dist/index.js"
11
14
  },
12
15
  "browser": {
13
- "require": "./dist/src/browser.js",
14
- "import": "./dist/src/browser.js"
16
+ "require": "./dist/browser.js",
17
+ "import": "./dist/browser.js"
15
18
  }
16
19
  },
17
20
  "files": [
18
- "dist/src"
21
+ "dist"
19
22
  ],
20
23
  "scripts": {
21
- "build": "tsc && mkdir -p dist/src/fonts && cp src/fonts/* dist/src/fonts/",
24
+ "build": "tsc && mkdir -p dist/fonts && cp src/fonts/* dist/fonts/",
22
25
  "generate": "tsx samples/generate.ts",
23
26
  "test": "tsx samples/generate.ts"
24
27
  },
File without changes
File without changes
File without changes
File without changes