md-preview-pdf 1.0.4

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.
Files changed (90) hide show
  1. package/.editorconfig +37 -0
  2. package/CHANGELOG.md +405 -0
  3. package/CODE_OF_CONDUCT.md +128 -0
  4. package/CONTRIBUTING.md +170 -0
  5. package/LICENSE +21 -0
  6. package/README.md +391 -0
  7. package/SECURITY.md +100 -0
  8. package/dist/cli.d.ts +7 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +275 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/converter.d.ts +58 -0
  13. package/dist/converter.d.ts.map +1 -0
  14. package/dist/converter.js +301 -0
  15. package/dist/converter.js.map +1 -0
  16. package/dist/index.d.ts +13 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +53 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/parser/index.d.ts +40 -0
  21. package/dist/parser/index.d.ts.map +1 -0
  22. package/dist/parser/index.js +100 -0
  23. package/dist/parser/index.js.map +1 -0
  24. package/dist/parser/markdown-parser.d.ts +12 -0
  25. package/dist/parser/markdown-parser.d.ts.map +1 -0
  26. package/dist/parser/markdown-parser.js +260 -0
  27. package/dist/parser/markdown-parser.js.map +1 -0
  28. package/dist/renderers/html-renderer.d.ts +19 -0
  29. package/dist/renderers/html-renderer.d.ts.map +1 -0
  30. package/dist/renderers/html-renderer.js +451 -0
  31. package/dist/renderers/html-renderer.js.map +1 -0
  32. package/dist/renderers/index.d.ts +8 -0
  33. package/dist/renderers/index.d.ts.map +1 -0
  34. package/dist/renderers/index.js +21 -0
  35. package/dist/renderers/index.js.map +1 -0
  36. package/dist/renderers/mermaid-renderer.d.ts +31 -0
  37. package/dist/renderers/mermaid-renderer.d.ts.map +1 -0
  38. package/dist/renderers/mermaid-renderer.js +221 -0
  39. package/dist/renderers/mermaid-renderer.js.map +1 -0
  40. package/dist/renderers/pdf-renderer.d.ts +40 -0
  41. package/dist/renderers/pdf-renderer.d.ts.map +1 -0
  42. package/dist/renderers/pdf-renderer.js +253 -0
  43. package/dist/renderers/pdf-renderer.js.map +1 -0
  44. package/dist/themes/github-dark.d.ts +7 -0
  45. package/dist/themes/github-dark.d.ts.map +1 -0
  46. package/dist/themes/github-dark.js +400 -0
  47. package/dist/themes/github-dark.js.map +1 -0
  48. package/dist/themes/github.d.ts +7 -0
  49. package/dist/themes/github.d.ts.map +1 -0
  50. package/dist/themes/github.js +362 -0
  51. package/dist/themes/github.js.map +1 -0
  52. package/dist/themes/highlight.d.ts +21 -0
  53. package/dist/themes/highlight.d.ts.map +1 -0
  54. package/dist/themes/highlight.js +384 -0
  55. package/dist/themes/highlight.js.map +1 -0
  56. package/dist/themes/index.d.ts +41 -0
  57. package/dist/themes/index.d.ts.map +1 -0
  58. package/dist/themes/index.js +83 -0
  59. package/dist/themes/index.js.map +1 -0
  60. package/dist/themes/vscode-dark.d.ts +7 -0
  61. package/dist/themes/vscode-dark.d.ts.map +1 -0
  62. package/dist/themes/vscode-dark.js +312 -0
  63. package/dist/themes/vscode-dark.js.map +1 -0
  64. package/dist/themes/vscode-light.d.ts +7 -0
  65. package/dist/themes/vscode-light.d.ts.map +1 -0
  66. package/dist/themes/vscode-light.js +259 -0
  67. package/dist/themes/vscode-light.js.map +1 -0
  68. package/dist/types/index.d.ts +170 -0
  69. package/dist/types/index.d.ts.map +1 -0
  70. package/dist/types/index.js +34 -0
  71. package/dist/types/index.js.map +1 -0
  72. package/dist/utils/error-handler.d.ts +39 -0
  73. package/dist/utils/error-handler.d.ts.map +1 -0
  74. package/dist/utils/error-handler.js +136 -0
  75. package/dist/utils/error-handler.js.map +1 -0
  76. package/dist/utils/file-utils.d.ts +78 -0
  77. package/dist/utils/file-utils.d.ts.map +1 -0
  78. package/dist/utils/file-utils.js +234 -0
  79. package/dist/utils/file-utils.js.map +1 -0
  80. package/dist/utils/index.d.ts +4 -0
  81. package/dist/utils/index.d.ts.map +1 -0
  82. package/dist/utils/index.js +30 -0
  83. package/dist/utils/index.js.map +1 -0
  84. package/dist/utils/logger.d.ts +10 -0
  85. package/dist/utils/logger.d.ts.map +1 -0
  86. package/dist/utils/logger.js +61 -0
  87. package/dist/utils/logger.js.map +1 -0
  88. package/eslint.config.js +70 -0
  89. package/index.d.ts +43 -0
  90. package/package.json +81 -0
