@masumdev/markforge 0.3.0 → 0.4.1
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 +167 -140
- package/dist/App-TPDCT2VL.mjs +393 -0
- package/dist/{chunk-IYGPJIK5.mjs → chunk-BPHDY6VB.mjs} +6 -0
- package/dist/{App-AM2CWXHJ.mjs → chunk-R6DT335C.mjs} +2140 -924
- package/dist/{chunk-HKB4CSPZ.mjs → chunk-UNWAEVDU.mjs} +4 -3
- package/dist/cli.mjs +38 -8
- package/dist/index.d.mts +554 -136
- package/dist/index.d.ts +554 -136
- package/dist/index.js +2652 -227
- package/dist/index.mjs +2643 -228
- package/dist/{loadConfig-PD6ENMAM.mjs → loadConfig-PGJKPE6G.mjs} +1 -1
- package/dist/previewServer-4EELOUAV.mjs +893 -0
- package/package.json +5 -1
- package/schema.json +142 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# @masumdev/markforge
|
|
4
4
|
|
|
5
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.
|
|
6
|
+
Convert Markdown into pixel-perfect **DOCX**, **PDF**, and **HTML** with native typography, syntax highlighting, Mermaid diagrams, callout boxes, customizable `ThemeProps`, AES-256 PDF encryption, and an interactive Ink terminal UI.
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/@masumdev/markforge)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -14,26 +14,35 @@ Convert Markdown into pixel-perfect **DOCX**, **PDF**, and **HTML** with native
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Features
|
|
18
18
|
|
|
19
19
|
| Feature | Description |
|
|
20
20
|
| :--- | :--- |
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
21
|
+
| **Multi-Format Output** | Generate `.docx`, `.pdf`, and `.html` from a single Markdown source simultaneously |
|
|
22
|
+
| **Theme.CORPORATE & ThemeProps** | Flagship cyan corporate design system plus full custom colors and fonts via `ThemeProps` |
|
|
23
|
+
| **Cover Page Builder** | Four professional cover page presets (`modern`, `corporate-split`, `minimal`, `card`) with company logo |
|
|
24
|
+
| **Back Cover / Closing Page** | Dedicated closing page with company details, contact info, social links, and copyright notice |
|
|
25
|
+
| **Math & LaTeX Equations** | Native KaTeX math rendering for inline (`$E=mc^2$`) and display blocks (`$$\sum_{i=1}^n x_i$$`) |
|
|
26
|
+
| **Multi-Column Directives** | Flexible multi-column layouts (`:::columns 2` and `:::col`) across HTML, PDF, and DOCX |
|
|
27
|
+
| **Section Numbering** | Automated hierarchical decimal numbering (`1.`, `1.1.`, `1.1.1.`) with configurable depth |
|
|
28
|
+
| **Footnotes & Endnotes** | Full academic footnotes (`[^1]` and `[^1]: description`) with backlinks and DOCX notes |
|
|
29
|
+
| **AES-256 PDF Security** | ISO 32000-2 standard PDF encryption with user/owner passwords and granular permissions |
|
|
30
|
+
| **100% Unselectable Watermark** | Chromium-rendered Image XObject watermark preventing any cursor selection interference |
|
|
31
|
+
| **Per-Zone Header & Footer** | Granular color, font size, font family, bold, and italic controls per `left`, `center`, `right` slot |
|
|
32
|
+
| **Mermaid Diagrams** | Full Mermaid.js diagram engine for flowcharts, sequence diagrams, gantt charts, and class models |
|
|
33
|
+
| **Callout / Alert Boxes** | GitHub-style `> [!NOTE]`, `> [!TIP]`, `> [!IMPORTANT]`, `> [!WARNING]`, `> [!CAUTION]` |
|
|
34
|
+
| **Syntax Highlighting** | Tokenized multi-language code blocks (`dracula`, `github-dark`, `monokai`, `nord`, etc.) |
|
|
35
|
+
| **Image Inlining Engine** | Resolves local files, remote URLs, Base64 data URIs, and SVGs into self-contained embedded assets |
|
|
36
|
+
| **Signatures & Approvals** | Multi-signatory approval blocks with customizable alignment, border styles, and signature images |
|
|
37
|
+
| **Live-Reload Preview Server** | Real-time HTTP preview server (`--serve`) with Server-Sent Events (SSE) and scroll sync |
|
|
38
|
+
| **Windows Corporate Compliance** | Native Microsoft Edge detection, clean isolated process arguments, and `windowsHide` support |
|
|
39
|
+
| **Type-Safe Config** | `markforge.config.ts` with Enums, `.markforgerc.json`, or YAML with JSON Schema |
|
|
40
|
+
| **Programmatic API** | High-level `compileMarkdown()` and low-level AST document builders for Node.js and Bun |
|
|
41
|
+
| **Ink Terminal UI** | Interactive TUI with live progress tracking, timers, and compilation metrics |
|
|
33
42
|
|
|
34
43
|
---
|
|
35
44
|
|
|
36
|
-
##
|
|
45
|
+
## Installation
|
|
37
46
|
|
|
38
47
|
```bash
|
|
39
48
|
# Global CLI Installation
|
|
@@ -49,7 +58,7 @@ bun add -d @masumdev/markforge
|
|
|
49
58
|
|
|
50
59
|
---
|
|
51
60
|
|
|
52
|
-
##
|
|
61
|
+
## CLI Usage
|
|
53
62
|
|
|
54
63
|
```bash
|
|
55
64
|
# Basic conversion to DOCX and PDF (defaults)
|
|
@@ -58,8 +67,8 @@ markforge document.md
|
|
|
58
67
|
# Specify target formats and output folder
|
|
59
68
|
markforge document.md --to docx,pdf,html -o ./dist
|
|
60
69
|
|
|
61
|
-
# Use custom
|
|
62
|
-
markforge specification.md
|
|
70
|
+
# Use custom configuration file
|
|
71
|
+
markforge specification.md -c ./markforge.config.ts
|
|
63
72
|
|
|
64
73
|
# Watch mode for live re-compilation
|
|
65
74
|
markforge report.md --watch
|
|
@@ -76,7 +85,7 @@ markforge document.md --serve --port 4000 --open
|
|
|
76
85
|
| `--to <formats...>` | `-t` | Output formats: `docx`, `pdf`, `html`, `png` | `docx,pdf` |
|
|
77
86
|
| `--output <dir>` | `-o` | Output directory | Same as input file |
|
|
78
87
|
| `--config <file>` | `-c` | Explicit configuration file path | Auto-discovered |
|
|
79
|
-
| `--theme <name>` | | Visual theme preset (`corporate`, `default`) | `corporate` |
|
|
88
|
+
| `--theme <name>` | | Visual theme preset (`corporate`, `default`, `academic`, `github`, `minimal`) | `corporate` |
|
|
80
89
|
| `--css <files...>` | | Custom CSS stylesheets to inject | `undefined` |
|
|
81
90
|
| `--orientation <type>` | | Page orientation (`portrait`, `landscape`) | `portrait` |
|
|
82
91
|
| `--paper-size <size>` | | Standard paper size (`A4`, `Letter`, `Legal`, `A3`, `A5`) | `A4` |
|
|
@@ -92,9 +101,9 @@ markforge document.md --serve --port 4000 --open
|
|
|
92
101
|
|
|
93
102
|
---
|
|
94
103
|
|
|
95
|
-
##
|
|
104
|
+
## Configuration (`markforge.config.ts`)
|
|
96
105
|
|
|
97
|
-
MarkForge supports type-safe configuration with
|
|
106
|
+
MarkForge supports type-safe configuration with TypeScript Enums:
|
|
98
107
|
|
|
99
108
|
```typescript
|
|
100
109
|
import {
|
|
@@ -104,24 +113,23 @@ import {
|
|
|
104
113
|
Orientation,
|
|
105
114
|
PaperSizeEnum,
|
|
106
115
|
SyntaxTheme,
|
|
107
|
-
|
|
116
|
+
SignatureAlign,
|
|
117
|
+
SignatureStyle,
|
|
108
118
|
} from "@masumdev/markforge";
|
|
109
119
|
|
|
110
120
|
export default defineConfig({
|
|
111
121
|
// Target output formats
|
|
112
122
|
to: [OutputFormat.DOCX, OutputFormat.PDF, OutputFormat.HTML],
|
|
113
123
|
|
|
114
|
-
//
|
|
115
|
-
outputDir: ".temp/output
|
|
124
|
+
// Destination folder
|
|
125
|
+
outputDir: ".temp/output",
|
|
116
126
|
|
|
117
|
-
//
|
|
127
|
+
// Theme preset or custom ThemeProps
|
|
118
128
|
theme: Theme.CORPORATE,
|
|
119
129
|
|
|
120
|
-
// Page
|
|
130
|
+
// Page geometry
|
|
121
131
|
orientation: Orientation.PORTRAIT,
|
|
122
132
|
paperSize: PaperSizeEnum.A4,
|
|
123
|
-
|
|
124
|
-
// Document page margins
|
|
125
133
|
margins: {
|
|
126
134
|
top: "3cm",
|
|
127
135
|
bottom: "2.5cm",
|
|
@@ -129,16 +137,46 @@ export default defineConfig({
|
|
|
129
137
|
right: "2.5cm",
|
|
130
138
|
},
|
|
131
139
|
|
|
132
|
-
//
|
|
140
|
+
// Cover Page Builder
|
|
141
|
+
coverPage: {
|
|
142
|
+
enabled: true,
|
|
143
|
+
preset: "modern",
|
|
144
|
+
logo: "./assets/company-logo.png",
|
|
145
|
+
logoWidth: 140,
|
|
146
|
+
badge: "CONFIDENTIAL SPECIFICATION",
|
|
147
|
+
badgeColor: "#ECFDFD",
|
|
148
|
+
badgeTextColor: "#0D998D",
|
|
149
|
+
footerText: "Proprietary Document - Authorized Personnel Only",
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// Back Cover / Closing Page
|
|
153
|
+
backCover: {
|
|
154
|
+
enabled: true,
|
|
155
|
+
preset: "corporate",
|
|
156
|
+
logo: "./assets/company-logo.png",
|
|
157
|
+
logoWidth: 120,
|
|
158
|
+
title: "Thank You",
|
|
159
|
+
subtitle: "Enterprise Cross-Platform Document Solutions",
|
|
160
|
+
company: "Masum Dev Technologies",
|
|
161
|
+
address: "Jakarta, Indonesia",
|
|
162
|
+
email: "contact@masumdev.com",
|
|
163
|
+
phone: "+62 812 3456 7890",
|
|
164
|
+
website: "https://react-native-library-docs.netlify.app",
|
|
165
|
+
social: {
|
|
166
|
+
github: "https://github.com/masumrpg",
|
|
167
|
+
},
|
|
168
|
+
copyright: "Copyright (c) {year} {company}. All Rights Reserved.",
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// Running headers with per-zone styling & tokens
|
|
133
172
|
header: {
|
|
134
173
|
left: {
|
|
135
174
|
text: "{company} - {title}",
|
|
136
175
|
color: "#0D998D",
|
|
137
176
|
fontSize: 9,
|
|
138
|
-
fontFamily: "Inter, Segoe UI, sans-serif",
|
|
139
177
|
bold: true,
|
|
140
178
|
},
|
|
141
|
-
center: "
|
|
179
|
+
center: "Technical Specification",
|
|
142
180
|
right: {
|
|
143
181
|
text: "v{version}",
|
|
144
182
|
color: "#94A3B8",
|
|
@@ -149,7 +187,7 @@ export default defineConfig({
|
|
|
149
187
|
dividerColor: "#CBD5E1",
|
|
150
188
|
},
|
|
151
189
|
|
|
152
|
-
// Running footers with dynamic page
|
|
190
|
+
// Running footers with dynamic page numbers
|
|
153
191
|
footer: {
|
|
154
192
|
left: {
|
|
155
193
|
text: "Author: {author}",
|
|
@@ -172,158 +210,147 @@ export default defineConfig({
|
|
|
172
210
|
dividerColor: "#CBD5E1",
|
|
173
211
|
},
|
|
174
212
|
|
|
175
|
-
//
|
|
213
|
+
// Table of Contents & Heading Numbering
|
|
176
214
|
toc: true,
|
|
215
|
+
tocTitle: "TABLE OF CONTENTS",
|
|
216
|
+
tocDepth: 3,
|
|
217
|
+
numberHeadings: {
|
|
218
|
+
enabled: true,
|
|
219
|
+
depth: 3,
|
|
220
|
+
skipH1: false,
|
|
221
|
+
},
|
|
177
222
|
|
|
178
|
-
//
|
|
223
|
+
// Math equation rendering
|
|
224
|
+
math: true,
|
|
225
|
+
|
|
226
|
+
// PDF Document Security & AES-256 Encryption
|
|
227
|
+
security: {
|
|
228
|
+
userPassword: "masumdev_secret", // Password required to open document
|
|
229
|
+
ownerPassword: "masumdev_admin", // Master password to edit permissions
|
|
230
|
+
permissions: {
|
|
231
|
+
printing: "highResolution",
|
|
232
|
+
modifying: false,
|
|
233
|
+
copying: true,
|
|
234
|
+
annotating: true,
|
|
235
|
+
fillingForms: true,
|
|
236
|
+
contentAccessibility: true,
|
|
237
|
+
documentAssembly: false,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
// Unselectable diagonal watermark
|
|
179
242
|
watermark: {
|
|
180
243
|
text: "CONFIDENTIAL DRAFT",
|
|
181
244
|
color: "#E11D48",
|
|
182
245
|
opacity: 0.1,
|
|
183
246
|
fontSize: 52,
|
|
184
247
|
rotate: -45,
|
|
185
|
-
position: WatermarkPosition.DIAGONAL,
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
// Syntax highlighting theme
|
|
189
|
-
syntaxTheme: SyntaxTheme.DRACULA,
|
|
190
|
-
|
|
191
|
-
// Asset embedding & bundling flags
|
|
192
|
-
embedImages: true,
|
|
193
|
-
bundleHtml: true,
|
|
194
|
-
|
|
195
|
-
// Global document metadata
|
|
196
|
-
metadata: {
|
|
197
|
-
title: "Unified Platform Architecture & Document Suite",
|
|
198
|
-
subtitle: "Enterprise Specification & Feature Validation Guide",
|
|
199
|
-
author: "Ma'sum",
|
|
200
|
-
company: "Masum Dev Technologies",
|
|
201
|
-
version: "1.0.0",
|
|
202
|
-
date: "2026-08-29",
|
|
203
|
-
lang: "en",
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Custom Theme Customization (`ThemeProps`)
|
|
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
248
|
},
|
|
232
|
-
});
|
|
233
|
-
```
|
|
234
249
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
## Signatures & Approval Blocks (`signatures`)
|
|
238
|
-
|
|
239
|
-
Add formal signature sign-offs (*Lembar Pengesahan / Tanda Tangan*) with 1-4 slots:
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
export default defineConfig({
|
|
250
|
+
// Document signatures and approval block
|
|
243
251
|
signatures: {
|
|
244
|
-
align:
|
|
245
|
-
style:
|
|
246
|
-
|
|
252
|
+
align: SignatureAlign.SPACE_BETWEEN,
|
|
253
|
+
style: SignatureStyle.BOX,
|
|
254
|
+
spacingBefore: "2.5cm",
|
|
247
255
|
items: [
|
|
248
256
|
{
|
|
249
|
-
title: "Prepared
|
|
257
|
+
title: "Prepared By",
|
|
250
258
|
name: "{author}",
|
|
251
|
-
role: "
|
|
259
|
+
role: "Principal Mobile Architect",
|
|
252
260
|
date: "{date}",
|
|
253
261
|
},
|
|
254
262
|
{
|
|
255
|
-
title: "Approved
|
|
256
|
-
name: "
|
|
263
|
+
title: "Approved By",
|
|
264
|
+
name: "Enterprise Architecture Board",
|
|
257
265
|
role: "Chief Technology Officer",
|
|
258
266
|
date: "{date}",
|
|
259
267
|
},
|
|
260
268
|
],
|
|
261
269
|
},
|
|
262
|
-
});
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
## Programmatic API
|
|
268
|
-
|
|
269
|
-
### High-Level API (`compileMarkdown` / `markforge`)
|
|
270
270
|
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
// Code syntax highlighting
|
|
272
|
+
syntaxTheme: SyntaxTheme.GITHUB_DARK,
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
to: [OutputFormat.DOCX, OutputFormat.PDF, OutputFormat.HTML],
|
|
276
|
-
outputDir: "./dist",
|
|
277
|
-
toc: true,
|
|
274
|
+
// Fallback metadata dictionary
|
|
278
275
|
metadata: {
|
|
279
|
-
title: "
|
|
280
|
-
author: "Ma'sum",
|
|
276
|
+
title: "Document Reference Manual",
|
|
277
|
+
author: "Ma'sum (@masumrpg)",
|
|
278
|
+
company: "Masum Dev Technologies",
|
|
281
279
|
version: "1.0.0",
|
|
280
|
+
date: "2026-08-30",
|
|
282
281
|
},
|
|
283
282
|
});
|
|
284
|
-
|
|
285
|
-
console.log(`✓ Compiled ${result.files.length} documents in ${result.durationMs}ms:`);
|
|
286
|
-
for (const file of result.files) {
|
|
287
|
-
console.log(` [${file.format.toUpperCase()}] ${file.filePath} (${file.sizeBytes} bytes)`);
|
|
288
|
-
}
|
|
289
283
|
```
|
|
290
284
|
|
|
291
|
-
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Complete Configuration Properties Reference
|
|
288
|
+
|
|
289
|
+
| Property | Type | Default | Description |
|
|
290
|
+
| :--- | :--- | :--- | :--- |
|
|
291
|
+
| `to` | `OutputFormat[]` | `['docx', 'pdf']` | Array of target document formats (`docx`, `pdf`, `html`, `png`) |
|
|
292
|
+
| `outputDir` | `string` | `'.'` | Output destination directory |
|
|
293
|
+
| `clean` | `boolean` | `false` | Remove stale output files in destination directory before compilation |
|
|
294
|
+
| `theme` | `Theme \| ThemeProps` | `Theme.CORPORATE` | Built-in theme preset or custom `ThemeProps` design tokens |
|
|
295
|
+
| `orientation` | `Orientation` | `'portrait'` | Page orientation (`portrait`, `landscape`) |
|
|
296
|
+
| `paperSize` | `PaperSizeEnum` | `'A4'` | Standard paper size (`A4`, `Letter`, `Legal`, `A3`, `A5`) |
|
|
297
|
+
| `margins` | `PageMargins` | `{ top: '2.5cm', ... }` | Page margins with units (`cm`, `mm`, `in`, `pt`) |
|
|
298
|
+
| `header` | `HeaderFooterConfig` | `undefined` | Header configuration with slots (`left`, `center`, `right`) and divider |
|
|
299
|
+
| `footer` | `HeaderFooterConfig` | `undefined` | Footer configuration with slots (`left`, `center`, `right`) and divider |
|
|
300
|
+
| `toc` | `boolean` | `true` | Generate automated Table of Contents |
|
|
301
|
+
| `tocTitle` | `string` | `'TABLE OF CONTENTS'`| Header title for the Table of Contents |
|
|
302
|
+
| `tocDepth` | `number` | `3` | Maximum heading level included in Table of Contents (1 to 6) |
|
|
303
|
+
| `numberHeadings` | `boolean \| object` | `false` | Automated hierarchical decimal numbering for headings (`1.`, `1.1.`, etc.) |
|
|
304
|
+
| `coverPage` | `boolean \| object` | `false` | Isolated front cover page builder with presets and company logo |
|
|
305
|
+
| `backCover` | `boolean \| object` | `false` | Isolated closing back cover page builder with corporate contact info |
|
|
306
|
+
| `signatures` | `object` | `undefined` | Formal multi-signatory approval and signing block |
|
|
307
|
+
| `math` | `boolean` | `false` | KaTeX LaTeX math equation rendering (`$inline$` and `$$block$$`) |
|
|
308
|
+
| `security` | `object` | `undefined` | ISO 32000-2 AES-256 PDF encryption, user/owner passwords, and permissions |
|
|
309
|
+
| `watermark` | `string \| object` | `undefined` | 100% unselectable diagonal watermark configuration |
|
|
310
|
+
| `syntaxTheme` | `SyntaxTheme` | `'github-dark'` | Code syntax highlighting color palette |
|
|
311
|
+
| `css` | `string \| string[]` | `undefined` | Custom CSS files to inject |
|
|
312
|
+
| `customCss` | `string` | `undefined` | Raw CSS string injected directly into the document head |
|
|
313
|
+
| `breakBeforeHeadings` | `number[]` | `[1]` | Heading levels that trigger an automatic page break (`1` = H1) |
|
|
314
|
+
| `embedImages` | `boolean` | `true` | Base64-encode and inline all remote and local images |
|
|
315
|
+
| `metadata` | `object` | `{}` | Document metadata dictionary for dynamic `{token}` interpolation |
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Programmatic API
|
|
320
|
+
|
|
321
|
+
MarkForge provides both high-level compilation functions and low-level AST builders:
|
|
292
322
|
|
|
293
323
|
```typescript
|
|
294
|
-
import * as fs from "node:fs";
|
|
295
324
|
import {
|
|
296
|
-
|
|
325
|
+
compileMarkdown,
|
|
326
|
+
parseMarkdown,
|
|
297
327
|
buildDocxDocument,
|
|
298
328
|
buildPdfDocument,
|
|
299
329
|
buildHtmlDocument,
|
|
300
330
|
Theme,
|
|
301
331
|
} from "@masumdev/markforge";
|
|
302
332
|
|
|
303
|
-
|
|
333
|
+
// High-level compilation to disk
|
|
334
|
+
const result = await compileMarkdown("./document.md", {
|
|
335
|
+
to: ["docx", "pdf", "html"],
|
|
336
|
+
outputDir: "./dist",
|
|
337
|
+
theme: Theme.CORPORATE,
|
|
338
|
+
});
|
|
304
339
|
|
|
305
|
-
|
|
306
|
-
|
|
340
|
+
console.log("Compiled files:", result.outputFiles);
|
|
341
|
+
console.log("Duration:", result.durationMs, "ms");
|
|
307
342
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const docxBuffer = await buildDocxDocument(doc, config);
|
|
316
|
-
const pdfBuffer = await buildPdfDocument(doc, config);
|
|
317
|
-
const htmlString = await buildHtmlDocument(doc, config);
|
|
318
|
-
|
|
319
|
-
// 3. Write output files
|
|
320
|
-
fs.writeFileSync("./dist/report.docx", docxBuffer);
|
|
321
|
-
fs.writeFileSync("./dist/report.pdf", pdfBuffer);
|
|
322
|
-
fs.writeFileSync("./dist/report.html", htmlString, "utf-8");
|
|
343
|
+
// Low-level in-memory AST compilation
|
|
344
|
+
const rawMarkdown = "# Executive Summary\n\nHigh-performance document engine.";
|
|
345
|
+
const doc = parseMarkdown(rawMarkdown);
|
|
346
|
+
|
|
347
|
+
const docxBuffer = await buildDocxDocument(doc, { theme: Theme.CORPORATE });
|
|
348
|
+
const pdfBuffer = await buildPdfDocument(doc, { theme: Theme.CORPORATE });
|
|
349
|
+
const htmlString = await buildHtmlDocument(doc, { theme: Theme.CORPORATE });
|
|
323
350
|
```
|
|
324
351
|
|
|
325
352
|
---
|
|
326
353
|
|
|
327
354
|
## License
|
|
328
355
|
|
|
329
|
-
MIT
|
|
356
|
+
MIT License. Designed and maintained by **Ma'sum** ([@masumrpg](https://github.com/masumrpg)).
|