@masumdev/markforge 0.4.1 → 0.5.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.
- package/README.md +2 -2
- package/dist/App-JOOTPDJN.mjs +847 -0
- package/dist/{chunk-R6DT335C.mjs → chunk-H3ZUUSHP.mjs} +77 -23
- package/dist/cli.mjs +2 -2
- package/dist/index.d.mts +44 -12
- package/dist/index.d.ts +44 -12
- package/dist/index.js +608 -67
- package/dist/index.mjs +595 -61
- package/dist/{previewServer-4EELOUAV.mjs → previewServer-U47WQ5FV.mjs} +1 -1
- package/package.json +1 -1
- package/dist/App-TPDCT2VL.mjs +0 -393
|
@@ -568,6 +568,7 @@ import * as path2 from "path";
|
|
|
568
568
|
// src/core/imageResolver.ts
|
|
569
569
|
import * as fs from "fs";
|
|
570
570
|
import * as path from "path";
|
|
571
|
+
import { fileURLToPath } from "url";
|
|
571
572
|
var memoryImageCache = /* @__PURE__ */ new Map();
|
|
572
573
|
function getMimeType(filePathOrUrl) {
|
|
573
574
|
const clean = filePathOrUrl.split("?")[0].toLowerCase();
|
|
@@ -624,9 +625,19 @@ async function resolveImage(src, baseDir = process.cwd()) {
|
|
|
624
625
|
memoryImageCache.set(cacheKey, resolved2);
|
|
625
626
|
return resolved2;
|
|
626
627
|
}
|
|
627
|
-
let localPath =
|
|
628
|
+
let localPath = src;
|
|
629
|
+
if (src.startsWith("file://")) {
|
|
630
|
+
try {
|
|
631
|
+
localPath = fileURLToPath(src);
|
|
632
|
+
} catch {
|
|
633
|
+
localPath = src;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!path.isAbsolute(localPath)) {
|
|
637
|
+
localPath = path.resolve(baseDir, localPath);
|
|
638
|
+
}
|
|
628
639
|
if (!fs.existsSync(localPath)) {
|
|
629
|
-
const cwdPath = path.resolve(process.cwd(), src);
|
|
640
|
+
const cwdPath = path.resolve(process.cwd(), src.startsWith("file://") ? localPath : src);
|
|
630
641
|
if (fs.existsSync(cwdPath)) {
|
|
631
642
|
localPath = cwdPath;
|
|
632
643
|
} else {
|
|
@@ -2164,7 +2175,7 @@ async function renderBackCoverHtml(backCover, baseDir = process.cwd()) {
|
|
|
2164
2175
|
`;
|
|
2165
2176
|
return { html, css };
|
|
2166
2177
|
}
|
|
2167
|
-
async function buildHtmlDocument(doc, config, baseDir = process.cwd()) {
|
|
2178
|
+
async function buildHtmlDocument(doc, config = {}, baseDir = process.cwd()) {
|
|
2168
2179
|
var _a, _b;
|
|
2169
2180
|
const resolved = resolveDocumentConfig(doc.metadata, config);
|
|
2170
2181
|
const baseThemeCss = generateThemeCss(resolved.theme);
|
|
@@ -2522,8 +2533,11 @@ function escapeXml(str) {
|
|
|
2522
2533
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2523
2534
|
}
|
|
2524
2535
|
function generateWatermarkPngBuffer(chromePath, wm) {
|
|
2525
|
-
const
|
|
2526
|
-
const
|
|
2536
|
+
const tmpId = Math.random().toString(36).substring(2, 9);
|
|
2537
|
+
const tmpDir = os.tmpdir();
|
|
2538
|
+
const tmpHtml = path3.join(tmpDir, `markforge-wm-${tmpId}.html`);
|
|
2539
|
+
const tmpPng = path3.join(tmpDir, `markforge-wm-${tmpId}.png`);
|
|
2540
|
+
const tmpProfile = path3.join(tmpDir, `markforge-wm-prof-${tmpId}`);
|
|
2527
2541
|
try {
|
|
2528
2542
|
const text = escapeXml(wm.text.toUpperCase());
|
|
2529
2543
|
const fontSize = (wm.fontSize || 52) * 1.5;
|
|
@@ -2574,6 +2588,9 @@ function generateWatermarkPngBuffer(chromePath, wm) {
|
|
|
2574
2588
|
chromePath,
|
|
2575
2589
|
[
|
|
2576
2590
|
"--headless=new",
|
|
2591
|
+
`--user-data-dir=${tmpProfile}`,
|
|
2592
|
+
"--no-first-run",
|
|
2593
|
+
"--no-default-browser-check",
|
|
2577
2594
|
"--disable-gpu",
|
|
2578
2595
|
"--disable-sync",
|
|
2579
2596
|
"--disable-extensions",
|
|
@@ -2595,6 +2612,7 @@ function generateWatermarkPngBuffer(chromePath, wm) {
|
|
|
2595
2612
|
try {
|
|
2596
2613
|
if (fs3.existsSync(tmpHtml)) fs3.unlinkSync(tmpHtml);
|
|
2597
2614
|
if (fs3.existsSync(tmpPng)) fs3.unlinkSync(tmpPng);
|
|
2615
|
+
if (fs3.existsSync(tmpProfile)) fs3.rmSync(tmpProfile, { recursive: true, force: true });
|
|
2598
2616
|
} catch {
|
|
2599
2617
|
}
|
|
2600
2618
|
}
|
|
@@ -2610,6 +2628,8 @@ function findChromeExecutable() {
|
|
|
2610
2628
|
const winLocalAppData = process.env.LOCALAPPDATA ?? "";
|
|
2611
2629
|
const winProgramFiles = process.env.PROGRAMFILES ?? "C:\\Program Files";
|
|
2612
2630
|
const winProgramFilesX86 = process.env["PROGRAMFILES(X86)"] ?? "C:\\Program Files (x86)";
|
|
2631
|
+
const winProgramW6432 = process.env.ProgramW6432 ?? "C:\\Program Files";
|
|
2632
|
+
const winUserProfile = process.env.USERPROFILE ?? "";
|
|
2613
2633
|
const candidates = [
|
|
2614
2634
|
// Linux
|
|
2615
2635
|
"/usr/bin/google-chrome",
|
|
@@ -2628,17 +2648,34 @@ function findChromeExecutable() {
|
|
|
2628
2648
|
// Windows — Microsoft Edge (Native Windows 10/11 browser, enterprise whitelist friendly)
|
|
2629
2649
|
`${winProgramFiles}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
2630
2650
|
`${winProgramFilesX86}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
2651
|
+
`${winProgramW6432}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
2631
2652
|
`${winLocalAppData}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
2632
|
-
|
|
2653
|
+
`${winLocalAppData}\\Microsoft\\Edge Dev\\Application\\msedge.exe`,
|
|
2654
|
+
`${winLocalAppData}\\Microsoft\\Edge Beta\\Application\\msedge.exe`,
|
|
2655
|
+
// Windows — Google Chrome & Chrome SxS (Canary)
|
|
2633
2656
|
`${winProgramFiles}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
2634
2657
|
`${winProgramFilesX86}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
2658
|
+
`${winProgramW6432}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
2635
2659
|
`${winLocalAppData}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
2660
|
+
`${winLocalAppData}\\Google\\Chrome SxS\\Application\\chrome.exe`,
|
|
2636
2661
|
// Windows — Brave Browser
|
|
2637
2662
|
`${winProgramFiles}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe`,
|
|
2638
2663
|
`${winProgramFilesX86}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe`,
|
|
2664
|
+
`${winProgramW6432}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe`,
|
|
2639
2665
|
`${winLocalAppData}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe`,
|
|
2640
2666
|
// Windows — Chromium
|
|
2641
|
-
`${winLocalAppData}\\Chromium\\Application\\chrome.exe
|
|
2667
|
+
`${winLocalAppData}\\Chromium\\Application\\chrome.exe`,
|
|
2668
|
+
// Windows — Scoop Package Manager
|
|
2669
|
+
`${winUserProfile}\\scoop\\apps\\googlechrome\\current\\chrome.exe`,
|
|
2670
|
+
`${winUserProfile}\\scoop\\apps\\chromium\\current\\chrome.exe`,
|
|
2671
|
+
`${winUserProfile}\\scoop\\apps\\brave\\current\\brave.exe`,
|
|
2672
|
+
`${winUserProfile}\\scoop\\apps\\msedge\\current\\msedge.exe`,
|
|
2673
|
+
`${winUserProfile}\\scoop\\shims\\chrome.exe`,
|
|
2674
|
+
`${winUserProfile}\\scoop\\shims\\msedge.exe`,
|
|
2675
|
+
// Windows — Chocolatey
|
|
2676
|
+
"C:\\ProgramData\\chocolatey\\bin\\chrome.exe",
|
|
2677
|
+
"C:\\ProgramData\\chocolatey\\bin\\msedge.exe",
|
|
2678
|
+
"C:\\ProgramData\\chocolatey\\bin\\brave.exe"
|
|
2642
2679
|
].filter(Boolean);
|
|
2643
2680
|
for (const candidate of candidates) {
|
|
2644
2681
|
try {
|
|
@@ -2649,13 +2686,15 @@ function findChromeExecutable() {
|
|
|
2649
2686
|
}
|
|
2650
2687
|
}
|
|
2651
2688
|
try {
|
|
2652
|
-
const cmd = isWin ? "where" : "which";
|
|
2653
|
-
const names = isWin ? ["chrome", "msedge", "brave", "google-chrome", "chromium", "chromium-browser"] : ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser", "microsoft-edge", "brave-browser"];
|
|
2689
|
+
const cmd = isWin ? "where.exe" : "which";
|
|
2690
|
+
const names = isWin ? ["chrome.exe", "msedge.exe", "brave.exe", "chrome", "msedge", "brave", "google-chrome", "chromium", "chromium-browser"] : ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser", "microsoft-edge", "brave-browser"];
|
|
2654
2691
|
for (const name of names) {
|
|
2655
|
-
const res = spawnSync(cmd, [name], { encoding: "utf-8" });
|
|
2692
|
+
const res = spawnSync(cmd, [name], { encoding: "utf-8", windowsHide: true });
|
|
2656
2693
|
if (res.status === 0 && res.stdout.trim()) {
|
|
2657
|
-
const
|
|
2658
|
-
|
|
2694
|
+
const lines = res.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
2695
|
+
for (const line of lines) {
|
|
2696
|
+
if (fs3.existsSync(line)) return line;
|
|
2697
|
+
}
|
|
2659
2698
|
}
|
|
2660
2699
|
}
|
|
2661
2700
|
} catch {
|
|
@@ -3003,7 +3042,8 @@ import {
|
|
|
3003
3042
|
ExternalHyperlink,
|
|
3004
3043
|
TabStopType,
|
|
3005
3044
|
PageBreak,
|
|
3006
|
-
NumberFormat
|
|
3045
|
+
NumberFormat,
|
|
3046
|
+
SectionType
|
|
3007
3047
|
} from "docx";
|
|
3008
3048
|
|
|
3009
3049
|
// src/core/mermaid/mermaidRenderer.ts
|
|
@@ -3021,6 +3061,8 @@ async function renderMermaidToPng(mermaidCode, _baseDir = process.cwd()) {
|
|
|
3021
3061
|
const tmpDir = os2.tmpdir();
|
|
3022
3062
|
const tmpHtml = path4.join(tmpDir, `mermaid_${tmpId}.html`);
|
|
3023
3063
|
const tmpScreenshot = path4.join(tmpDir, `mermaid_${tmpId}.png`);
|
|
3064
|
+
const tmpProfile = path4.join(tmpDir, `mermaid_prof_${tmpId}`);
|
|
3065
|
+
const isWin = process.platform === "win32";
|
|
3024
3066
|
const htmlContent = `<!DOCTYPE html>
|
|
3025
3067
|
<html>
|
|
3026
3068
|
<head>
|
|
@@ -3064,10 +3106,14 @@ ${mermaidCode}
|
|
|
3064
3106
|
const res = spawnSync2(
|
|
3065
3107
|
chromePath,
|
|
3066
3108
|
[
|
|
3067
|
-
"--headless",
|
|
3109
|
+
"--headless=new",
|
|
3110
|
+
`--user-data-dir=${tmpProfile}`,
|
|
3111
|
+
"--no-first-run",
|
|
3112
|
+
"--no-default-browser-check",
|
|
3068
3113
|
"--disable-gpu",
|
|
3069
|
-
"--
|
|
3070
|
-
"--disable-
|
|
3114
|
+
"--disable-sync",
|
|
3115
|
+
"--disable-extensions",
|
|
3116
|
+
...isWin ? [] : ["--no-sandbox", "--disable-setuid-sandbox"],
|
|
3071
3117
|
"--allow-file-access-from-files",
|
|
3072
3118
|
"--disable-web-security",
|
|
3073
3119
|
"--disable-software-rasterizer",
|
|
@@ -3076,7 +3122,7 @@ ${mermaidCode}
|
|
|
3076
3122
|
`--screenshot=${tmpScreenshot}`,
|
|
3077
3123
|
fileUrl
|
|
3078
3124
|
],
|
|
3079
|
-
{ timeout: 15e3 }
|
|
3125
|
+
{ timeout: 15e3, windowsHide: true }
|
|
3080
3126
|
);
|
|
3081
3127
|
if (res.status === 0 && fs4.existsSync(tmpScreenshot)) {
|
|
3082
3128
|
const buffer = fs4.readFileSync(tmpScreenshot);
|
|
@@ -3087,6 +3133,7 @@ ${mermaidCode}
|
|
|
3087
3133
|
try {
|
|
3088
3134
|
if (fs4.existsSync(tmpHtml)) fs4.unlinkSync(tmpHtml);
|
|
3089
3135
|
if (fs4.existsSync(tmpScreenshot)) fs4.unlinkSync(tmpScreenshot);
|
|
3136
|
+
if (fs4.existsSync(tmpProfile)) fs4.rmSync(tmpProfile, { recursive: true, force: true });
|
|
3090
3137
|
} catch {
|
|
3091
3138
|
}
|
|
3092
3139
|
}
|
|
@@ -4205,6 +4252,7 @@ async function buildDocxDocument(doc, config, baseDir = process.cwd()) {
|
|
|
4205
4252
|
);
|
|
4206
4253
|
docSections.push({
|
|
4207
4254
|
properties: {
|
|
4255
|
+
type: SectionType.NEXT_PAGE,
|
|
4208
4256
|
page: {
|
|
4209
4257
|
size: {
|
|
4210
4258
|
width: resolved.paperDimensions.widthTwip,
|
|
@@ -4219,13 +4267,14 @@ async function buildDocxDocument(doc, config, baseDir = process.cwd()) {
|
|
|
4219
4267
|
}
|
|
4220
4268
|
}
|
|
4221
4269
|
},
|
|
4222
|
-
headers:
|
|
4223
|
-
footers:
|
|
4270
|
+
headers: { default: new Header({ children: [] }) },
|
|
4271
|
+
footers: { default: new Footer({ children: [] }) },
|
|
4224
4272
|
children: coverElements
|
|
4225
4273
|
});
|
|
4226
4274
|
}
|
|
4227
4275
|
docSections.push({
|
|
4228
4276
|
properties: {
|
|
4277
|
+
type: SectionType.NEXT_PAGE,
|
|
4229
4278
|
page: {
|
|
4230
4279
|
pageNumbers: {
|
|
4231
4280
|
start: 1,
|
|
@@ -4246,8 +4295,8 @@ async function buildDocxDocument(doc, config, baseDir = process.cwd()) {
|
|
|
4246
4295
|
}
|
|
4247
4296
|
}
|
|
4248
4297
|
},
|
|
4249
|
-
headers: docHeader ? { default: docHeader } :
|
|
4250
|
-
footers: docFooter ? { default: docFooter } :
|
|
4298
|
+
headers: docHeader ? { default: docHeader } : { default: new Header({ children: [] }) },
|
|
4299
|
+
footers: docFooter ? { default: docFooter } : { default: new Footer({ children: [] }) },
|
|
4251
4300
|
children: docElements
|
|
4252
4301
|
});
|
|
4253
4302
|
if (resolved.backCover && resolved.backCover.enabled) {
|
|
@@ -4262,6 +4311,7 @@ async function buildDocxDocument(doc, config, baseDir = process.cwd()) {
|
|
|
4262
4311
|
);
|
|
4263
4312
|
docSections.push({
|
|
4264
4313
|
properties: {
|
|
4314
|
+
type: SectionType.NEXT_PAGE,
|
|
4265
4315
|
page: {
|
|
4266
4316
|
size: {
|
|
4267
4317
|
width: resolved.paperDimensions.widthTwip,
|
|
@@ -4276,8 +4326,8 @@ async function buildDocxDocument(doc, config, baseDir = process.cwd()) {
|
|
|
4276
4326
|
}
|
|
4277
4327
|
}
|
|
4278
4328
|
},
|
|
4279
|
-
headers:
|
|
4280
|
-
footers:
|
|
4329
|
+
headers: { default: new Header({ children: [] }) },
|
|
4330
|
+
footers: { default: new Footer({ children: [] }) },
|
|
4281
4331
|
children: backElements
|
|
4282
4332
|
});
|
|
4283
4333
|
}
|
|
@@ -4681,8 +4731,12 @@ function createEmptyDocxCell(widthDxa) {
|
|
|
4681
4731
|
}
|
|
4682
4732
|
|
|
4683
4733
|
export {
|
|
4734
|
+
applyHeadingNumbering,
|
|
4684
4735
|
parseMarkdownDocument,
|
|
4736
|
+
replaceDocumentTokens,
|
|
4737
|
+
resolveDocumentConfig,
|
|
4685
4738
|
buildHtmlDocument,
|
|
4739
|
+
findChromeExecutable,
|
|
4686
4740
|
buildPdfDocument,
|
|
4687
4741
|
buildDocxDocument
|
|
4688
4742
|
};
|
package/dist/cli.mjs
CHANGED
|
@@ -71,7 +71,7 @@ async function main() {
|
|
|
71
71
|
if (options.serve !== false && options.serve !== void 0) {
|
|
72
72
|
const rawPort = options.serve === true ? 3e3 : parseInt(String(options.serve), 10);
|
|
73
73
|
const port = isNaN(rawPort) ? 3e3 : rawPort;
|
|
74
|
-
const { startPreviewServer } = await import("./previewServer-
|
|
74
|
+
const { startPreviewServer } = await import("./previewServer-U47WQ5FV.mjs");
|
|
75
75
|
const instance = await startPreviewServer({
|
|
76
76
|
filePath: resolvedInputPath,
|
|
77
77
|
port,
|
|
@@ -99,7 +99,7 @@ async function main() {
|
|
|
99
99
|
}
|
|
100
100
|
const [{ render }, { App }] = await Promise.all([
|
|
101
101
|
import("ink"),
|
|
102
|
-
import("./App-
|
|
102
|
+
import("./App-JOOTPDJN.mjs")
|
|
103
103
|
]);
|
|
104
104
|
render(
|
|
105
105
|
/* @__PURE__ */ jsx(
|
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,10 @@ declare enum OutputFormat {
|
|
|
4
4
|
DOCX = "docx",
|
|
5
5
|
PDF = "pdf",
|
|
6
6
|
HTML = "html",
|
|
7
|
-
PNG = "png"
|
|
7
|
+
PNG = "png",
|
|
8
|
+
TXT = "txt"
|
|
8
9
|
}
|
|
9
|
-
type MarkforgeFormat = "docx" | "pdf" | "html" | "png" | OutputFormat;
|
|
10
|
+
type MarkforgeFormat = "docx" | "pdf" | "html" | "png" | "txt" | OutputFormat;
|
|
10
11
|
interface ThemeProps {
|
|
11
12
|
/**
|
|
12
13
|
* Primary brand accent color (e.g. "#33CDCF", "#2563EB", "#7C3AED", "#E11D48").
|
|
@@ -238,7 +239,13 @@ interface CoverPageConfig {
|
|
|
238
239
|
*/
|
|
239
240
|
footerText?: string;
|
|
240
241
|
}
|
|
241
|
-
|
|
242
|
+
declare enum BackCoverPreset {
|
|
243
|
+
MODERN = "modern",
|
|
244
|
+
CORPORATE = "corporate",
|
|
245
|
+
MINIMAL = "minimal",
|
|
246
|
+
CONTACT_CARD = "contact-card"
|
|
247
|
+
}
|
|
248
|
+
type BackCoverPresetType = "modern" | "corporate" | "minimal" | "contact-card" | BackCoverPreset;
|
|
242
249
|
interface BackCoverSocial {
|
|
243
250
|
github?: string;
|
|
244
251
|
twitter?: string;
|
|
@@ -260,7 +267,7 @@ interface BackCoverConfig {
|
|
|
260
267
|
* - "contact-card": Floating elevated glassmorphic contact card with full metadata grid.
|
|
261
268
|
* @default "modern"
|
|
262
269
|
*/
|
|
263
|
-
preset?:
|
|
270
|
+
preset?: BackCoverPresetType;
|
|
264
271
|
/**
|
|
265
272
|
* Headline title shown on the back cover.
|
|
266
273
|
* @default "Thank You"
|
|
@@ -405,8 +412,19 @@ interface DocumentMetadata {
|
|
|
405
412
|
backCover?: boolean | BackCoverConfig;
|
|
406
413
|
[key: string]: unknown;
|
|
407
414
|
}
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
declare enum SignatureAlign {
|
|
416
|
+
LEFT = "left",
|
|
417
|
+
CENTER = "center",
|
|
418
|
+
RIGHT = "right",
|
|
419
|
+
SPACE_BETWEEN = "space-between"
|
|
420
|
+
}
|
|
421
|
+
type SignatureAlignOption = "left" | "center" | "right" | "space-between" | SignatureAlign;
|
|
422
|
+
declare enum SignatureStyle {
|
|
423
|
+
LINE = "line",
|
|
424
|
+
BOX = "box",
|
|
425
|
+
CLEAN = "clean"
|
|
426
|
+
}
|
|
427
|
+
type SignatureStyleOption = "line" | "box" | "clean" | SignatureStyle;
|
|
410
428
|
interface SignatureItem {
|
|
411
429
|
/**
|
|
412
430
|
* Title or sign-off label above signature (e.g. "Prepared by", "Approved by", "Acknowledged by").
|
|
@@ -443,7 +461,7 @@ interface SignatureBlockConfig {
|
|
|
443
461
|
* Horizontal alignment of the signature block.
|
|
444
462
|
* @default "right" for 1 item, "space-between" for >= 2 items
|
|
445
463
|
*/
|
|
446
|
-
align?:
|
|
464
|
+
align?: SignatureAlignOption;
|
|
447
465
|
/**
|
|
448
466
|
* Visual layout style of the signature block:
|
|
449
467
|
* - "line": Traditional signature with a horizontal separator line above name.
|
|
@@ -451,7 +469,7 @@ interface SignatureBlockConfig {
|
|
|
451
469
|
* - "clean": Minimalist blank vertical space without borders.
|
|
452
470
|
* @default "line"
|
|
453
471
|
*/
|
|
454
|
-
style?:
|
|
472
|
+
style?: SignatureStyleOption;
|
|
455
473
|
/**
|
|
456
474
|
* Border or divider line color.
|
|
457
475
|
* @default "#CBD5E1"
|
|
@@ -766,8 +784,8 @@ interface NormalizedSignatureItem {
|
|
|
766
784
|
}
|
|
767
785
|
interface NormalizedSignatureBlock {
|
|
768
786
|
items: NormalizedSignatureItem[];
|
|
769
|
-
align:
|
|
770
|
-
style:
|
|
787
|
+
align: SignatureAlignOption;
|
|
788
|
+
style: SignatureStyleOption;
|
|
771
789
|
borderColor: string;
|
|
772
790
|
titleColor: string;
|
|
773
791
|
nameColor: string;
|
|
@@ -966,7 +984,7 @@ declare function renderBackCoverHtml(backCover: NormalizedBackCover, baseDir?: s
|
|
|
966
984
|
/**
|
|
967
985
|
* Builds standalone self-contained HTML from a parsed Markdown document.
|
|
968
986
|
*/
|
|
969
|
-
declare function buildHtmlDocument(doc: ParsedMarkdownDocument, config
|
|
987
|
+
declare function buildHtmlDocument(doc: ParsedMarkdownDocument, config?: MarkforgeConfig, baseDir?: string): Promise<string>;
|
|
970
988
|
|
|
971
989
|
/**
|
|
972
990
|
* Finds available Chrome or Chromium binary for headless PDF rendering.
|
|
@@ -981,6 +999,20 @@ declare function injectPagedMediaStyles(html: string, config: MarkforgeConfig, m
|
|
|
981
999
|
*/
|
|
982
1000
|
declare function buildPdfDocument(doc: ParsedMarkdownDocument, config: MarkforgeConfig, baseDir?: string): Promise<Buffer>;
|
|
983
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* Converts inline AST spans into clean, readable plain text.
|
|
1004
|
+
*/
|
|
1005
|
+
declare function renderInlinesToText(spans?: MarkdownInlineSpan[], meta?: Record<string, unknown>): string;
|
|
1006
|
+
/**
|
|
1007
|
+
* Builds a structured, beautifully formatted plain text (.txt) document from markdown AST.
|
|
1008
|
+
*/
|
|
1009
|
+
declare function buildTextDocument(doc: ParsedMarkdownDocument, config?: MarkforgeConfig, _baseDir?: string): Promise<string>;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Builds a high-resolution PNG document image buffer using headless Chromium screenshot.
|
|
1013
|
+
*/
|
|
1014
|
+
declare function buildPngDocument(doc: ParsedMarkdownDocument, config?: MarkforgeConfig, baseDir?: string): Promise<Buffer>;
|
|
1015
|
+
|
|
984
1016
|
interface ResolvedImage {
|
|
985
1017
|
src: string;
|
|
986
1018
|
buffer: Buffer;
|
|
@@ -1114,4 +1146,4 @@ declare const MARKFORGE_VERSION: string;
|
|
|
1114
1146
|
*/
|
|
1115
1147
|
declare function getMarkforgeVersion(fromDir?: string): string;
|
|
1116
1148
|
|
|
1117
|
-
export { type BackCoverConfig, type
|
|
1149
|
+
export { type BackCoverConfig, BackCoverPreset, type BackCoverPresetType, type BackCoverSocial, type CompilationResult, type CoverPageConfig, CoverPagePreset, type CoverPreset, DEFAULT_CONFIG, type DocumentLayoutConfig, type DocumentMetadata, type DocumentOrientation, type FootnoteDefinition, type FrontmatterMetadata, type GeneratedOutputFile, type HeaderFooterItem, type HeaderFooterSlot, KATEX_INLINE_CSS, MARKFORGE_VERSION, type MarkdownASTNode, type MarkdownInlineSpan, type MarkdownNodeType, type MarkforgeConfig, type MarkforgeFormat, type MarkforgeTheme, type NormalizedBackCover, type NormalizedCoverPage, type NormalizedHeaderFooter, type NormalizedHeaderFooterZone, type NormalizedMargins, type NormalizedNumberHeadings, type NormalizedSecurity, type NormalizedSignatureBlock, type NormalizedSignatureItem, type NormalizedWatermark, type NumberHeadingsConfig, Orientation, OutputFormat, PAPER_DIMENSIONS_TWIP, type PageMargins, type PaperSize, PaperSizeEnum, type ParsedMarkdownDocument, type PdfPermissions, type PreviewServerInstance, type PreviewServerOptions, type ResolvedDocumentConfig, type ResolvedImage, SYNTAX_COLORS, type SecurityConfig, SignatureAlign, type SignatureAlignOption, type SignatureBlockConfig, type SignatureItem, SignatureStyle, type SignatureStyleOption, SyntaxTheme, type SyntaxToken, THEMES, THEME_CORPORATE, THEME_DEFAULT, Theme, type ThemeProps, type WatermarkOptions, WatermarkPosition, applyHeadingNumbering, buildDocxDocument, buildHtmlDocument, buildPdfDocument, buildPngDocument, buildTextDocument, buildTextDocument as buildTxtDocument, compileMarkdown, defineConfig, escapeHtml, findChromeExecutable, formatServerTimestamp, generateThemeCss, getMarkforgeVersion, getMimeType, highlightCodeToHtml, injectPagedMediaStyles, inlineHtmlImages, loadConfig, compileMarkdown as markforge, normalizeBackCover, normalizeCoverPage, normalizeHeaderFooter, normalizeHeaderFooterSlot, normalizeNumberHeadings, normalizeSecurity, normalizeSignatures, normalizeWatermark, parseInlineSpans, parseMarginToTwip, parseMarkdownDocument as parseMarkdown, parseMarkdownDocument, renderBackCoverHtml, renderCoverPageHtml, renderInlinesToHtml, renderInlinesToText, renderMathToHtml, renderMermaidToPng, renderNodesToHtml, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, startPreviewServer, tokenizeCodeLine };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ declare enum OutputFormat {
|
|
|
4
4
|
DOCX = "docx",
|
|
5
5
|
PDF = "pdf",
|
|
6
6
|
HTML = "html",
|
|
7
|
-
PNG = "png"
|
|
7
|
+
PNG = "png",
|
|
8
|
+
TXT = "txt"
|
|
8
9
|
}
|
|
9
|
-
type MarkforgeFormat = "docx" | "pdf" | "html" | "png" | OutputFormat;
|
|
10
|
+
type MarkforgeFormat = "docx" | "pdf" | "html" | "png" | "txt" | OutputFormat;
|
|
10
11
|
interface ThemeProps {
|
|
11
12
|
/**
|
|
12
13
|
* Primary brand accent color (e.g. "#33CDCF", "#2563EB", "#7C3AED", "#E11D48").
|
|
@@ -238,7 +239,13 @@ interface CoverPageConfig {
|
|
|
238
239
|
*/
|
|
239
240
|
footerText?: string;
|
|
240
241
|
}
|
|
241
|
-
|
|
242
|
+
declare enum BackCoverPreset {
|
|
243
|
+
MODERN = "modern",
|
|
244
|
+
CORPORATE = "corporate",
|
|
245
|
+
MINIMAL = "minimal",
|
|
246
|
+
CONTACT_CARD = "contact-card"
|
|
247
|
+
}
|
|
248
|
+
type BackCoverPresetType = "modern" | "corporate" | "minimal" | "contact-card" | BackCoverPreset;
|
|
242
249
|
interface BackCoverSocial {
|
|
243
250
|
github?: string;
|
|
244
251
|
twitter?: string;
|
|
@@ -260,7 +267,7 @@ interface BackCoverConfig {
|
|
|
260
267
|
* - "contact-card": Floating elevated glassmorphic contact card with full metadata grid.
|
|
261
268
|
* @default "modern"
|
|
262
269
|
*/
|
|
263
|
-
preset?:
|
|
270
|
+
preset?: BackCoverPresetType;
|
|
264
271
|
/**
|
|
265
272
|
* Headline title shown on the back cover.
|
|
266
273
|
* @default "Thank You"
|
|
@@ -405,8 +412,19 @@ interface DocumentMetadata {
|
|
|
405
412
|
backCover?: boolean | BackCoverConfig;
|
|
406
413
|
[key: string]: unknown;
|
|
407
414
|
}
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
declare enum SignatureAlign {
|
|
416
|
+
LEFT = "left",
|
|
417
|
+
CENTER = "center",
|
|
418
|
+
RIGHT = "right",
|
|
419
|
+
SPACE_BETWEEN = "space-between"
|
|
420
|
+
}
|
|
421
|
+
type SignatureAlignOption = "left" | "center" | "right" | "space-between" | SignatureAlign;
|
|
422
|
+
declare enum SignatureStyle {
|
|
423
|
+
LINE = "line",
|
|
424
|
+
BOX = "box",
|
|
425
|
+
CLEAN = "clean"
|
|
426
|
+
}
|
|
427
|
+
type SignatureStyleOption = "line" | "box" | "clean" | SignatureStyle;
|
|
410
428
|
interface SignatureItem {
|
|
411
429
|
/**
|
|
412
430
|
* Title or sign-off label above signature (e.g. "Prepared by", "Approved by", "Acknowledged by").
|
|
@@ -443,7 +461,7 @@ interface SignatureBlockConfig {
|
|
|
443
461
|
* Horizontal alignment of the signature block.
|
|
444
462
|
* @default "right" for 1 item, "space-between" for >= 2 items
|
|
445
463
|
*/
|
|
446
|
-
align?:
|
|
464
|
+
align?: SignatureAlignOption;
|
|
447
465
|
/**
|
|
448
466
|
* Visual layout style of the signature block:
|
|
449
467
|
* - "line": Traditional signature with a horizontal separator line above name.
|
|
@@ -451,7 +469,7 @@ interface SignatureBlockConfig {
|
|
|
451
469
|
* - "clean": Minimalist blank vertical space without borders.
|
|
452
470
|
* @default "line"
|
|
453
471
|
*/
|
|
454
|
-
style?:
|
|
472
|
+
style?: SignatureStyleOption;
|
|
455
473
|
/**
|
|
456
474
|
* Border or divider line color.
|
|
457
475
|
* @default "#CBD5E1"
|
|
@@ -766,8 +784,8 @@ interface NormalizedSignatureItem {
|
|
|
766
784
|
}
|
|
767
785
|
interface NormalizedSignatureBlock {
|
|
768
786
|
items: NormalizedSignatureItem[];
|
|
769
|
-
align:
|
|
770
|
-
style:
|
|
787
|
+
align: SignatureAlignOption;
|
|
788
|
+
style: SignatureStyleOption;
|
|
771
789
|
borderColor: string;
|
|
772
790
|
titleColor: string;
|
|
773
791
|
nameColor: string;
|
|
@@ -966,7 +984,7 @@ declare function renderBackCoverHtml(backCover: NormalizedBackCover, baseDir?: s
|
|
|
966
984
|
/**
|
|
967
985
|
* Builds standalone self-contained HTML from a parsed Markdown document.
|
|
968
986
|
*/
|
|
969
|
-
declare function buildHtmlDocument(doc: ParsedMarkdownDocument, config
|
|
987
|
+
declare function buildHtmlDocument(doc: ParsedMarkdownDocument, config?: MarkforgeConfig, baseDir?: string): Promise<string>;
|
|
970
988
|
|
|
971
989
|
/**
|
|
972
990
|
* Finds available Chrome or Chromium binary for headless PDF rendering.
|
|
@@ -981,6 +999,20 @@ declare function injectPagedMediaStyles(html: string, config: MarkforgeConfig, m
|
|
|
981
999
|
*/
|
|
982
1000
|
declare function buildPdfDocument(doc: ParsedMarkdownDocument, config: MarkforgeConfig, baseDir?: string): Promise<Buffer>;
|
|
983
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* Converts inline AST spans into clean, readable plain text.
|
|
1004
|
+
*/
|
|
1005
|
+
declare function renderInlinesToText(spans?: MarkdownInlineSpan[], meta?: Record<string, unknown>): string;
|
|
1006
|
+
/**
|
|
1007
|
+
* Builds a structured, beautifully formatted plain text (.txt) document from markdown AST.
|
|
1008
|
+
*/
|
|
1009
|
+
declare function buildTextDocument(doc: ParsedMarkdownDocument, config?: MarkforgeConfig, _baseDir?: string): Promise<string>;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Builds a high-resolution PNG document image buffer using headless Chromium screenshot.
|
|
1013
|
+
*/
|
|
1014
|
+
declare function buildPngDocument(doc: ParsedMarkdownDocument, config?: MarkforgeConfig, baseDir?: string): Promise<Buffer>;
|
|
1015
|
+
|
|
984
1016
|
interface ResolvedImage {
|
|
985
1017
|
src: string;
|
|
986
1018
|
buffer: Buffer;
|
|
@@ -1114,4 +1146,4 @@ declare const MARKFORGE_VERSION: string;
|
|
|
1114
1146
|
*/
|
|
1115
1147
|
declare function getMarkforgeVersion(fromDir?: string): string;
|
|
1116
1148
|
|
|
1117
|
-
export { type BackCoverConfig, type
|
|
1149
|
+
export { type BackCoverConfig, BackCoverPreset, type BackCoverPresetType, type BackCoverSocial, type CompilationResult, type CoverPageConfig, CoverPagePreset, type CoverPreset, DEFAULT_CONFIG, type DocumentLayoutConfig, type DocumentMetadata, type DocumentOrientation, type FootnoteDefinition, type FrontmatterMetadata, type GeneratedOutputFile, type HeaderFooterItem, type HeaderFooterSlot, KATEX_INLINE_CSS, MARKFORGE_VERSION, type MarkdownASTNode, type MarkdownInlineSpan, type MarkdownNodeType, type MarkforgeConfig, type MarkforgeFormat, type MarkforgeTheme, type NormalizedBackCover, type NormalizedCoverPage, type NormalizedHeaderFooter, type NormalizedHeaderFooterZone, type NormalizedMargins, type NormalizedNumberHeadings, type NormalizedSecurity, type NormalizedSignatureBlock, type NormalizedSignatureItem, type NormalizedWatermark, type NumberHeadingsConfig, Orientation, OutputFormat, PAPER_DIMENSIONS_TWIP, type PageMargins, type PaperSize, PaperSizeEnum, type ParsedMarkdownDocument, type PdfPermissions, type PreviewServerInstance, type PreviewServerOptions, type ResolvedDocumentConfig, type ResolvedImage, SYNTAX_COLORS, type SecurityConfig, SignatureAlign, type SignatureAlignOption, type SignatureBlockConfig, type SignatureItem, SignatureStyle, type SignatureStyleOption, SyntaxTheme, type SyntaxToken, THEMES, THEME_CORPORATE, THEME_DEFAULT, Theme, type ThemeProps, type WatermarkOptions, WatermarkPosition, applyHeadingNumbering, buildDocxDocument, buildHtmlDocument, buildPdfDocument, buildPngDocument, buildTextDocument, buildTextDocument as buildTxtDocument, compileMarkdown, defineConfig, escapeHtml, findChromeExecutable, formatServerTimestamp, generateThemeCss, getMarkforgeVersion, getMimeType, highlightCodeToHtml, injectPagedMediaStyles, inlineHtmlImages, loadConfig, compileMarkdown as markforge, normalizeBackCover, normalizeCoverPage, normalizeHeaderFooter, normalizeHeaderFooterSlot, normalizeNumberHeadings, normalizeSecurity, normalizeSignatures, normalizeWatermark, parseInlineSpans, parseMarginToTwip, parseMarkdownDocument as parseMarkdown, parseMarkdownDocument, renderBackCoverHtml, renderCoverPageHtml, renderInlinesToHtml, renderInlinesToText, renderMathToHtml, renderMermaidToPng, renderNodesToHtml, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, startPreviewServer, tokenizeCodeLine };
|