@masumdev/markforge 0.2.4 β†’ 0.2.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/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  # @masumdev/markforge
4
4
 
5
- **Modern, high-performance Markdown & MDX multi-format publishing engine & CLI.**
6
- Convert Markdown into pixel-perfect **DOCX**, **PDF**, and **HTML** with syntax highlighting, Mermaid diagrams, callout boxes, and a beautiful Ink terminal UI.
5
+ **Enterprise Markdown & MDX Multi-Format Publishing Engine & CLI.**
6
+ Convert Markdown into pixel-perfect **DOCX**, **PDF**, and **HTML** with native typography, syntax highlighting, Mermaid diagrams, callout boxes, customizable `ThemeProps`, and an interactive Ink terminal UI.
7
7
 
8
8
  [![npm version](https://img.shields.io/npm/v/@masumdev/markforge.svg?style=flat-square&color=33CDCF)](https://www.npmjs.com/package/@masumdev/markforge)
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-33CDCF.svg?style=flat-square)](https://opensource.org/licenses/MIT)
@@ -18,381 +18,282 @@ Convert Markdown into pixel-perfect **DOCX**, **PDF**, and **HTML** with syntax
18
18
 
19
19
  | Feature | Description |
20
20
  | :--- | :--- |
21
- | πŸ“„ **Multi-Format Output** | Generate `.docx`, `.pdf`, and `.html` from a single Markdown source |
22
- | 🎨 **Mermaid Diagrams** | Full Mermaid.js support β€” flowcharts, sequence, gantt, class diagrams |
23
- | πŸ“’ **Callout / Alert Boxes** | GitHub-style `> [!NOTE]`, `> [!TIP]`, `> [!WARNING]`, `> [!CAUTION]`, `> [!IMPORTANT]` |
24
- | 🌈 **Dual Syntax Highlighting** | Dark theme for PDF/HTML, Light theme for DOCX β€” 100% readable in both |
25
- | πŸ–ΌοΈ **Image Inlining Engine** | Auto-resolves local paths, remote URLs, Base64 URIs, and SVGs |
26
- | πŸ“‘ **Auto Table of Contents** | Anchored TOC generated from heading structure |
27
- | πŸ“ **Header & Footer Zones** | Left / Center / Right multi-zone headers and footers per format |
28
- | 🎨 **Curated Themes** | `default`, `academic`, `github`, `corporate`, `minimal`, `dracula` |
29
- | πŸ’§ **Watermark Support** | Optional configurable watermark (position, opacity, text) β€” off by default |
30
- | βš™οΈ **Type-Safe Config** | `markforge.config.ts`, `.markforgerc.json`, or YAML with JSON Schema |
31
- | πŸš€ **Programmatic API** | Full TypeScript API for Node.js & Bun integration |
32
- | πŸ–₯️ **Ink Terminal UI** | Rich interactive TUI with progress indicators and build summary |
21
+ | πŸ“„ **Multi-Format Output** | Generate `.docx`, `.pdf`, and `.html` from a single Markdown source simultaneously |
22
+ | 🎨 **Theme.CORPORATE & ThemeProps** | Flagship cyan corporate design system + full custom colors & fonts via `ThemeProps` |
23
+ | πŸ“ **Per-Zone Header & Footer** | Granular color, font size, font family, bold & italic controls per `left`, `center`, `right` slot |
24
+ | πŸ“Š **Mermaid Diagrams** | Full Mermaid.js diagram engine β€” flowcharts, sequence, state, class, gantt |
25
+ | πŸ“’ **Callout / Alert Boxes** | GitHub-style `> [!NOTE]`, `> [!TIP]`, `> [!IMPORTANT]`, `> [!WARNING]`, `> [!CAUTION]` |
26
+ | 🌈 **Syntax Highlighting** | Tokenized multi-language code blocks (`dracula`, `github-dark`, `monokai`, `nord`, etc.) |
27
+ | πŸ–ΌοΈ **Image Inlining Engine** | Resolves local files, remote URLs, Base64 data URIs, and SVGs into embedded assets |
28
+ | πŸ“‘ **Auto Table of Contents** | Anchored TOC generated from heading structure (`#` to `####`) |
29
+ | πŸ’§ **Non-Intrusive Watermark** | Background-layer watermark with custom text, color, opacity, rotation, and position |
30
+ | βš™οΈ **Type-Safe Config** | `markforge.config.ts` with Enums, `.markforgerc.json`, or YAML with JSON Schema |
31
+ | πŸš€ **Programmatic API** | High-level `compileMarkdown()` and low-level AST document builders for Node.js & Bun |
32
+ | πŸ–₯️ **Ink Terminal UI** | Interactive TUI with live spinners, progress tracking, and compilation metrics |
33
33
 
34
34
  ---
35
35
 
36
36
  ## πŸ“¦ Installation
37
37
 
38
38
  ```bash
39
- # Global CLI
39
+ # Global CLI Installation
40
40
  npm install -g @masumdev/markforge
41
+ # or with bun:
41
42
  bun add -g @masumdev/markforge
42
43
 
43
- # Dev dependency
44
+ # Project Local Dependency
44
45
  npm install -D @masumdev/markforge
46
+ # or with bun:
45
47
  bun add -d @masumdev/markforge
46
48
  ```
47
49
 
48
50
  ---
49
51
 
50
- ## πŸš€ Quick Start
52
+ ## πŸ’» CLI Usage
51
53
 
52
54
  ```bash
53
- # Convert to DOCX + PDF (default)
55
+ # Basic conversion to DOCX and PDF (defaults)
54
56
  markforge document.md
55
57
 
56
- # Specify output formats
58
+ # Specify target formats and output folder
57
59
  markforge document.md --to docx,pdf,html -o ./dist
58
60
 
59
- # Use a theme and custom CSS
60
- markforge report.md --theme academic --css ./styles/corp.css
61
+ # Use custom CSS styling and force Table of Contents
62
+ markforge specification.md --css ./styles/custom.css --toc
61
63
 
62
- # Force Table of Contents
63
- markforge specification.md --toc
64
+ # Watch mode for live re-compilation
65
+ markforge report.md --watch
64
66
 
65
- # Watch mode
66
- markforge document.md --watch
67
+ # Launch local preview server and open in browser
68
+ markforge document.md --serve --port 4000 --open
67
69
  ```
68
70
 
69
- ---
70
-
71
- ## πŸ–ŠοΈ Markdown Source Features
72
-
73
- ### Callout / Alert Boxes
74
-
75
- MarkForge supports GitHub-style alert syntax with full color-coded styling in all output formats:
76
-
77
- ```markdown
78
- > [!NOTE]
79
- > This is a note β€” rendered with cyan left border.
80
-
81
- > [!TIP]
82
- > This is a tip β€” rendered with green styling.
83
-
84
- > [!IMPORTANT]
85
- > Critical information β€” rendered with purple styling.
86
-
87
- > [!WARNING]
88
- > A warning β€” rendered with amber/yellow styling.
89
-
90
- > [!CAUTION]
91
- > High-risk action β€” rendered with red styling.
92
- ```
93
-
94
- ### Mermaid Diagrams
95
-
96
- Mermaid code blocks are automatically rendered into images embedded in all output formats:
97
-
98
- ````markdown
99
- ```mermaid
100
- flowchart LR
101
- A[Markdown Source] --> B[AST Parser]
102
- B --> C[DOCX Builder]
103
- B --> D[PDF Builder]
104
- B --> E[HTML Builder]
105
- ```
106
- ````
107
-
108
- ### Syntax-Highlighted Code Blocks
109
-
110
- All common languages are supported with proper token coloring:
111
-
112
- ````markdown
113
- ```typescript
114
- import { markforge } from "@masumdev/markforge";
115
-
116
- const result = await markforge("./spec.md", { to: ["pdf", "docx"] });
117
- ```
118
- ````
119
-
120
- **Dual-theme coloring:**
121
- - **PDF / HTML**: VS Code Dark+ palette (bright colors on dark background)
122
- - **DOCX**: GitHub Light palette (deep colors on white background)
71
+ ### CLI Flags Reference
123
72
 
124
- ### Table of Contents
125
-
126
- Add `toc: true` in frontmatter or use `--toc` CLI flag to auto-generate:
127
-
128
- ```markdown
129
- ---
130
- toc: true
131
- ---
132
-
133
- # My Document
134
- ```
135
-
136
- ---
137
-
138
- ## πŸ“‹ Frontmatter Reference
139
-
140
- ```markdown
141
- ---
142
- title: "Enterprise Architecture Specification"
143
- subtitle: "Cloud & Edge Infrastructure β€” Q3 2026"
144
- author: "Ma'sum"
145
- version: "2.4.0"
146
- date: "2026-08-27"
147
- theme: "default" # default | academic | github | corporate | minimal | dracula
148
- toc: true # auto-generate Table of Contents
149
- orientation: "portrait" # portrait | landscape
150
- paperSize: "A4" # A4 | letter | legal
151
- watermark:
152
- enabled: false # no watermark by default
153
- text: "CONFIDENTIAL"
154
- opacity: 0.08
155
- position: "diagonal" # diagonal | center | top-left | top-right | bottom-left | bottom-right
156
- header:
157
- left: "My Company"
158
- center: "{title}"
159
- right: "Version {version}"
160
- footer:
161
- left: "Confidential"
162
- right: "Page {page} of {pages}"
163
- ---
164
- ```
73
+ | Flag | Alias | Description | Default |
74
+ | :--- | :---: | :--- | :--- |
75
+ | `<file>` | | Markdown input file path | **Required** |
76
+ | `--to <formats...>` | `-t` | Output formats: `docx`, `pdf`, `html`, `png` | `docx,pdf` |
77
+ | `--output <dir>` | `-o` | Output directory | Same as input file |
78
+ | `--config <file>` | `-c` | Explicit configuration file path | Auto-discovered |
79
+ | `--theme <name>` | | Visual theme preset (`corporate`, `default`) | `corporate` |
80
+ | `--css <files...>` | | Custom CSS stylesheets to inject | `undefined` |
81
+ | `--orientation <type>` | | Page orientation (`portrait`, `landscape`) | `portrait` |
82
+ | `--paper-size <size>` | | Standard paper size (`A4`, `Letter`, `Legal`, `A3`, `A5`) | `A4` |
83
+ | `--toc` | | Force Table of Contents generation | `false` |
84
+ | `--watermark <text>` | | Document watermark text | `undefined` |
85
+ | `--syntax-theme <theme>`| | Code syntax highlighting theme | `github-dark` |
86
+ | `--watch` | `-w` | Watch input file and re-compile on change | `false` |
87
+ | `--serve` | | Start local HTTP preview server | `false` |
88
+ | `--port <number>` | `-p` | Local preview server port | `4000` |
89
+ | `--open` | | Automatically open browser on preview | `false` |
90
+ | `--version` | `-V` | Output version number | |
91
+ | `--help` | `-h` | Display CLI help menu | |
165
92
 
166
93
  ---
167
94
 
168
- ## βš™οΈ Configuration Reference
95
+ ## βš™οΈ Configuration (`markforge.config.ts`)
169
96
 
170
- MarkForge automatically discovers configuration files starting from the input file's directory up to the workspace root, or via the `-c, --config <path>` CLI flag.
171
-
172
- ### 1. TypeScript (`markforge.config.ts`)
97
+ MarkForge supports type-safe configuration with full TypeScript Enums:
173
98
 
174
99
  ```typescript
175
- import { defineConfig } from "@masumdev/markforge";
100
+ import {
101
+ defineConfig,
102
+ OutputFormat,
103
+ Theme,
104
+ Orientation,
105
+ PaperSizeEnum,
106
+ SyntaxTheme,
107
+ WatermarkPosition,
108
+ } from "@masumdev/markforge";
176
109
 
177
110
  export default defineConfig({
178
- // Output formats: "docx" | "pdf" | "html"
179
- to: ["docx", "pdf", "html"],
180
- outputDir: "./dist/documents",
111
+ // Target output formats
112
+ to: [OutputFormat.DOCX, OutputFormat.PDF, OutputFormat.HTML],
113
+
114
+ // Output destination directory
115
+ outputDir: ".temp/output-docs",
181
116
 
182
- // Theme: "default" | "academic" | "github" | "corporate" | "minimal" | "dracula"
183
- theme: "academic",
117
+ // Visual document theme (Theme.CORPORATE preset or a custom ThemeProps object)
118
+ theme: Theme.CORPORATE,
184
119
 
185
- // Custom CSS stylesheet(s) to inject
186
- css: ["./styles/custom.css"],
120
+ // Page orientation & standard physical paper size
121
+ orientation: Orientation.PORTRAIT,
122
+ paperSize: PaperSizeEnum.A4,
187
123
 
188
- // Page layout & dimensions
189
- orientation: "portrait", // "portrait" | "landscape"
190
- paperSize: "A4", // "A4" | "Letter" | "Legal" | "A3" | "A5"
124
+ // Document page margins
191
125
  margins: {
192
- top: "2.5cm",
126
+ top: "3cm",
193
127
  bottom: "2.5cm",
194
- left: "3cm",
195
- right: "3cm",
128
+ left: "2.5cm",
129
+ right: "2.5cm",
196
130
  },
197
131
 
198
- // Multi-zone header & footer (supports tokens: {title}, {author}, {version}, {date}, {page}, {pages})
132
+ // Running headers with dynamic tokens & per-zone slot styling
199
133
  header: {
200
- left: "Enterprise Architecture",
201
- center: "{title}",
202
- right: "v{version}",
134
+ left: {
135
+ text: "{company} - {title}",
136
+ color: "#0D998D",
137
+ fontSize: 9,
138
+ fontFamily: "Inter, Segoe UI, sans-serif",
139
+ bold: true,
140
+ },
141
+ center: "Internal Technical Guide",
142
+ right: {
143
+ text: "v{version}",
144
+ color: "#94A3B8",
145
+ fontSize: 8.5,
146
+ italic: true,
147
+ },
148
+ divider: true,
149
+ dividerColor: "#CBD5E1",
203
150
  },
151
+
152
+ // Running footers with dynamic page numbering & per-zone slot styling
204
153
  footer: {
205
- left: "Confidential β€” Internal Use Only",
206
- right: "Page {page} of {pages}",
154
+ left: {
155
+ text: "Author: {author}",
156
+ color: "#64748B",
157
+ fontSize: 8.5,
158
+ },
159
+ center: {
160
+ text: "{date}",
161
+ color: "#94A3B8",
162
+ fontSize: 8.5,
163
+ italic: true,
164
+ },
165
+ right: {
166
+ text: "Page {page} of {pages}",
167
+ color: "#0D998D",
168
+ fontSize: 9,
169
+ bold: true,
170
+ },
171
+ divider: true,
172
+ dividerColor: "#CBD5E1",
173
+ },
174
+
175
+ // Automatic Table of Contents
176
+ toc: true,
177
+
178
+ // Watermark configuration (placed at lowest background layer)
179
+ watermark: {
180
+ text: "CONFIDENTIAL DRAFT",
181
+ color: "#E11D48",
182
+ opacity: 0.1,
183
+ fontSize: 52,
184
+ rotate: -45,
185
+ position: WatermarkPosition.DIAGONAL,
207
186
  },
208
187
 
209
- // Document features
210
- toc: true, // Auto-generate Table of Contents
211
- embedImages: true, // Embed/inline all images as Base64 data URIs
212
- bundleHtml: true, // Self-contained HTML with embedded styles and scripts
213
- syntaxTheme: "github-dark", // "github-dark" | "github-light" | "dracula" | "monokai" | "nord"
188
+ // Syntax highlighting theme
189
+ syntaxTheme: SyntaxTheme.DRACULA,
214
190
 
215
- // Diagonal page watermark
216
- watermark: "CONFIDENTIAL",
191
+ // Asset embedding & bundling flags
192
+ embedImages: true,
193
+ bundleHtml: true,
217
194
 
218
- // Default document metadata
195
+ // Global document metadata
219
196
  metadata: {
220
- title: "System Architecture Specification",
221
- author: "Ma'sum",
197
+ title: "Unified Platform Architecture & Document Suite",
198
+ subtitle: "Enterprise Specification & Feature Validation Guide",
199
+ author: "Masum RPG",
200
+ company: "Masum Dev Technologies",
222
201
  version: "1.0.0",
223
- company: "My Organization",
202
+ date: "2026-08-29",
203
+ lang: "en",
224
204
  },
225
-
226
- // Server & watch options
227
- watch: false,
228
- serve: false,
229
- port: 4000,
230
- open: false,
231
205
  });
232
206
  ```
233
207
 
234
- ### 2. JSON with `$schema` (`markforge.config.json`)
235
-
236
- Adding `$schema` enables **instant autocompletion and validation** in VS Code, WebStorm, and other IDEs:
237
-
238
- ```json
239
- {
240
- "$schema": "https://raw.githubusercontent.com/masumdev/react-native-library/main/packages/markforge/schema.json",
241
- "to": ["docx", "pdf", "html"],
242
- "outputDir": "./dist/documents",
243
- "theme": "academic",
244
- "orientation": "portrait",
245
- "paperSize": "A4",
246
- "margins": {
247
- "top": "2.5cm",
248
- "bottom": "2.5cm",
249
- "left": "3cm",
250
- "right": "3cm"
251
- },
252
- "header": {
253
- "left": "Enterprise Architecture",
254
- "right": "{title}"
255
- },
256
- "footer": {
257
- "left": "Confidential",
258
- "right": "Page {page} of {pages}"
259
- },
260
- "toc": true,
261
- "embedImages": true,
262
- "syntaxTheme": "github-dark",
263
- "watermark": "CONFIDENTIAL"
264
- }
265
- ```
208
+ ---
266
209
 
267
- ### 3. YAML (`markforge.config.yaml` / `.markforgerc.yaml`)
268
-
269
- ```yaml
270
- to:
271
- - docx
272
- - pdf
273
- - html
274
- outputDir: ./dist/documents
275
- theme: academic
276
- orientation: portrait
277
- paperSize: A4
278
- margins:
279
- top: 2.5cm
280
- bottom: 2.5cm
281
- left: 3cm
282
- right: 3cm
283
- header:
284
- left: Enterprise Architecture
285
- right: "{title}"
286
- footer:
287
- left: Confidential
288
- right: "Page {page} of {pages}"
289
- toc: true
290
- embedImages: true
291
- watermark: CONFIDENTIAL
292
- ```
210
+ ## 🎨 Custom Theme Customization (`ThemeProps`)
293
211
 
212
+ You can completely rebrand all document styling by passing a `ThemeProps` object:
213
+
214
+ ```typescript
215
+ import { defineConfig } from "@masumdev/markforge";
216
+
217
+ export default defineConfig({
218
+ theme: {
219
+ primaryColor: "#0D998D",
220
+ primaryDark: "#008073",
221
+ primaryLight: "#D9F1F0",
222
+ backgroundColor: "#0F172A",
223
+ textColor: "#E2E8F0",
224
+ textMuted: "#94A3B8",
225
+ borderColor: "#334155",
226
+ cardBackground: "#1E293B",
227
+ codeBackground: "#020617",
228
+ codeText: "#E2E8F0",
229
+ fontFamily: "'Inter', sans-serif",
230
+ fontMono: "'Fira Code', monospace",
231
+ },
232
+ });
233
+ ```
294
234
 
295
235
  ---
296
236
 
297
- ## πŸ’» Programmatic API
237
+ ## πŸš€ Programmatic API
238
+
239
+ ### High-Level API (`compileMarkdown` / `markforge`)
298
240
 
299
241
  ```typescript
300
- import { markforge, compileMarkdown } from "@masumdev/markforge";
242
+ import { compileMarkdown, OutputFormat } from "@masumdev/markforge";
301
243
 
302
- // High-level: compile file β†’ write to disk
303
- const result = await markforge("./specification.md", {
304
- to: ["docx", "pdf", "html"],
244
+ const result = await compileMarkdown("./specification.md", {
245
+ to: [OutputFormat.DOCX, OutputFormat.PDF, OutputFormat.HTML],
305
246
  outputDir: "./dist",
306
- theme: "academic",
247
+ toc: true,
307
248
  metadata: {
308
- title: "System Architecture Specification",
309
- author: "Ma'sum",
310
- version: "2.4.0",
249
+ title: "API Reference Manual",
250
+ author: "Masum Dev",
251
+ version: "1.0.0",
311
252
  },
312
253
  });
313
254
 
314
- console.log(`βœ“ Generated ${result.files.length} files in ${result.durationMs}ms`);
315
-
255
+ console.log(`βœ“ Compiled ${result.files.length} documents in ${result.durationMs}ms:`);
316
256
  for (const file of result.files) {
317
- console.log(` [${file.format.toUpperCase()}] ${file.filePath} β€” ${file.sizeBytes} bytes`);
257
+ console.log(` [${file.format.toUpperCase()}] ${file.filePath} (${file.sizeBytes} bytes)`);
318
258
  }
319
259
  ```
320
260
 
321
- ```typescript
322
- import { compileMarkdown, buildPdfDocument, buildDocxDocument, buildHtmlDocument } from "@masumdev/markforge";
323
-
324
- // Low-level: parse β†’ build each format independently
325
- const parsed = await compileMarkdown("./report.md");
326
-
327
- const pdfBuffer = await buildPdfDocument(parsed.doc, parsed.config, parsed.baseDir);
328
- const docxBuffer = await buildDocxDocument(parsed.doc, parsed.config, parsed.baseDir);
329
- const htmlString = await buildHtmlDocument(parsed.doc, parsed.config, parsed.baseDir);
330
- ```
331
-
332
- ---
333
-
334
- ## 🎨 Built-in Themes
335
-
336
- | Theme | Description | Best For |
337
- | :--- | :--- | :--- |
338
- | `default` | Blu by BCA Digital cyan palette, modern sans-serif | Tech docs, specifications |
339
- | `academic` | Serif typography (Merriweather/Georgia), justified text | Papers, reports, theses |
340
- | `github` | GitHub Markdown rendering style | READMEs, open-source docs |
341
- | `corporate` | Clean professional layout | Business documents |
342
- | `minimal` | Minimal whitespace-focused design | Simple notes |
343
- | `dracula` | Dark-mode inspired color scheme | Developer docs |
344
-
345
- All themes automatically inherit shared component styles (callouts, code blocks, tables, badges) via the `THEME_COMPONENTS` base layer.
346
-
347
- ---
348
-
349
- ## πŸ–₯️ CLI Flags
261
+ ### Low-Level API (AST & Individual Document Builders)
350
262
 
351
- | Flag | Alias | Description | Default |
352
- | :--- | :---: | :--- | :--- |
353
- | `--to <formats>` | `-t` | Comma-separated output formats: `docx`, `pdf`, `html` | `docx,pdf` |
354
- | `--output <dir>` | `-o` | Output directory | Same as input file dir |
355
- | `--theme <name>` | | Built-in theme name | `default` |
356
- | `--css <path...>` | | Custom CSS file(s) to inject | |
357
- | `--toc` | | Force Table of Contents generation | `false` |
358
- | `--config <path>` | `-c` | Config file path (`markforge.config.ts`, `.json`, `.yaml`) | Auto-discovered |
359
- | `--watch` | `-w` | Watch input and re-compile on change | `false` |
360
- | `--version` | `-V` | Print version and exit | |
361
- | `--help` | `-h` | Show help | |
362
-
363
- ---
364
-
365
- ## πŸ—οΈ Architecture
366
-
367
- ```
368
- Markdown / MDX source
369
- β”‚
370
- β–Ό
371
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
372
- β”‚ AST Parser β”‚ β†’ Frontmatter + Node tree
373
- β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
374
- β”‚
375
- β”Œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”
376
- β”‚ β”‚ β”‚
377
- β–Ό β–Ό β–Ό
378
- DOCX PDF HTML
379
- Builder Builder Builder
380
- β”‚ β”‚ β”‚
381
- β”‚ Chromium β”‚
382
- β”‚ (headlessβ”‚
383
- β”‚ PDF) β”‚
384
- β–Ό β–Ό β–Ό
385
- .docx .pdf .html
263
+ ```typescript
264
+ import * as fs from "node:fs";
265
+ import {
266
+ parseMarkdownDocument,
267
+ buildDocxDocument,
268
+ buildPdfDocument,
269
+ buildHtmlDocument,
270
+ Theme,
271
+ } from "@masumdev/markforge";
272
+
273
+ const markdownContent = fs.readFileSync("./report.md", "utf-8");
274
+
275
+ // 1. Parse Markdown into structured AST
276
+ const doc = parseMarkdownDocument(markdownContent);
277
+
278
+ const config = {
279
+ theme: Theme.CORPORATE,
280
+ toc: true,
281
+ margins: { top: "2.5cm", bottom: "2.5cm", left: "2.5cm", right: "2.5cm" },
282
+ };
283
+
284
+ // 2. Build formats independently into binary buffers or HTML strings
285
+ const docxBuffer = await buildDocxDocument(doc, config);
286
+ const pdfBuffer = await buildPdfDocument(doc, config);
287
+ const htmlString = await buildHtmlDocument(doc, config);
288
+
289
+ // 3. Write output files
290
+ fs.writeFileSync("./dist/report.docx", docxBuffer);
291
+ fs.writeFileSync("./dist/report.pdf", pdfBuffer);
292
+ fs.writeFileSync("./dist/report.html", htmlString, "utf-8");
386
293
  ```
387
294
 
388
- **Sub-systems:**
389
- - `imageResolver` β€” Local / URL / Base64 / SVG asset resolution
390
- - `mermaidRenderer` β€” Headless Mermaid.js diagram rasterization
391
- - `syntaxHighlighter` β€” Dual dark/light theme tokenizer (no external deps)
392
- - `htmlThemes` β€” `THEME_COMPONENTS` base + per-theme typography overrides
393
-
394
295
  ---
395
296
 
396
297
  ## πŸ“„ License
397
298
 
398
- MIT Β© [Ma'sum](https://github.com/masumrpg)
299
+ MIT Β© [Masum Dev](https://github.com/masumdev)