@@ -0,0 +1,170 @@
1
+ # Contributing to MD Preview PDF
2
+
3
+ First off, thank you for considering contributing to MD Preview PDF! It's people like you that make this tool better for everyone.
4
+
5
+ ## Code of Conduct
6
+
7
+ This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
8
+
9
+ ## How Can I Contribute?
10
+
11
+ ### Reporting Bugs
12
+
13
+ Before creating bug reports, please check the existing issues to avoid duplicates. When you create a bug report, include as many details as possible:
14
+
15
+ - **Use a clear and descriptive title**
16
+ - **Describe the exact steps to reproduce the problem**
17
+ - **Provide specific examples** (markdown files, configurations)
18
+ - **Describe the behavior you observed and what you expected**
19
+ - **Include your environment details** (OS, Node.js version, package version)
20
+ - **Add screenshots** if applicable
21
+
22
+ ### Suggesting Enhancements
23
+
24
+ Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion:
25
+
26
+ - **Use a clear and descriptive title**
27
+ - **Provide a detailed description of the suggested enhancement**
28
+ - **Explain why this enhancement would be useful**
29
+ - **List any similar features in other tools** if applicable
30
+
31
+ ### Pull Requests
32
+
33
+ 1. **Fork the repository** and create your branch from `main`
34
+ 2. **Follow the coding style** of the project (ESLint configuration provided)
35
+ 3. **Write clear commit messages** following conventional commits format:
36
+ - `feat:` for new features
37
+ - `fix:` for bug fixes
38
+ - `docs:` for documentation changes
39
+ - `test:` for test additions/changes
40
+ - `refactor:` for code refactoring
41
+ - `chore:` for maintenance tasks
42
+ 4. **Update documentation** if you're changing functionality
43
+ 5. **Add tests** if you're adding features
44
+ 6. **Ensure all tests pass** by running `npm test`
45
+ 7. **Update CHANGELOG.md** with your changes
46
+
47
+ ## Development Setup
48
+
49
+ ```bash
50
+ # Clone your fork
51
+ git clone https://github.com/your-username/md-preview-pdf.git
52
+ cd md-preview-pdf
53
+
54
+ # Install dependencies
55
+ npm install
56
+
57
+ # Build the project
58
+ npm run build
59
+
60
+ # Run tests
61
+ npm test
62
+
63
+ # Run linting
64
+ npm run lint
65
+ ```
66
+
67
+ ## Development Workflow
68
+
69
+ 1. Create a new branch:
70
+ ```bash
71
+ git checkout -b feature/your-feature-name
72
+ ```
73
+
74
+ 2. Make your changes and test them:
75
+ ```bash
76
+ npm run build
77
+ npm test
78
+ npm run dev -- tests/samples/comprehensive-test.md
79
+ ```
80
+
81
+ 3. Commit your changes:
82
+ ```bash
83
+ git add .
84
+ git commit -m "feat: add amazing feature"
85
+ ```
86
+
87
+ 4. Push to your fork:
88
+ ```bash
89
+ git push origin feature/your-feature-name
90
+ ```
91
+
92
+ 5. Create a Pull Request on GitHub
93
+
94
+ ## Coding Guidelines
95
+
96
+ ### TypeScript Style
97
+
98
+ - Use **TypeScript** for all new code
99
+ - Follow the existing **ESLint** configuration
100
+ - Use **explicit types** for function parameters and return values
101
+ - Prefer **interfaces** over type aliases for object shapes
102
+ - Use **const** for variables that don't change
103
+ - Use **async/await** over promises chains
104
+
105
+ ### Code Organization
106
+
107
+ - Keep functions **small and focused** (single responsibility)
108
+ - **Extract reusable logic** into utility functions
109
+ - Add **JSDoc comments** for public APIs
110
+ - Use **descriptive variable names**
111
+ - Organize imports: Node.js built-ins → third-party → local
112
+
113
+ ### Testing
114
+
115
+ - Write **unit tests** for utility functions
116
+ - Write **integration tests** for the converter
117
+ - Test with **various markdown features**
118
+ - Test **error cases** and edge conditions
119
+ - Aim for **>80% code coverage**
120
+
121
+ ### Documentation
122
+
123
+ - Update **README.md** for user-facing changes
124
+ - Update **ARCHITECTURE.md** for architectural changes
125
+ - Add **JSDoc comments** for public APIs
126
+ - Include **examples** in documentation
127
+ - Keep documentation **clear and concise**
128
+
129
+ ## Project Structure
130
+
131
+ ```
132
+ md-preview-pdf/
133
+ ├── src/
134
+ │ ├── index.ts # Main entry point and exports
135
+ │ ├── cli.ts # Command-line interface
136
+ │ ├── converter.ts # Main converter class
137
+ │ ├── parser/ # Markdown parsing logic
138
+ │ ├── renderers/ # HTML, PDF, and Mermaid rendering
139
+ │ ├── themes/ # CSS themes
140
+ │ ├── utils/ # Utility functions
141
+ │ └── types/ # TypeScript type definitions
142
+ ├── tests/
143
+ │ ├── samples/ # Test markdown files
144
+ │ └── *.test.ts # Test files
145
+ ├── .github/
146
+ │ └── workflows/ # CI/CD workflows
147
+ └── docs/ # Additional documentation
148
+ ```
149
+
150
+ ## Testing Checklist
151
+
152
+ Before submitting a PR, ensure:
153
+
154
+ - [ ] All tests pass (`npm test`)
155
+ - [ ] Linting passes (`npm run lint`)
156
+ - [ ] Code builds successfully (`npm run build`)
157
+ - [ ] Documentation is updated
158
+ - [ ] CHANGELOG.md is updated
159
+ - [ ] No console.log() statements left in code
160
+ - [ ] New features have tests
161
+ - [ ] All commits follow conventional commits format
162
+
163
+ ## Questions?
164
+
165
+ Feel free to:
166
+ - Open an issue for discussion
167
+ - Join our community discussions
168
+ - Reach out to the maintainers
169
+
170
+ Thank you for contributing! 🎉
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,391 @@
1
+ # MD Preview PDF 📄
2
+
3
+ A state-of-the-art Markdown to PDF converter that preserves the exact visual appearance of markdown previews, including full support for Mermaid diagrams, syntax highlighting, math equations, and GitHub Flavored Markdown.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-blue)](https://www.typescriptlang.org/)
8
+ [![ESLint](https://img.shields.io/badge/ESLint-9.0-brightgreen)](https://eslint.org/)
9
+ ![Tests](https://img.shields.io/badge/Tests-26%20passing-brightgreen)
10
+
11
+ ## ✨ Features
12
+
13
+ - **Full Markdown Support**: Complete GFM (GitHub Flavored Markdown) support
14
+ - **Mermaid Diagrams**: Flowcharts, sequence diagrams, class diagrams, and more
15
+ - **Syntax Highlighting**: 150+ programming languages with beautiful themes
16
+ - **Math Equations**: LaTeX math rendering via KaTeX
17
+ - **Multiple Themes**: GitHub (light/dark), VS Code (light/dark)
18
+ - **Table of Contents**: Auto-generated TOC with customizable depth
19
+ - **Task Lists**: Checkbox support for TODO lists
20
+ - **Footnotes**: Full footnote support
21
+ - **Custom Containers**: Tips, warnings, info boxes, and more
22
+ - **Emoji Support**: Convert `:emoji:` shortcodes to unicode
23
+ - **High-Fidelity Output**: Uses Puppeteer for pixel-perfect PDF generation
24
+
25
+ ## 📦 Installation
26
+
27
+ ### From Source (Development)
28
+
29
+ ```bash
30
+ # Clone the repository
31
+ git clone https://github.com/anuragkr29/md-preview-pdf.git
32
+ cd md-preview-pdf
33
+
34
+ # Install dependencies
35
+ npm install
36
+
37
+ # Build the project
38
+ npm run build
39
+
40
+ # Link for global CLI usage (optional)
41
+ npm link
42
+ ```
43
+
44
+ ### From NPM (Coming Soon)
45
+
46
+ ```bash
47
+ # Global installation
48
+ npm install -g md-preview-pdf
49
+
50
+ # Local installation
51
+ npm install md-preview-pdf
52
+ ```
53
+
54
+ ## 🚀 Quick Start
55
+
56
+ ### Command Line
57
+
58
+ ```bash
59
+ # Basic conversion
60
+ md-preview-pdf document.md
61
+
62
+ # Specify output file
63
+ md-preview-pdf document.md output.pdf
64
+
65
+ # Use dark theme
66
+ md-preview-pdf document.md --theme github-dark
67
+
68
+ # Add page numbers
69
+ md-preview-pdf document.md --page-numbers
70
+
71
+ # Generate table of contents
72
+ md-preview-pdf document.md --toc
73
+ ```
74
+
75
+ ### Programmatic Usage
76
+
77
+ ```typescript
78
+ import { Converter, convert } from 'md-preview-pdf';
79
+
80
+ // Quick convert
81
+ const result = await convert('document.md', 'output.pdf', {
82
+ theme: { name: 'github' },
83
+ pdf: { format: 'A4' },
84
+ });
85
+
86
+ // Using the Converter class
87
+ const converter = new Converter({
88
+ theme: { name: 'github-dark' },
89
+ toc: true,
90
+ math: true,
91
+ });
92
+
93
+ const result = await converter.convertFile('input.md', 'output.pdf');
94
+ console.log(`PDF generated: ${result.outputPath}`);
95
+
96
+ // Don't forget to cleanup
97
+ await converter.cleanup();
98
+ ```
99
+
100
+ ## 📋 CLI Options
101
+
102
+ | Option | Description | Default |
103
+ |--------|-------------|---------|
104
+ | `-t, --theme <theme>` | Theme (github, github-dark, vscode-light, vscode-dark) | `github` |
105
+ | `-f, --format <format>` | Page format (A4, A3, A5, Letter, Legal, Tabloid) | `A4` |
106
+ | `--landscape` | Use landscape orientation | `false` |
107
+ | `--no-background` | Disable background printing | `true` |
108
+ | `-m, --margin <margin>` | Page margins (e.g., "20mm" or "10mm,15mm,20mm,15mm") | `20mm` |
109
+ | `--toc` | Generate table of contents | `false` |
110
+ | `--toc-depth <depth>` | TOC heading depth (1-6) | `3` |
111
+ | `--html` | Also output HTML file | `false` |
112
+ | `--no-math` | Disable KaTeX math rendering | `true` |
113
+ | `--no-emoji` | Disable emoji conversion | `true` |
114
+ | `--no-highlight` | Disable syntax highlighting | `true` |
115
+ | `--mermaid-theme <theme>` | Mermaid theme (default, forest, dark, neutral) | `default` |
116
+ | `--header <template>` | Custom header HTML template | - |
117
+ | `--footer <template>` | Custom footer HTML template | - |
118
+ | `--page-numbers` | Add page numbers to footer | `false` |
119
+ | `--css <path>` | Custom CSS file path | - |
120
+ | `--debug` | Run in debug mode (show browser) | `false` |
121
+ | `-v, --verbose` | Verbose output | `false` |
122
+ | `-q, --quiet` | Quiet mode | `false` |
123
+
124
+ ## 🎨 Themes
125
+
126
+ List available themes:
127
+
128
+ ```bash
129
+ md-preview-pdf themes
130
+ ```
131
+
132
+ ### Available Themes
133
+
134
+ - **github**: GitHub light theme (default)
135
+ - **github-dark**: GitHub dark theme
136
+ - **vscode-light**: VS Code light theme
137
+ - **vscode-dark**: VS Code dark theme
138
+
139
+ ### Customizing Theme Styling
140
+
141
+ Each theme is defined as a CSS string in the `src/themes/` directory. To customize a theme:
142
+
143
+ 1. **GitHub Light Theme** (`src/themes/github.ts`)
144
+ - Background color: `#ffffff` (white)
145
+ - Text color: `#24292f` (dark gray)
146
+ - Edit the `.markdown-body` styling and color variables
147
+
148
+ 2. **GitHub Dark Theme** (`src/themes/github-dark.ts`)
149
+ - Background color: `#0d1117` (very dark gray)
150
+ - Text color: `#c9d1d9` (light gray)
151
+ - Edit the `.markdown-body` styling and color variables
152
+
153
+ 3. **VS Code Light Theme** (`src/themes/vscode-light.ts`)
154
+ - Background color: `#ffffff` (white)
155
+ - Text color: `#333333` (dark gray)
156
+ - Edit the `.markdown-body` styling to match VS Code light theme
157
+
158
+ 4. **VS Code Dark Theme** (`src/themes/vscode-dark.ts`)
159
+ - Background color: `#1e1e1e` (VS Code dark)
160
+ - Text color: `#d4d4d4` (light gray)
161
+ - Edit the `.markdown-body` styling to match VS Code dark theme
162
+
163
+ To test your theme changes:
164
+ ```bash
165
+ npm run build
166
+ md-preview-pdf tests/samples/simple-test.md output.pdf --theme github-dark
167
+ ```
168
+
169
+ ### Sample Output
170
+
171
+ The following PDFs demonstrate the output quality across all themes:
172
+
173
+ | Theme | Simple Test | File Size |
174
+ |-------|-------------|-----------|
175
+ | [GitHub Light](tests/output/examples/simple-github.pdf) | [View](tests/output/examples/simple-github.pdf) | 130 KB |
176
+ | [GitHub Dark](tests/output/examples/simple-github-dark.pdf) | [View](tests/output/examples/simple-github-dark.pdf) | 130 KB |
177
+ | [VS Code Light](tests/output/examples/simple-vscode-light.pdf) | [View](tests/output/examples/simple-vscode-light.pdf) | 134 KB |
178
+ | [VS Code Dark](tests/output/examples/simple-vscode-dark.pdf) | [View](tests/output/examples/simple-vscode-dark.pdf) | 134 KB |
179
+
180
+ ## 📊 Supported Mermaid Diagrams
181
+
182
+
183
+ ```mermaid
184
+ flowchart TD
185
+ A[Start] --> B{Decision}
186
+ B -->|Yes| C[OK]
187
+ B -->|No| D[End]
188
+ ```
189
+
190
+
191
+ Supported diagram types:
192
+ - Flowcharts
193
+ - Sequence diagrams
194
+ - Class diagrams
195
+ - State diagrams
196
+ - Entity Relationship diagrams
197
+ - Gantt charts
198
+ - Pie charts
199
+ - Git graphs
200
+ - User Journey diagrams
201
+
202
+ ## ➗ Math Equations
203
+
204
+ Inline math with single dollar signs:
205
+
206
+ ```markdown
207
+ The formula $E = mc^2$ is famous.
208
+ ```
209
+
210
+ Block math with double dollar signs:
211
+
212
+ ```markdown
213
+ $$
214
+ \int_{a}^{b} f(x) \, dx = F(b) - F(a)
215
+ $$
216
+ ```
217
+
218
+ ## 📝 Front Matter
219
+
220
+ Use YAML front matter to configure document-specific options:
221
+
222
+ ```yaml
223
+ ---
224
+ title: "My Document"
225
+ author: "John Doe"
226
+ date: "2024-01-01"
227
+ pdf:
228
+ format: Letter
229
+ margin:
230
+ top: "25mm"
231
+ bottom: "25mm"
232
+ theme: github-dark
233
+ ---
234
+ ```
235
+
236
+ ## 📁 Custom Containers
237
+
238
+ ```markdown
239
+ ::: tip Pro Tip
240
+ This is a helpful tip!
241
+ :::
242
+
243
+ ::: warning Warning
244
+ Be careful about this!
245
+ :::
246
+
247
+ ::: danger Danger
248
+ This is critical!
249
+ :::
250
+
251
+ ::: info Information
252
+ Here's some additional info.
253
+ :::
254
+
255
+ ::: details Click to expand
256
+ Hidden content here...
257
+ :::
258
+ ```
259
+
260
+ ## 🛠️ Development
261
+
262
+ ```bash
263
+ # Install dependencies
264
+ npm install
265
+
266
+ # Build
267
+ npm run build
268
+
269
+ # Run tests
270
+ npm test
271
+
272
+ # Run in development mode
273
+ npm run dev -- input.md
274
+
275
+ # Lint code
276
+ npm run lint
277
+ ```
278
+
279
+ ## 📂 Project Structure
280
+
281
+ ```
282
+ md-preview-pdf/
283
+ ├── src/
284
+ │ ├── index.ts # Main entry point
285
+ │ ├── cli.ts # CLI interface
286
+ │ ├── converter.ts # Main converter class
287
+ │ ├── parser/ # Markdown parsing
288
+ │ ├── renderers/ # HTML/PDF/Mermaid rendering
289
+ │ ├── themes/ # CSS themes
290
+ │ ├── utils/ # Utilities
291
+ │ └── types/ # TypeScript types
292
+ ├── tests/
293
+ │ ├── samples/ # Test markdown files
294
+ │ └── *.test.ts # Test files
295
+ ├── package.json
296
+ ├── tsconfig.json
297
+ └── README.md
298
+ ```
299
+
300
+ ## 🔧 API Reference
301
+
302
+ ### Converter Class
303
+
304
+ ```typescript
305
+ class Converter {
306
+ constructor(options?: ConverterOptions);
307
+
308
+ // Convert markdown file to PDF
309
+ convertFile(input: string, output?: string): Promise<ConversionResult>;
310
+
311
+ // Convert markdown string to PDF buffer
312
+ convertString(markdown: string, basePath?: string): Promise<Buffer>;
313
+
314
+ // Convert multiple files
315
+ convertFiles(inputs: string[], outputDir?: string): Promise<ConversionResult[]>;
316
+
317
+ // Generate HTML from markdown
318
+ generateHtml(markdown: string, basePath?: string): Promise<string>;
319
+
320
+ // Parse markdown without rendering
321
+ parseMarkdown(markdown: string): ParsedMarkdown;
322
+
323
+ // Update options
324
+ setOptions(options: Partial<ConverterOptions>): void;
325
+
326
+ // Get current options
327
+ getOptions(): ConverterOptions;
328
+
329
+ // Clean up resources
330
+ cleanup(): Promise<void>;
331
+ }
332
+ ```
333
+
334
+ ### ConverterOptions
335
+
336
+ ```typescript
337
+ interface ConverterOptions {
338
+ pdf?: PDFOptions; // PDF generation options
339
+ theme?: ThemeOptions; // Theme configuration
340
+ mermaid?: MermaidOptions; // Mermaid diagram options
341
+ toc?: boolean; // Enable table of contents
342
+ tocDepth?: number; // TOC depth (1-6)
343
+ outputHtml?: boolean; // Also output HTML
344
+ math?: boolean; // Enable KaTeX math
345
+ emoji?: boolean; // Enable emoji conversion
346
+ highlight?: boolean; // Enable syntax highlighting
347
+ basePath?: string; // Base path for relative resources
348
+ debug?: boolean; // Debug mode
349
+ }
350
+ ```
351
+
352
+ ## 🧪 Testing
353
+
354
+ ```bash
355
+ # Run all tests
356
+ npm test
357
+
358
+ # Run tests with coverage
359
+ npm test -- --coverage
360
+
361
+ # Run tests in watch mode
362
+ npm test -- --watch
363
+ ```
364
+
365
+ ## 📄 License
366
+
367
+ MIT License - see [LICENSE](LICENSE) for details.
368
+
369
+ ## 🤝 Contributing
370
+
371
+ Contributions are welcome! Please feel free to submit a Pull Request.
372
+
373
+ 1. Fork the repository
374
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
375
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
376
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
377
+ 5. Open a Pull Request
378
+
379
+ ## 🙏 Acknowledgments
380
+
381
+ - [markdown-it](https://github.com/markdown-it/markdown-it) - Markdown parser
382
+ - [Puppeteer](https://pptr.dev/) - Headless Chrome for PDF generation
383
+ - [Mermaid](https://mermaid.js.org/) - Diagram rendering
384
+ - [KaTeX](https://katex.org/) - Math rendering
385
+ - [highlight.js](https://highlightjs.org/) - Syntax highlighting
386
+
387
+ ---
388
+
389
+ **Created by [Anurag Kumar](https://github.com/anuragkr29)**
390
+
391
+ **Repository**: [md-preview-pdf](https://github.com/anuragkr29/md-preview-pdf)
package/SECURITY.md ADDED
@@ -0,0 +1,100 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ We release patches for security vulnerabilities. Which versions are eligible for receiving such patches depends on the CVSS v3.0 Rating:
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 1.0.x | :white_check_mark: |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ We take the security of MD Preview PDF seriously. If you believe you have found a security vulnerability, please report it to us as described below.
14
+
15
+ ### Where to Report
16
+
17
+ **Please do not report security vulnerabilities through public GitHub issues.**
18
+
19
+ Instead, please report them via email to:
20
+ - **Email**: anuragkr29@outlook.com
21
+ - **Subject**: [SECURITY] MD Preview PDF - Brief Description
22
+
23
+ ### What to Include
24
+
25
+ Please include the following information in your report:
26
+
27
+ - Type of issue (e.g., buffer overflow, SQL injection, cross-site scripting, etc.)
28
+ - Full paths of source file(s) related to the manifestation of the issue
29
+ - The location of the affected source code (tag/branch/commit or direct URL)
30
+ - Any special configuration required to reproduce the issue
31
+ - Step-by-step instructions to reproduce the issue
32
+ - Proof-of-concept or exploit code (if possible)
33
+ - Impact of the issue, including how an attacker might exploit it
34
+
35
+ ### What to Expect
36
+
37
+ After you submit a report, you can expect:
38
+
39
+ - **Acknowledgment**: We'll acknowledge receipt of your vulnerability report within 48 hours
40
+ - **Initial Assessment**: We'll provide an initial assessment within 5 business days
41
+ - **Updates**: We'll keep you informed of our progress
42
+ - **Fix & Disclosure**: Once the issue is fixed, we'll work with you on disclosure timing
43
+
44
+ ### Preferred Languages
45
+
46
+ We prefer all communications to be in English.
47
+
48
+ ## Security Best Practices
49
+
50
+ When using MD Preview PDF:
51
+
52
+ 1. **Input Validation**: Always validate and sanitize markdown input, especially when processing user-generated content
53
+ 2. **File Paths**: Use absolute paths and validate file locations to prevent directory traversal attacks
54
+ 3. **Resource Limits**: Set appropriate timeouts and resource limits when processing large documents
55
+ 4. **Updates**: Keep the package and its dependencies up to date
56
+ 5. **Sandbox**: Consider running the converter in a sandboxed environment if processing untrusted input
57
+
58
+ ## Known Security Considerations
59
+
60
+ ### Puppeteer and Chromium
61
+
62
+ This package uses Puppeteer, which downloads and runs a full Chromium browser. Key security considerations:
63
+
64
+ - Chromium is regularly updated for security patches
65
+ - The browser runs in headless mode with limited privileges
66
+ - Network access is controlled but not completely disabled
67
+ - Consider running in a containerized environment for untrusted input
68
+
69
+ ### Markdown Processing
70
+
71
+ - HTML tags in markdown are processed by default
72
+ - Consider using sanitization libraries for user-generated content
73
+ - Be cautious with custom CSS that may contain malicious code
74
+ - Validate external resources (images, links) before processing
75
+
76
+ ### File System Access
77
+
78
+ - The tool requires read access to input files
79
+ - It requires write access to output directories
80
+ - Ensure proper file permissions in your environment
81
+ - Validate all file paths to prevent unauthorized access
82
+
83
+ ## Disclosure Policy
84
+
85
+ - We follow responsible disclosure practices
86
+ - We aim to patch confirmed vulnerabilities within 30 days
87
+ - We'll publicly acknowledge security researchers who report valid issues (unless they prefer to remain anonymous)
88
+ - We'll coordinate disclosure timing with the reporter
89
+
90
+ ## Comments on this Policy
91
+
92
+ If you have suggestions on how this process could be improved, please submit a pull request or open an issue.
93
+
94
+ ## Updates
95
+
96
+ This security policy may be updated periodically. Significant changes will be announced in release notes.
97
+
98
+ ---
99
+
100
+ Last Updated: January 3, 2026
package/dist/cli.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MD Preview PDF CLI
4
+ * Command-line interface for converting Markdown to PDF
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG"}