convpdf 0.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/dist/bin/convpdf.d.ts +3 -0
  4. package/dist/bin/convpdf.d.ts.map +1 -0
  5. package/dist/bin/convpdf.js +297 -0
  6. package/dist/bin/convpdf.js.map +1 -0
  7. package/dist/src/html/template.d.ts +10 -0
  8. package/dist/src/html/template.d.ts.map +1 -0
  9. package/dist/src/html/template.js +57 -0
  10. package/dist/src/html/template.js.map +1 -0
  11. package/dist/src/markdown/frontmatter.d.ts +3 -0
  12. package/dist/src/markdown/frontmatter.d.ts.map +1 -0
  13. package/dist/src/markdown/frontmatter.js +48 -0
  14. package/dist/src/markdown/frontmatter.js.map +1 -0
  15. package/dist/src/markdown/marked.d.ts +4 -0
  16. package/dist/src/markdown/marked.d.ts.map +1 -0
  17. package/dist/src/markdown/marked.js +82 -0
  18. package/dist/src/markdown/marked.js.map +1 -0
  19. package/dist/src/markdown/math.d.ts +7 -0
  20. package/dist/src/markdown/math.d.ts.map +1 -0
  21. package/dist/src/markdown/math.js +42 -0
  22. package/dist/src/markdown/math.js.map +1 -0
  23. package/dist/src/markdown/toc.d.ts +3 -0
  24. package/dist/src/markdown/toc.d.ts.map +1 -0
  25. package/dist/src/markdown/toc.js +29 -0
  26. package/dist/src/markdown/toc.js.map +1 -0
  27. package/dist/src/renderer.d.ts +17 -0
  28. package/dist/src/renderer.d.ts.map +1 -0
  29. package/dist/src/renderer.js +181 -0
  30. package/dist/src/renderer.js.map +1 -0
  31. package/dist/src/styles/default.css +147 -0
  32. package/dist/src/styles/github.css +118 -0
  33. package/dist/src/types.d.ts +40 -0
  34. package/dist/src/types.d.ts.map +1 -0
  35. package/dist/src/types.js +14 -0
  36. package/dist/src/types.js.map +1 -0
  37. package/dist/src/utils/html.d.ts +3 -0
  38. package/dist/src/utils/html.d.ts.map +1 -0
  39. package/dist/src/utils/html.js +24 -0
  40. package/dist/src/utils/html.js.map +1 -0
  41. package/dist/src/utils/validation.d.ts +6 -0
  42. package/dist/src/utils/validation.d.ts.map +1 -0
  43. package/dist/src/utils/validation.js +49 -0
  44. package/dist/src/utils/validation.js.map +1 -0
  45. package/package.json +82 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohamed Cheikh Sidiya
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,101 @@
1
+ # convpdf
2
+
3
+ Convert Markdown to high-quality PDF using Node.js, Marked, and Puppeteer.
4
+
5
+ ## Features
6
+
7
+ - **Zero-Config**: Beautiful defaults out of the box.
8
+ - **High Fidelity**: Professional rendering of math (MathJax), code (Highlight.js), and tables.
9
+ - **Advanced Layout**: Support for [TOC], footnotes, and `<!-- PAGE_BREAK -->`.
10
+ - **Customizable**: Override CSS, templates, headers, and footers.
11
+ - **Batch Processing**: Convert multiple files using glob patterns.
12
+ - **Watch Mode**: Live-reload PDFs as you edit your Markdown.
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ # Basic conversion
18
+ convpdf input.md
19
+
20
+ # Multiple files with custom output directory
21
+ convpdf "docs/*.md" -o results/
22
+
23
+ # Custom styles and TOC
24
+ convpdf input.md --css styles.css --toc
25
+
26
+ # Watch mode
27
+ convpdf "docs/**/*.md" --watch -o pdf/
28
+ ```
29
+
30
+ ## Options
31
+
32
+ - `-o, --output <path>`: Output directory or file path.
33
+ - `-w, --watch`: Watch for changes.
34
+ - `-c, --css <path>`: Custom CSS file.
35
+ - `-t, --template <path>`: Custom HTML template.
36
+ - `-m, --margin <margin>`: Page margin (default: 20mm).
37
+ - `-f, --format <format>`: PDF format (default: A4).
38
+ - `--header <path>`: Custom header template.
39
+ - `--footer <path>`: Custom footer template.
40
+ - `--toc`: Generate Table of Contents.
41
+ - `--toc-depth <depth>`: TOC depth from `1` to `6`.
42
+ - `--no-math`: Disable MathJax.
43
+
44
+ ## Configuration
45
+
46
+ Supports `.convpdfrc`, `.convpdfrc.json`, `.convpdfrc.yaml`, and `.convpdfrc.yml`.
47
+
48
+ Example:
49
+
50
+ ```yaml
51
+ margin: 15mm
52
+ format: A4
53
+ toc: true
54
+ tocDepth: 3
55
+ css: ./styles/custom.css
56
+ template: ./templates/report.html
57
+ header: ./templates/header.html
58
+ footer: ./templates/footer.html
59
+ ```
60
+
61
+ Paths in config files are resolved relative to the config file location.
62
+
63
+ ## Quality Gate
64
+
65
+ ```bash
66
+ npm run typecheck
67
+ npm run lint
68
+ npm run format:check
69
+ npm run build
70
+ npm test
71
+ ```
72
+
73
+ Or run everything in one command:
74
+
75
+ ```bash
76
+ npm run ci
77
+ ```
78
+
79
+ ## Linting and Formatting
80
+
81
+ ```bash
82
+ npm run lint
83
+ npm run lint:fix
84
+ npm run format
85
+ npm run format:check
86
+ ```
87
+
88
+ ## Development
89
+
90
+ ```bash
91
+ npm install
92
+ npm run build
93
+ npm test
94
+
95
+ # Run in dev mode without building dist/
96
+ npm run dev -- input.md
97
+ ```
98
+
99
+ ---
100
+
101
+ > Inspired by [simonhaenisch/md-to-pdf](https://github.com/simonhaenisch/md-to-pdf)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=convpdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convpdf.d.ts","sourceRoot":"","sources":["../../bin/convpdf.ts"],"names":[],"mappings":""}
@@ -0,0 +1,297 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { readFile, stat, mkdir } from 'fs/promises';
4
+ import { resolve, basename, extname, join, dirname } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ import chalk from 'chalk';
7
+ import { glob } from 'glob';
8
+ import chokidar, {} from 'chokidar';
9
+ import yaml from 'js-yaml';
10
+ import { Renderer } from '../src/renderer.js';
11
+ import { normalizeTocDepth } from '../src/utils/validation.js';
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const findPackageJson = async (dir) => {
14
+ const candidate = join(dir, 'package.json');
15
+ try {
16
+ await stat(candidate);
17
+ return candidate;
18
+ }
19
+ catch {
20
+ const parent = dirname(dir);
21
+ if (parent === dir)
22
+ throw new Error('package.json not found');
23
+ return findPackageJson(parent);
24
+ }
25
+ };
26
+ const pkg = JSON.parse(await readFile(await findPackageJson(__dirname), 'utf-8'));
27
+ const program = new Command();
28
+ const hasGlobMagic = (value) => /[*?[\]{}()]/.test(value);
29
+ const parseInteger = (value) => {
30
+ const parsed = Number.parseInt(value, 10);
31
+ if (!Number.isFinite(parsed)) {
32
+ throw new Error(`Invalid integer "${value}"`);
33
+ }
34
+ return parsed;
35
+ };
36
+ const loadConfig = async () => {
37
+ const candidates = ['.convpdfrc', '.convpdfrc.json', '.convpdfrc.yaml', '.convpdfrc.yml'];
38
+ for (const candidate of candidates) {
39
+ const configPath = resolve(candidate);
40
+ try {
41
+ const raw = await readFile(configPath, 'utf-8');
42
+ const parsed = yaml.load(raw, { schema: yaml.JSON_SCHEMA });
43
+ if (!parsed)
44
+ return { values: {}, sourcePath: configPath };
45
+ if (typeof parsed !== 'object' || Array.isArray(parsed)) {
46
+ throw new Error(`Expected object at root of config, got ${typeof parsed}`);
47
+ }
48
+ const config = parsed;
49
+ const configDir = dirname(configPath);
50
+ if (config.css)
51
+ config.css = resolve(configDir, config.css);
52
+ if (config.template)
53
+ config.template = resolve(configDir, config.template);
54
+ if (config.header)
55
+ config.header = resolve(configDir, config.header);
56
+ if (config.footer)
57
+ config.footer = resolve(configDir, config.footer);
58
+ return { values: config, sourcePath: configPath };
59
+ }
60
+ catch (error) {
61
+ const message = error instanceof Error ? error.message : String(error);
62
+ if (error?.code === 'ENOENT') {
63
+ continue;
64
+ }
65
+ throw new Error(`Failed to parse config "${configPath}": ${message}`);
66
+ }
67
+ }
68
+ return { values: {}, sourcePath: null };
69
+ };
70
+ const describeInputs = async (inputs) => Promise.all(inputs.map(async (raw) => {
71
+ const absolute = resolve(raw);
72
+ try {
73
+ const stats = await stat(absolute);
74
+ return {
75
+ raw,
76
+ absolute,
77
+ hasGlobMagic: hasGlobMagic(raw),
78
+ isDirectory: stats.isDirectory()
79
+ };
80
+ }
81
+ catch {
82
+ return {
83
+ raw,
84
+ absolute,
85
+ hasGlobMagic: hasGlobMagic(raw),
86
+ isDirectory: false
87
+ };
88
+ }
89
+ }));
90
+ const resolveMarkdownFiles = async (inputs) => {
91
+ const matches = await Promise.all(inputs.map(async (input) => {
92
+ try {
93
+ const stats = await stat(input.absolute);
94
+ if (stats.isFile())
95
+ return [input.absolute];
96
+ if (stats.isDirectory()) {
97
+ return glob('**/*.{md,markdown}', {
98
+ cwd: input.absolute,
99
+ nodir: true,
100
+ absolute: true
101
+ });
102
+ }
103
+ }
104
+ catch {
105
+ // If the direct path doesn't exist, treat it as a glob expression.
106
+ }
107
+ return glob(input.raw, { nodir: true, absolute: true });
108
+ }));
109
+ return [...new Set(matches.flat().filter((value) => /\.(md|markdown)$/i.test(value)))].sort((a, b) => a.localeCompare(b));
110
+ };
111
+ const resolveOutputStrategy = (outputPath, inputs) => {
112
+ if (!outputPath)
113
+ return { mode: 'adjacent', targetPath: null };
114
+ const absolute = resolve(outputPath);
115
+ if (!absolute.toLowerCase().endsWith('.pdf')) {
116
+ return { mode: 'directory', targetPath: absolute };
117
+ }
118
+ const maybeMultiple = inputs.length > 1 || inputs.some((input) => input.isDirectory || input.hasGlobMagic);
119
+ if (maybeMultiple) {
120
+ throw new Error('Output path cannot be a single .pdf file when inputs can expand to multiple markdown files.');
121
+ }
122
+ return { mode: 'single-file', targetPath: absolute };
123
+ };
124
+ const toOutputPath = (inputPath, strategy) => {
125
+ if (strategy.mode === 'adjacent') {
126
+ return join(dirname(inputPath), `${basename(inputPath, extname(inputPath))}.pdf`);
127
+ }
128
+ if (strategy.mode === 'single-file') {
129
+ if (!strategy.targetPath)
130
+ throw new Error('Single file output path is missing');
131
+ return strategy.targetPath;
132
+ }
133
+ if (!strategy.targetPath)
134
+ throw new Error('Output directory path is missing');
135
+ return join(strategy.targetPath, `${basename(inputPath, extname(inputPath))}.pdf`);
136
+ };
137
+ const readTemplate = async (pathValue) => {
138
+ if (!pathValue)
139
+ return null;
140
+ try {
141
+ return await readFile(resolve(pathValue), 'utf-8');
142
+ }
143
+ catch (error) {
144
+ const message = error instanceof Error ? error.message : String(error);
145
+ throw new Error(`Failed to read template file "${pathValue}": ${message}`);
146
+ }
147
+ };
148
+ class ConversionQueue {
149
+ chain = Promise.resolve();
150
+ pending = new Set();
151
+ enqueue(filePath, convert) {
152
+ if (this.pending.has(filePath))
153
+ return;
154
+ this.pending.add(filePath);
155
+ this.chain = this.chain
156
+ .then(async () => {
157
+ this.pending.delete(filePath);
158
+ await convert(filePath);
159
+ })
160
+ .catch((error) => {
161
+ this.pending.delete(filePath);
162
+ const message = error instanceof Error ? error.message : String(error);
163
+ console.error(chalk.red('Queue error:'), message);
164
+ });
165
+ }
166
+ }
167
+ program
168
+ .name('convpdf')
169
+ .description('Convert Markdown to high-quality PDF.')
170
+ .version(pkg.version)
171
+ .argument('<inputs...>', 'Input markdown files or glob patterns')
172
+ .option('-o, --output <path>', 'Output directory or file path')
173
+ .option('-w, --watch', 'Watch for changes')
174
+ .option('-c, --css <path>', 'Custom CSS')
175
+ .option('-t, --template <path>', 'Custom HTML template')
176
+ .option('-m, --margin <margin>', 'Page margin', '20mm')
177
+ .option('-f, --format <format>', 'PDF format', 'A4')
178
+ .option('--header <path>', 'Custom header template')
179
+ .option('--footer <path>', 'Custom footer template')
180
+ .option('--toc', 'Generate Table of Contents')
181
+ .option('--toc-depth <depth>', 'Table of Contents depth', parseInteger)
182
+ .option('--no-math', 'Disable MathJax')
183
+ .action(async (inputs, options) => {
184
+ let watcher = null;
185
+ const cleanup = async () => {
186
+ if (watcher)
187
+ await watcher.close().catch(() => { });
188
+ };
189
+ try {
190
+ const config = await loadConfig();
191
+ if (config.sourcePath) {
192
+ console.log(chalk.gray(`Using config: ${config.sourcePath}`));
193
+ }
194
+ const opts = { ...config.values, ...options };
195
+ if (opts.tocDepth !== undefined) {
196
+ opts.tocDepth = normalizeTocDepth(opts.tocDepth);
197
+ }
198
+ const describedInputs = await describeInputs(inputs);
199
+ const outputStrategy = resolveOutputStrategy(opts.output, describedInputs);
200
+ const files = await resolveMarkdownFiles(describedInputs);
201
+ if (!files.length) {
202
+ throw new Error('No input markdown files found.');
203
+ }
204
+ const firstInput = describedInputs[0];
205
+ const singleInput = describedInputs.length === 1 &&
206
+ firstInput &&
207
+ !firstInput.isDirectory &&
208
+ !firstInput.hasGlobMagic
209
+ ? firstInput.absolute
210
+ : null;
211
+ const renderer = new Renderer({
212
+ customCss: opts.css ? resolve(opts.css) : null,
213
+ template: opts.template ? resolve(opts.template) : null,
214
+ margin: opts.margin,
215
+ format: opts.format,
216
+ toc: opts.toc,
217
+ tocDepth: opts.tocDepth,
218
+ math: opts.math,
219
+ headerTemplate: await readTemplate(opts.header),
220
+ footerTemplate: await readTemplate(opts.footer)
221
+ });
222
+ let successCount = 0;
223
+ let failCount = 0;
224
+ const convert = async (filePath) => {
225
+ try {
226
+ const inputPath = resolve(filePath);
227
+ const inputStat = await stat(inputPath);
228
+ if (!inputStat.isFile())
229
+ return;
230
+ if (outputStrategy.mode === 'single-file' && singleInput && inputPath !== singleInput) {
231
+ console.log(chalk.yellow(`Skipping ${inputPath}: output is configured as a single PDF file for ${singleInput}.`));
232
+ return;
233
+ }
234
+ const outputPath = toOutputPath(inputPath, outputStrategy);
235
+ await mkdir(dirname(outputPath), { recursive: true });
236
+ console.log(chalk.blue(`Converting ${chalk.bold(inputPath)} -> ${chalk.bold(outputPath)}...`));
237
+ const markdown = await readFile(inputPath, 'utf-8');
238
+ await renderer.generatePdf(markdown, outputPath, { basePath: dirname(inputPath) });
239
+ console.log(chalk.green(`Done: ${basename(outputPath)}`));
240
+ successCount++;
241
+ }
242
+ catch (error) {
243
+ const message = error instanceof Error ? error.message : String(error);
244
+ console.error(chalk.red(`Failed (${filePath}): ${message}`));
245
+ failCount++;
246
+ }
247
+ };
248
+ for (const filePath of files) {
249
+ await convert(filePath);
250
+ }
251
+ const onSignal = async () => {
252
+ console.log(chalk.yellow('\nGracefully shutting down...'));
253
+ await cleanup();
254
+ await renderer.close();
255
+ process.exit(0);
256
+ };
257
+ process.on('SIGINT', () => {
258
+ void onSignal();
259
+ });
260
+ process.on('SIGTERM', () => {
261
+ void onSignal();
262
+ });
263
+ if (opts.watch) {
264
+ console.log(chalk.yellow('\nWatching for changes... (Press Ctrl+C to stop)'));
265
+ const queue = new ConversionQueue();
266
+ watcher = chokidar.watch(inputs, {
267
+ ignored: /(^|[\/\\])\../,
268
+ persistent: true,
269
+ ignoreInitial: true
270
+ });
271
+ watcher.on('all', (event, changedPath) => {
272
+ if (!['add', 'change'].includes(event) || !/\.(md|markdown)$/i.test(changedPath))
273
+ return;
274
+ const absoluteChangedPath = resolve(changedPath);
275
+ console.log(chalk.cyan(`\n${event === 'add' ? 'New file' : 'Change'} detected: ${absoluteChangedPath}`));
276
+ queue.enqueue(absoluteChangedPath, convert);
277
+ });
278
+ }
279
+ else {
280
+ await renderer.close();
281
+ if (successCount) {
282
+ console.log(chalk.green(`\nSuccessfully converted ${successCount} file(s).`));
283
+ }
284
+ if (failCount) {
285
+ throw new Error(`Failed to convert ${failCount} file(s).`);
286
+ }
287
+ }
288
+ }
289
+ catch (error) {
290
+ const message = error instanceof Error ? error.message : String(error);
291
+ console.error(chalk.red('Error:'), message);
292
+ await cleanup();
293
+ process.exit(1);
294
+ }
295
+ });
296
+ program.parse();
297
+ //# sourceMappingURL=convpdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convpdf.js","sourceRoot":"","sources":["../../bin/convpdf.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,QAAQ,EAAE,EAAkB,MAAM,UAAU,CAAC;AACpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,eAAe,GAAG,KAAK,EAAE,GAAW,EAAmB,E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ath?: string;
7
+ includeMathJax: boolean;
8
+ }
9
+ export declare const renderTemplate: (input: HtmlTemplateInput) => Promise<string>;
10
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/html/template.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;CACzB;AA2CD,eAAO,MAAM,cAAc,GAAU,OAAO,iBAAiB,KAAG,OAAO,CAAC,MAAM,CAc7E,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { readFile } from 'fs/promises';
2
+ import { resolve } from 'path';
3
+ import { pathToFileURL } from 'url';
4
+ import { escapeHtml } from '../utils/html.js';
5
+ const DEFAULT_TEMPLATE = `<!DOCTYPE html>
6
+ <html>
7
+ <head>
8
+ <meta charset="UTF-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
+ {{base}}
11
+ <title>{{title}}</title>
12
+ <style>{{css}}</style>
13
+ {{mathjax}}
14
+ </head>
15
+ <body class="markdown-body">
16
+ {{content}}
17
+ </body>
18
+ </html>`;
19
+ const MATHJAX_SNIPPET = `
20
+ <script>
21
+ window.MathJax = {
22
+ tex: {
23
+ inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],
24
+ displayMath: [['$$', '$$'], ['\\\\[', '\\\\]']]
25
+ },
26
+ svg: { fontCache: 'global' },
27
+ options: { enableErrorOutputs: false }
28
+ };
29
+ </script>
30
+ <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>`;
31
+ const loadTemplate = async (templatePath) => {
32
+ if (!templatePath)
33
+ return DEFAULT_TEMPLATE;
34
+ try {
35
+ return await readFile(resolve(templatePath), 'utf-8');
36
+ }
37
+ catch (error) {
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ throw new Error(`Failed to read template at "${templatePath}": ${message}`);
40
+ }
41
+ };
42
+ const replaceToken = (template, token, value) => template.split(`{{${token}}}`).join(value);
43
+ export const renderTemplate = async (input) => {
44
+ const template = await loadTemplate(input.templatePath);
45
+ const baseTag = input.basePath
46
+ ? `<base href="${escapeHtml(pathToFileURL(resolve(input.basePath)).href)}/">`
47
+ : '';
48
+ const mathJax = input.includeMathJax ? MATHJAX_SNIPPET : '';
49
+ let html = template;
50
+ html = replaceToken(html, 'title', escapeHtml(input.title));
51
+ html = replaceToken(html, 'base', baseTag);
52
+ html = replaceToken(html, 'css', input.css);
53
+ html = replaceToken(html, 'content', input.content);
54
+ html = replaceToken(html, 'mathjax', mathJax);
55
+ return html;
56
+ };
57
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/html/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAW9C,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;QAajB,CAAC;AAET,MAAM,eAAe,GAAG;;;;;;;;;;;8GAWsF,CAAC;AAE/G,MAAM,YAAY,GAAG,KAAK,EAAE,YAA4B,EAAmB,EAAE;IAC3E,IAAI,CAAC,YAAY;QAAE,OAAO,gBAAgB,CAAC;IAC3C,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,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AI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FrontmatterParseResult } from '../types.js';
2
+ export declare const parseFrontmatter: (markdown: string) => FrontmatterParseResult;
3
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/markdown/frontmatter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAOvE,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,sBA2CnD,CAAC"}
@@ -0,0 +1,48 @@
1
+ import yaml from 'js-yaml';
2
+ const normalizeFrontmatter = (value) => {
3
+ if (!value || typeof value !== 'object' || Array.isArray(value))
4
+ return {};
5
+ return value;
6
+ };
7
+ export const parseFrontmatter = (markdown) => {
8
+ const lines = markdown.split(/\r?\n/);
9
+ if (lines[0]?.trim() !== '---') {
10
+ return { data: {}, content: markdown, warnings: [] };
11
+ }
12
+ let closingIndex = -1;
13
+ for (let index = 1; index < lines.length; index++) {
14
+ if (lines[index]?.trim() === '---') {
15
+ closingIndex = index;
16
+ break;
17
+ }
18
+ }
19
+ if (closingIndex < 0) {
20
+ return { data: {}, content: markdown, warnings: [] };
21
+ }
22
+ const source = lines.slice(1, closingIndex).join('\n');
23
+ const content = lines.slice(closingIndex + 1).join('\n');
24
+ if (!source.trim()) {
25
+ return {
26
+ data: {},
27
+ content,
28
+ warnings: []
29
+ };
30
+ }
31
+ try {
32
+ const parsed = yaml.load(source, { schema: yaml.JSON_SCHEMA });
33
+ return {
34
+ data: normalizeFrontmatter(parsed),
35
+ content,
36
+ warnings: []
37
+ };
38
+ }
39
+ catch (error) {
40
+ const message = error instanceof Error ? error.message : String(error);
41
+ return {
42
+ data: {},
43
+ content: markdown,
44
+ warnings: [`Frontmatter parsing failed: ${message}`]
45
+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AAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QACnB,OAAO;YACL,IAAI,EAAE,EAAE;YACR,OAAO;YACP,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/D,OAAO;YACL,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC;YAClC,OAAO;YACP,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO;YACL,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,QAAQ;YACjB,QAAQ,EAAE,CAAC,+BAA+B,OAAO,EAAE,CAAC;SACrD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Marked } from 'marked';
2
+ import type GithubSlugger from 'github-slugger';
3
+ export declare const createMarkedInstance: (slugger: GithubSlugger) => Marked;
4
+ //# sourceMappingURL=marked.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marked.d.ts","sourceRoot":"","sources":["../../../src/markdown/marked.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAQhD,eAAO,MAAM,oBAAoB,GAAI,SAAS,aAAa,KAAG,MA2E7D,CAAC"}