@masumdev/markforge 0.2.3 → 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 +204 -213
- package/dist/{App-DKCNXX3Z.mjs → App-GNRUPFM7.mjs} +900 -324
- package/dist/chunk-IYGPJIK5.mjs +165 -0
- package/dist/cli.mjs +9 -6
- package/dist/index.d.mts +310 -63
- package/dist/index.d.ts +310 -63
- package/dist/index.js +1146 -435
- package/dist/index.mjs +1134 -436
- package/dist/{loadConfig-T4ZV6YY2.mjs → loadConfig-PD6ENMAM.mjs} +1 -1
- package/package.json +1 -1
- package/schema.json +221 -28
- package/dist/chunk-ASXSHC6H.mjs +0 -120
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masumdev/markforge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Modern, high-performance Markdown & MDX multi-format document publishing engine and CLI (DOCX, PDF, HTML, and Images) with embedded HTML/CSS, image inliner, and Ink terminal UI.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
package/schema.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"title": "MarkforgeConfig",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Type-safe configuration schema for @masumdev/markforge Markdown & MDX document publishing engine",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
7
|
"$schema": {
|
|
8
8
|
"type": "string",
|
|
9
|
-
"description": "JSON
|
|
9
|
+
"description": "JSON Schema reference URI for IDE autocompletion and validation"
|
|
10
10
|
},
|
|
11
11
|
"to": {
|
|
12
|
-
"description": "Target formats to compile markdown to",
|
|
12
|
+
"description": "Target formats to compile markdown to (docx, pdf, html, png)",
|
|
13
13
|
"oneOf": [
|
|
14
14
|
{
|
|
15
15
|
"type": "string",
|
|
@@ -27,73 +27,266 @@
|
|
|
27
27
|
},
|
|
28
28
|
"outputDir": {
|
|
29
29
|
"type": "string",
|
|
30
|
-
"description": "Output directory
|
|
30
|
+
"description": "Output directory where compiled documents will be saved"
|
|
31
31
|
},
|
|
32
32
|
"theme": {
|
|
33
|
-
"
|
|
34
|
-
"description": "Visual document theme",
|
|
35
|
-
"enum": ["default", "academic", "github", "corporate", "minimal", "dracula"],
|
|
36
|
-
"default": "default"
|
|
37
|
-
},
|
|
38
|
-
"css": {
|
|
39
|
-
"description": "Custom CSS stylesheet(s) to inject",
|
|
33
|
+
"description": "Visual document theme (preset 'corporate' or custom ThemeProps object)",
|
|
40
34
|
"oneOf": [
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
{
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": ["corporate", "default"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"primaryColor": { "type": "string" },
|
|
43
|
+
"primaryDark": { "type": "string" },
|
|
44
|
+
"primaryLight": { "type": "string" },
|
|
45
|
+
"backgroundColor": { "type": "string" },
|
|
46
|
+
"textColor": { "type": "string" },
|
|
47
|
+
"textMuted": { "type": "string" },
|
|
48
|
+
"borderColor": { "type": "string" },
|
|
49
|
+
"cardBackground": { "type": "string" },
|
|
50
|
+
"codeBackground": { "type": "string" },
|
|
51
|
+
"codeText": { "type": "string" },
|
|
52
|
+
"fontFamily": { "type": "string" },
|
|
53
|
+
"fontMono": { "type": "string" },
|
|
54
|
+
"customCss": { "type": "string" }
|
|
55
|
+
},
|
|
56
|
+
"additionalProperties": false
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"default": "corporate"
|
|
44
60
|
},
|
|
45
61
|
"orientation": {
|
|
46
62
|
"type": "string",
|
|
63
|
+
"description": "Page orientation for PDF and DOCX",
|
|
47
64
|
"enum": ["portrait", "landscape"],
|
|
48
65
|
"default": "portrait"
|
|
49
66
|
},
|
|
50
67
|
"paperSize": {
|
|
51
68
|
"type": "string",
|
|
69
|
+
"description": "Standard physical paper size",
|
|
52
70
|
"enum": ["A4", "Letter", "Legal", "A3", "A5"],
|
|
53
71
|
"default": "A4"
|
|
54
72
|
},
|
|
55
73
|
"margins": {
|
|
56
74
|
"type": "object",
|
|
75
|
+
"description": "Document page margins (supports units like '2.5cm', '1in', '20mm', or pt numbers)",
|
|
57
76
|
"properties": {
|
|
58
77
|
"top": { "type": ["string", "number"] },
|
|
59
78
|
"bottom": { "type": ["string", "number"] },
|
|
60
79
|
"left": { "type": ["string", "number"] },
|
|
61
80
|
"right": { "type": ["string", "number"] }
|
|
62
|
-
}
|
|
81
|
+
},
|
|
82
|
+
"additionalProperties": false
|
|
63
83
|
},
|
|
64
84
|
"header": {
|
|
65
85
|
"type": "object",
|
|
86
|
+
"description": "Running header template across document pages (supports {title}, {subtitle}, {author}, {version}, {date}, {company})",
|
|
66
87
|
"properties": {
|
|
67
|
-
"left": {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
"left": {
|
|
89
|
+
"oneOf": [
|
|
90
|
+
{ "type": "string" },
|
|
91
|
+
{
|
|
92
|
+
"type": "object",
|
|
93
|
+
"properties": {
|
|
94
|
+
"text": { "type": "string" },
|
|
95
|
+
"color": { "type": "string" },
|
|
96
|
+
"fontSize": { "type": "number" },
|
|
97
|
+
"fontFamily": { "type": "string" },
|
|
98
|
+
"bold": { "type": "boolean" },
|
|
99
|
+
"italic": { "type": "boolean" }
|
|
100
|
+
},
|
|
101
|
+
"required": ["text"],
|
|
102
|
+
"additionalProperties": false
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"center": {
|
|
107
|
+
"oneOf": [
|
|
108
|
+
{ "type": "string" },
|
|
109
|
+
{
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": {
|
|
112
|
+
"text": { "type": "string" },
|
|
113
|
+
"color": { "type": "string" },
|
|
114
|
+
"fontSize": { "type": "number" },
|
|
115
|
+
"fontFamily": { "type": "string" },
|
|
116
|
+
"bold": { "type": "boolean" },
|
|
117
|
+
"italic": { "type": "boolean" }
|
|
118
|
+
},
|
|
119
|
+
"required": ["text"],
|
|
120
|
+
"additionalProperties": false
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"right": {
|
|
125
|
+
"oneOf": [
|
|
126
|
+
{ "type": "string" },
|
|
127
|
+
{
|
|
128
|
+
"type": "object",
|
|
129
|
+
"properties": {
|
|
130
|
+
"text": { "type": "string" },
|
|
131
|
+
"color": { "type": "string" },
|
|
132
|
+
"fontSize": { "type": "number" },
|
|
133
|
+
"fontFamily": { "type": "string" },
|
|
134
|
+
"bold": { "type": "boolean" },
|
|
135
|
+
"italic": { "type": "boolean" }
|
|
136
|
+
},
|
|
137
|
+
"required": ["text"],
|
|
138
|
+
"additionalProperties": false
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"divider": { "type": "boolean" },
|
|
143
|
+
"dividerColor": { "type": "string" },
|
|
144
|
+
"font": { "type": "string" },
|
|
145
|
+
"size": { "type": "number" },
|
|
146
|
+
"color": { "type": "string" }
|
|
147
|
+
},
|
|
148
|
+
"additionalProperties": false
|
|
71
149
|
},
|
|
72
150
|
"footer": {
|
|
73
151
|
"type": "object",
|
|
152
|
+
"description": "Running footer template across document pages (supports {page}, {pages}, {title}, {author}, {date})",
|
|
74
153
|
"properties": {
|
|
75
|
-
"left": {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
154
|
+
"left": {
|
|
155
|
+
"oneOf": [
|
|
156
|
+
{ "type": "string" },
|
|
157
|
+
{
|
|
158
|
+
"type": "object",
|
|
159
|
+
"properties": {
|
|
160
|
+
"text": { "type": "string" },
|
|
161
|
+
"color": { "type": "string" },
|
|
162
|
+
"fontSize": { "type": "number" },
|
|
163
|
+
"fontFamily": { "type": "string" },
|
|
164
|
+
"bold": { "type": "boolean" },
|
|
165
|
+
"italic": { "type": "boolean" }
|
|
166
|
+
},
|
|
167
|
+
"required": ["text"],
|
|
168
|
+
"additionalProperties": false
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
"center": {
|
|
173
|
+
"oneOf": [
|
|
174
|
+
{ "type": "string" },
|
|
175
|
+
{
|
|
176
|
+
"type": "object",
|
|
177
|
+
"properties": {
|
|
178
|
+
"text": { "type": "string" },
|
|
179
|
+
"color": { "type": "string" },
|
|
180
|
+
"fontSize": { "type": "number" },
|
|
181
|
+
"fontFamily": { "type": "string" },
|
|
182
|
+
"bold": { "type": "boolean" },
|
|
183
|
+
"italic": { "type": "boolean" }
|
|
184
|
+
},
|
|
185
|
+
"required": ["text"],
|
|
186
|
+
"additionalProperties": false
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
"right": {
|
|
191
|
+
"oneOf": [
|
|
192
|
+
{ "type": "string" },
|
|
193
|
+
{
|
|
194
|
+
"type": "object",
|
|
195
|
+
"properties": {
|
|
196
|
+
"text": { "type": "string" },
|
|
197
|
+
"color": { "type": "string" },
|
|
198
|
+
"fontSize": { "type": "number" },
|
|
199
|
+
"fontFamily": { "type": "string" },
|
|
200
|
+
"bold": { "type": "boolean" },
|
|
201
|
+
"italic": { "type": "boolean" }
|
|
202
|
+
},
|
|
203
|
+
"required": ["text"],
|
|
204
|
+
"additionalProperties": false
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
"divider": { "type": "boolean" },
|
|
209
|
+
"dividerColor": { "type": "string" },
|
|
210
|
+
"font": { "type": "string" },
|
|
211
|
+
"size": { "type": "number" },
|
|
212
|
+
"color": { "type": "string" }
|
|
213
|
+
},
|
|
214
|
+
"additionalProperties": false
|
|
79
215
|
},
|
|
80
216
|
"toc": {
|
|
81
217
|
"type": "boolean",
|
|
82
|
-
"description": "Auto-generate Table of Contents",
|
|
218
|
+
"description": "Auto-generate Table of Contents with page references",
|
|
83
219
|
"default": false
|
|
84
220
|
},
|
|
85
221
|
"watermark": {
|
|
222
|
+
"description": "Watermark configuration across document pages (string or WatermarkOptions object)",
|
|
223
|
+
"oneOf": [
|
|
224
|
+
{ "type": "string" },
|
|
225
|
+
{ "type": "boolean" },
|
|
226
|
+
{
|
|
227
|
+
"type": "object",
|
|
228
|
+
"properties": {
|
|
229
|
+
"text": { "type": "string" },
|
|
230
|
+
"color": { "type": "string" },
|
|
231
|
+
"opacity": { "type": "number" },
|
|
232
|
+
"fontSize": { "type": "number" },
|
|
233
|
+
"rotate": { "type": "number" },
|
|
234
|
+
"position": {
|
|
235
|
+
"type": "string",
|
|
236
|
+
"enum": ["diagonal", "center", "top-right", "bottom-right"]
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"required": ["text"],
|
|
240
|
+
"additionalProperties": false
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
"css": {
|
|
245
|
+
"description": "Custom CSS stylesheet path(s) to inject into the document",
|
|
246
|
+
"oneOf": [
|
|
247
|
+
{ "type": "string" },
|
|
248
|
+
{ "type": "array", "items": { "type": "string" } }
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
"syntaxTheme": {
|
|
86
252
|
"type": "string",
|
|
87
|
-
"description": "
|
|
253
|
+
"description": "Code block syntax highlighting color theme",
|
|
254
|
+
"enum": ["github-dark", "github-light", "dracula", "monokai", "nord"],
|
|
255
|
+
"default": "github-dark"
|
|
256
|
+
},
|
|
257
|
+
"metadata": {
|
|
258
|
+
"type": "object",
|
|
259
|
+
"description": "Default document metadata dictionary (used as fallback if not in markdown frontmatter)",
|
|
260
|
+
"properties": {
|
|
261
|
+
"title": { "type": "string" },
|
|
262
|
+
"subtitle": { "type": "string" },
|
|
263
|
+
"author": {
|
|
264
|
+
"oneOf": [
|
|
265
|
+
{ "type": "string" },
|
|
266
|
+
{ "type": "array", "items": { "type": "string" } }
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
"date": { "type": "string" },
|
|
270
|
+
"version": { "type": "string" },
|
|
271
|
+
"company": { "type": "string" },
|
|
272
|
+
"lang": { "type": "string" },
|
|
273
|
+
"coverPage": { "type": "boolean" }
|
|
274
|
+
},
|
|
275
|
+
"additionalProperties": true
|
|
88
276
|
},
|
|
89
277
|
"embedImages": {
|
|
90
278
|
"type": "boolean",
|
|
91
|
-
"description": "Whether to inline/embed all images",
|
|
279
|
+
"description": "Whether to inline/embed all images as Base64 in outputs",
|
|
280
|
+
"default": true
|
|
281
|
+
},
|
|
282
|
+
"bundleHtml": {
|
|
283
|
+
"type": "boolean",
|
|
284
|
+
"description": "Produce self-contained HTML with embedded styles and scripts",
|
|
92
285
|
"default": true
|
|
93
286
|
},
|
|
94
287
|
"watch": {
|
|
95
288
|
"type": "boolean",
|
|
96
|
-
"description": "Watch mode for
|
|
289
|
+
"description": "Watch mode for re-compilation on source file changes",
|
|
97
290
|
"default": false
|
|
98
291
|
},
|
|
99
292
|
"serve": {
|
|
@@ -108,7 +301,7 @@
|
|
|
108
301
|
},
|
|
109
302
|
"open": {
|
|
110
303
|
"type": "boolean",
|
|
111
|
-
"description": "
|
|
304
|
+
"description": "Automatically open document in browser on compile",
|
|
112
305
|
"default": false
|
|
113
306
|
}
|
|
114
307
|
},
|
package/dist/chunk-ASXSHC6H.mjs
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
try {
|
|
3
|
-
if (typeof globalThis !== "undefined" && (!globalThis.localStorage || typeof globalThis.localStorage.getItem !== "function")) {
|
|
4
|
-
Object.defineProperty(globalThis, "localStorage", {
|
|
5
|
-
value: { getItem: () => null, setItem: () => {}, removeItem: () => {}, clear: () => {}, key: () => null, length: 0 },
|
|
6
|
-
configurable: true, writable: true,
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
} catch {}
|
|
10
|
-
import {
|
|
11
|
-
__require
|
|
12
|
-
} from "./chunk-YZHGBG4N.mjs";
|
|
13
|
-
|
|
14
|
-
// src/config/loadConfig.ts
|
|
15
|
-
import * as fs from "fs";
|
|
16
|
-
import * as path from "path";
|
|
17
|
-
import { pathToFileURL } from "url";
|
|
18
|
-
import * as YAML from "yaml";
|
|
19
|
-
var DEFAULT_CONFIG_FILENAMES = [
|
|
20
|
-
"markforge.config.json",
|
|
21
|
-
".markforgerc.json",
|
|
22
|
-
"markforge.config.yaml",
|
|
23
|
-
"markforge.config.yml",
|
|
24
|
-
".markforgerc.yaml",
|
|
25
|
-
".markforgerc.yml",
|
|
26
|
-
".markforgerc",
|
|
27
|
-
"markforge.config.ts",
|
|
28
|
-
"markforge.config.js",
|
|
29
|
-
"markforge.config.mjs",
|
|
30
|
-
"markforge.config.cjs"
|
|
31
|
-
];
|
|
32
|
-
var DEFAULT_CONFIG = {
|
|
33
|
-
to: ["docx", "pdf"],
|
|
34
|
-
outputDir: void 0,
|
|
35
|
-
theme: "default",
|
|
36
|
-
css: void 0,
|
|
37
|
-
orientation: "portrait",
|
|
38
|
-
paperSize: "A4",
|
|
39
|
-
margins: {
|
|
40
|
-
top: "2.5cm",
|
|
41
|
-
bottom: "2.5cm",
|
|
42
|
-
left: "2.5cm",
|
|
43
|
-
right: "2.5cm"
|
|
44
|
-
},
|
|
45
|
-
header: void 0,
|
|
46
|
-
footer: {
|
|
47
|
-
right: "Page {page} of {pages}"
|
|
48
|
-
},
|
|
49
|
-
toc: false,
|
|
50
|
-
watermark: void 0,
|
|
51
|
-
embedImages: true,
|
|
52
|
-
metadata: void 0,
|
|
53
|
-
watch: false,
|
|
54
|
-
serve: false,
|
|
55
|
-
port: 4e3,
|
|
56
|
-
open: false,
|
|
57
|
-
bundleHtml: true,
|
|
58
|
-
syntaxTheme: "github-dark"
|
|
59
|
-
};
|
|
60
|
-
async function loadConfig(customPath, cwd = process.cwd()) {
|
|
61
|
-
let resolvedPath = null;
|
|
62
|
-
if (customPath) {
|
|
63
|
-
resolvedPath = path.isAbsolute(customPath) ? customPath : path.resolve(cwd, customPath);
|
|
64
|
-
if (!fs.existsSync(resolvedPath)) {
|
|
65
|
-
throw new Error(`Configuration file not found: ${resolvedPath}`);
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
for (const filename of DEFAULT_CONFIG_FILENAMES) {
|
|
69
|
-
const candidate = path.resolve(cwd, filename);
|
|
70
|
-
if (fs.existsSync(candidate)) {
|
|
71
|
-
resolvedPath = candidate;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (!resolvedPath) {
|
|
77
|
-
return {
|
|
78
|
-
config: { ...DEFAULT_CONFIG },
|
|
79
|
-
configPath: null
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const ext = path.extname(resolvedPath).toLowerCase();
|
|
83
|
-
let userConfig = {};
|
|
84
|
-
if (ext === ".json" || resolvedPath.endsWith(".markforgerc")) {
|
|
85
|
-
const raw = fs.readFileSync(resolvedPath, "utf-8");
|
|
86
|
-
userConfig = JSON.parse(raw);
|
|
87
|
-
} else if (ext === ".yaml" || ext === ".yml") {
|
|
88
|
-
const raw = fs.readFileSync(resolvedPath, "utf-8");
|
|
89
|
-
userConfig = YAML.parse(raw);
|
|
90
|
-
} else if (ext === ".ts" || ext === ".js" || ext === ".mjs" || ext === ".cjs") {
|
|
91
|
-
try {
|
|
92
|
-
const fileUrl = pathToFileURL(resolvedPath).href;
|
|
93
|
-
const mod = await import(fileUrl);
|
|
94
|
-
userConfig = mod.default || mod;
|
|
95
|
-
} catch {
|
|
96
|
-
const required = __require(resolvedPath);
|
|
97
|
-
userConfig = required.default || required;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const mergedConfig = {
|
|
101
|
-
...DEFAULT_CONFIG,
|
|
102
|
-
...userConfig,
|
|
103
|
-
margins: {
|
|
104
|
-
...DEFAULT_CONFIG.margins,
|
|
105
|
-
...userConfig.margins
|
|
106
|
-
},
|
|
107
|
-
header: userConfig.header || DEFAULT_CONFIG.header,
|
|
108
|
-
footer: userConfig.footer || DEFAULT_CONFIG.footer,
|
|
109
|
-
metadata: userConfig.metadata
|
|
110
|
-
};
|
|
111
|
-
return {
|
|
112
|
-
config: mergedConfig,
|
|
113
|
-
configPath: resolvedPath
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
DEFAULT_CONFIG,
|
|
119
|
-
loadConfig
|
|
120
|
-
};
|