@masumdev/markforge 0.4.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.
@@ -32,10 +32,9 @@ try {
32
32
  }
33
33
  } catch {
34
34
  }
35
- var FALLBACK_VERSION = "0.4.0";
36
35
  function readVersionFromPackageJson(fromDir) {
37
36
  let currentDir = fromDir;
38
- for (let i = 0; i < 6; i++) {
37
+ for (let i = 0; i < 10; i++) {
39
38
  try {
40
39
  const pkgJsonPath = path.join(currentDir, "package.json");
41
40
  if (fs.existsSync(pkgJsonPath)) {
@@ -50,7 +49,9 @@ function readVersionFromPackageJson(fromDir) {
50
49
  if (parentDir === currentDir) break;
51
50
  currentDir = parentDir;
52
51
  }
53
- return FALLBACK_VERSION;
52
+ throw new Error(
53
+ "Failed to resolve '@masumdev/markforge' package version: package.json was not found or is missing a valid 'version' field."
54
+ );
54
55
  }
55
56
  function getPackageDir() {
56
57
  if (typeof __dirname !== "undefined") {
package/dist/cli.mjs CHANGED
@@ -9,7 +9,7 @@ try {
9
9
  } catch {}
10
10
  import {
11
11
  MARKFORGE_VERSION
12
- } from "./chunk-TNWZ4MFS.mjs";
12
+ } from "./chunk-UNWAEVDU.mjs";
13
13
  import "./chunk-YZHGBG4N.mjs";
14
14
 
15
15
  // src/cli.tsx
@@ -56,7 +56,7 @@ async function main() {
56
56
  }
57
57
  const cliFormats = options.to ? options.to.split(",").map((f) => f.trim().toLowerCase()).filter(Boolean) : void 0;
58
58
  const { loadConfig } = await import("./loadConfig-PGJKPE6G.mjs");
59
- const { config: fileConfig } = await loadConfig(
59
+ const { config: fileConfig, configPath } = await loadConfig(
60
60
  options.config,
61
61
  path.dirname(resolvedInputPath)
62
62
  );
@@ -71,19 +71,26 @@ 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-XAUOBNBZ.mjs");
74
+ const { startPreviewServer } = await import("./previewServer-4EELOUAV.mjs");
75
75
  const instance = await startPreviewServer({
76
76
  filePath: resolvedInputPath,
77
77
  port,
78
78
  open: Boolean(options.open),
79
79
  config: mergedConfig
80
80
  });
81
+ const themeLabel = typeof mergedConfig.theme === "object" ? "Custom (ThemeProps)" : String(mergedConfig.theme || "corporate");
81
82
  console.log(`
82
83
  ======================================================`);
83
- console.log(` MarkForge Live Reload Preview Server`);
84
+ console.log(` MarkForge Live Reload Preview Server v${MARKFORGE_VERSION}`);
85
+ console.log(`======================================================`);
84
86
  console.log(` Target File : ${resolvedInputPath}`);
87
+ console.log(` Config File : ${configPath || "(default auto-discovery)"}`);
88
+ console.log(` Theme : ${themeLabel} | Syntax: ${mergedConfig.syntaxTheme || "github-dark"}`);
89
+ console.log(` Layout : ${mergedConfig.paperSize || "A4"} (${mergedConfig.orientation || "portrait"})`);
85
90
  console.log(` Server URL : ${instance.url}`);
86
- console.log(` Author : Ma'sum (https://github.com/masumrpg)`);
91
+ console.log(` Auto-Open : ${Boolean(options.open) ? "Enabled" : "Disabled"}`);
92
+ console.log(` Author : Ma'sum (@masumrpg)`);
93
+ console.log(` GitHub : https://github.com/masumrpg`);
87
94
  console.log(`======================================================
88
95
  `);
89
96
  console.log(`[READY] Watching for markdown and style changes. Press Ctrl+C to exit.
@@ -92,7 +99,7 @@ async function main() {
92
99
  }
93
100
  const [{ render }, { App }] = await Promise.all([
94
101
  import("ink"),
95
- import("./App-3QDKBKHG.mjs")
102
+ import("./App-TPDCT2VL.mjs")
96
103
  ]);
97
104
  render(
98
105
  /* @__PURE__ */ jsx(
@@ -100,6 +107,7 @@ async function main() {
100
107
  {
101
108
  inputFile: resolvedInputPath,
102
109
  config: mergedConfig,
110
+ configPath,
103
111
  onComplete: (res) => {
104
112
  if (res.errors && res.errors.length > 0) {
105
113
  process.exitCode = 1;
package/dist/index.d.mts CHANGED
@@ -216,10 +216,23 @@ interface CoverPageConfig {
216
216
  * Custom background color or CSS gradient for the cover page.
217
217
  */
218
218
  bgGradient?: string;
219
+ backgroundColor?: string;
219
220
  /**
220
- * Custom text color for cover typography.
221
+ * Custom typography colors.
221
222
  */
222
223
  textColor?: string;
224
+ titleColor?: string;
225
+ subtitleColor?: string;
226
+ accentColor?: string;
227
+ /**
228
+ * Contact details (for covers that render organization cards).
229
+ */
230
+ address?: string;
231
+ email?: string;
232
+ phone?: string;
233
+ website?: string;
234
+ social?: BackCoverSocial;
235
+ copyright?: string;
223
236
  /**
224
237
  * Custom footer notes at the bottom of the cover page.
225
238
  */
@@ -257,10 +270,22 @@ interface BackCoverConfig {
257
270
  * Subtitle / closing statement shown on the back cover.
258
271
  */
259
272
  subtitle?: string;
273
+ /**
274
+ * Author / signatory shown on the closing page.
275
+ */
276
+ author?: string | string[];
260
277
  /**
261
278
  * Organization or company name (falls back to document company).
262
279
  */
263
280
  company?: string;
281
+ /**
282
+ * Document version shown on the back cover.
283
+ */
284
+ version?: string;
285
+ /**
286
+ * Date shown on the back cover.
287
+ */
288
+ date?: string | boolean;
264
289
  /**
265
290
  * Office address or headquarters location.
266
291
  */
@@ -285,6 +310,10 @@ interface BackCoverConfig {
285
310
  * Copyright notice at the bottom (supports tokens like {company}, {date}, {year}).
286
311
  */
287
312
  copyright?: string;
313
+ /**
314
+ * Custom footer text at the bottom.
315
+ */
316
+ footerText?: string;
288
317
  /**
289
318
  * Brand logo path, URL, or Base64 data URI.
290
319
  */
@@ -306,10 +335,14 @@ interface BackCoverConfig {
306
335
  * Custom CSS background gradient or solid hex color for the back cover.
307
336
  */
308
337
  bgGradient?: string;
338
+ backgroundColor?: string;
309
339
  /**
310
- * Custom text color for back cover typography.
340
+ * Custom typography colors.
311
341
  */
312
342
  textColor?: string;
343
+ titleColor?: string;
344
+ subtitleColor?: string;
345
+ accentColor?: string;
313
346
  }
314
347
  interface NumberHeadingsOptions {
315
348
  /**
@@ -658,6 +691,14 @@ declare function parseInlineSpans(text: string): MarkdownInlineSpan[];
658
691
  * Extracts slug from heading text for TOC & anchor links.
659
692
  */
660
693
  declare function slugify(text: string): string;
694
+ /**
695
+ * Applies hierarchical numbering to headings (e.g. "1.", "1.1.", "1.1.1.").
696
+ */
697
+ declare function applyHeadingNumbering(nodes: MarkdownASTNode[], tocEntries: {
698
+ id: string;
699
+ text: string;
700
+ level: number;
701
+ }[], options: NumberHeadingsOptions): void;
661
702
  /**
662
703
  * Parses raw markdown string into rich structured AST nodes.
663
704
  */
@@ -749,28 +790,46 @@ interface NormalizedCoverPage {
749
790
  logo?: string;
750
791
  logoWidth?: number | string;
751
792
  bgGradient?: string;
793
+ backgroundColor?: string;
752
794
  textColor?: string;
795
+ titleColor?: string;
796
+ subtitleColor?: string;
797
+ accentColor?: string;
753
798
  footerText?: string;
799
+ address?: string;
800
+ email?: string;
801
+ phone?: string;
802
+ website?: string;
803
+ social?: Record<string, string>;
804
+ copyright?: string;
754
805
  }
755
806
  interface NormalizedBackCover {
756
807
  enabled: boolean;
757
808
  preset: "modern" | "corporate" | "minimal" | "contact-card";
758
809
  title: string;
759
810
  subtitle?: string;
811
+ author?: string;
760
812
  company?: string;
813
+ version?: string;
814
+ date?: string;
761
815
  address?: string;
762
816
  email?: string;
763
817
  phone?: string;
764
818
  website?: string;
765
819
  social?: Record<string, string>;
766
820
  copyright?: string;
821
+ footerText?: string;
767
822
  badge?: string;
768
823
  badgeColor?: string;
769
824
  badgeTextColor?: string;
770
825
  logo?: string;
771
826
  logoWidth?: number | string;
772
827
  bgGradient?: string;
828
+ backgroundColor?: string;
773
829
  textColor?: string;
830
+ titleColor?: string;
831
+ subtitleColor?: string;
832
+ accentColor?: string;
774
833
  }
775
834
  interface NormalizedNumberHeadings {
776
835
  enabled: boolean;
@@ -823,22 +882,13 @@ interface ResolvedDocumentConfig {
823
882
  syntaxTheme: string;
824
883
  }
825
884
  /**
826
- * Replaces dynamic variables ({title}, {subtitle}, {author}, {version}, {date}, {company}) in text templates.
885
+ * Replaces dynamic variables ({title}, {subtitle}, {author}, {version}, {date}, {company}, {year}, and any custom metadata keys) in text templates.
827
886
  */
828
- declare function replaceDocumentTokens(template: string | undefined, meta: {
829
- title?: string;
830
- subtitle?: string;
831
- author?: string;
832
- version?: string;
833
- date?: string;
834
- company?: string;
835
- year?: string;
836
- [key: string]: string | undefined;
837
- }): string;
887
+ declare function replaceDocumentTokens(template?: string, meta?: Record<string, unknown>): string;
838
888
  /**
839
- * Normalizes watermark configuration into a consistent structured object.
889
+ * Normalizes watermark configuration into a consistent structured object with dynamic token replacement.
840
890
  */
841
- declare function normalizeWatermark(rawWatermark?: string | WatermarkOptions | false): NormalizedWatermark | undefined;
891
+ declare function normalizeWatermark(rawWatermark?: string | WatermarkOptions | false, tokens?: Record<string, unknown>): NormalizedWatermark | undefined;
842
892
  /**
843
893
  * Normalizes an individual left, center, or right header/footer zone slot.
844
894
  */
@@ -868,25 +918,11 @@ declare function normalizeSignatures(raw?: SignatureBlockConfig | SignatureItem[
868
918
  /**
869
919
  * Normalizes Cover Page configuration with token replacement.
870
920
  */
871
- declare function normalizeCoverPage(rawCover?: boolean | CoverPageConfig | Record<string, unknown>, tokenCtx?: {
872
- title?: string;
873
- subtitle?: string;
874
- author?: string;
875
- version?: string;
876
- date?: string;
877
- company?: string;
878
- }): NormalizedCoverPage | undefined;
921
+ declare function normalizeCoverPage(rawCover?: boolean | CoverPageConfig | Record<string, unknown>, tokenCtx?: Record<string, unknown>): NormalizedCoverPage | undefined;
879
922
  /**
880
923
  * Normalizes Back Cover / Closing Page configuration with token replacement.
881
924
  */
882
- declare function normalizeBackCover(rawBack?: boolean | BackCoverConfig | Record<string, unknown>, tokenCtx?: {
883
- title?: string;
884
- subtitle?: string;
885
- author?: string;
886
- version?: string;
887
- date?: string;
888
- company?: string;
889
- }): NormalizedBackCover | undefined;
925
+ declare function normalizeBackCover(rawBack?: boolean | BackCoverConfig | Record<string, unknown>, tokenCtx?: Record<string, unknown>): NormalizedBackCover | undefined;
890
926
  /**
891
927
  * Normalizes numberHeadings configuration.
892
928
  */
@@ -906,13 +942,13 @@ declare function resolveDocumentConfig(frontmatter?: Record<string, unknown>, us
906
942
  */
907
943
  declare function escapeHtml(str: string): string;
908
944
  /**
909
- * Converts Markdown inline spans to HTML markup.
945
+ * Renders inline Markdown spans (bold, italic, links, images, footnotes, math, etc.) to HTML with token replacement.
910
946
  */
911
- declare function renderInlinesToHtml(spans?: MarkdownInlineSpan[], baseDir?: string): Promise<string>;
947
+ declare function renderInlinesToHtml(spans?: MarkdownInlineSpan[], baseDir?: string, tokens?: Record<string, unknown>): Promise<string>;
912
948
  /**
913
949
  * Renders an AST node array to HTML.
914
950
  */
915
- declare function renderNodesToHtml(nodes: MarkdownASTNode[], resolved: ResolvedDocumentConfig, baseDir?: string): Promise<string>;
951
+ declare function renderNodesToHtml(nodes: MarkdownASTNode[], resolved: ResolvedDocumentConfig, baseDir?: string, tokens?: Record<string, unknown>): Promise<string>;
916
952
  /**
917
953
  * Renders the Cover Page HTML and returns { html, css }.
918
954
  */
@@ -1013,8 +1049,8 @@ declare const KATEX_INLINE_CSS = "\n.katex { font: normal 1.21em KaTeX_Main, Tim
1013
1049
  /**
1014
1050
  * Flagship corporate theme — full design system with Blu-by-BCA-Digital cyan palette.
1015
1051
  */
1016
- declare const THEME_CORPORATE = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-text); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; border-bottom: 2px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; }\nh4 { font-size: 1.1rem; }\np { margin: 0.8rem 0; }\n";
1017
- declare const THEME_DEFAULT = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-text); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; border-bottom: 2px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; }\nh4 { font-size: 1.1rem; }\np { margin: 0.8rem 0; }\n";
1052
+ declare const THEME_CORPORATE = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-primary-dark); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; color: var(--mf-primary-dark); border-bottom: 2.5px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; color: var(--mf-primary-dark); }\nh4 { font-size: 1.1rem; color: var(--mf-primary-dark); }\nh5 { font-size: 1.0rem; color: var(--mf-primary-dark); }\nh6 { font-size: 0.9rem; color: var(--mf-primary-dark); }\np { margin: 0.8rem 0; }\n";
1053
+ declare const THEME_DEFAULT = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-primary-dark); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; color: var(--mf-primary-dark); border-bottom: 2.5px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; color: var(--mf-primary-dark); }\nh4 { font-size: 1.1rem; color: var(--mf-primary-dark); }\nh5 { font-size: 1.0rem; color: var(--mf-primary-dark); }\nh6 { font-size: 0.9rem; color: var(--mf-primary-dark); }\np { margin: 0.8rem 0; }\n";
1018
1054
  declare const THEMES: Record<string, string>;
1019
1055
 
1020
1056
  /**
@@ -1070,8 +1106,7 @@ declare function loadConfig(customPath?: string, startDir?: string): Promise<{
1070
1106
  }>;
1071
1107
 
1072
1108
  /**
1073
- * Dynamically resolved version — reads from the nearest package.json at runtime.
1074
- * Falls back to the hardcoded FALLBACK_VERSION constant if not found.
1109
+ * Dynamically resolved version — reads strictly from the nearest package.json at runtime.
1075
1110
  */
1076
1111
  declare const MARKFORGE_VERSION: string;
1077
1112
  /**
@@ -1079,4 +1114,4 @@ declare const MARKFORGE_VERSION: string;
1079
1114
  */
1080
1115
  declare function getMarkforgeVersion(fromDir?: string): string;
1081
1116
 
1082
- export { type BackCoverConfig, type BackCoverPreset, type BackCoverSocial, type CompilationResult, type CoverPageConfig, CoverPagePreset, 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, type SignatureAlign, type SignatureBlockConfig, type SignatureItem, type SignatureStyle, SyntaxTheme, type SyntaxToken, THEMES, THEME_CORPORATE, THEME_DEFAULT, Theme, type ThemeProps, type WatermarkOptions, WatermarkPosition, buildDocxDocument, buildHtmlDocument, buildPdfDocument, 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, renderMathToHtml, renderMermaidToPng, renderNodesToHtml, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, startPreviewServer, tokenizeCodeLine };
1117
+ export { type BackCoverConfig, type BackCoverPreset, type BackCoverSocial, type CompilationResult, type CoverPageConfig, CoverPagePreset, 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, type SignatureAlign, type SignatureBlockConfig, type SignatureItem, type SignatureStyle, SyntaxTheme, type SyntaxToken, THEMES, THEME_CORPORATE, THEME_DEFAULT, Theme, type ThemeProps, type WatermarkOptions, WatermarkPosition, applyHeadingNumbering, buildDocxDocument, buildHtmlDocument, buildPdfDocument, 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, renderMathToHtml, renderMermaidToPng, renderNodesToHtml, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, startPreviewServer, tokenizeCodeLine };
package/dist/index.d.ts CHANGED
@@ -216,10 +216,23 @@ interface CoverPageConfig {
216
216
  * Custom background color or CSS gradient for the cover page.
217
217
  */
218
218
  bgGradient?: string;
219
+ backgroundColor?: string;
219
220
  /**
220
- * Custom text color for cover typography.
221
+ * Custom typography colors.
221
222
  */
222
223
  textColor?: string;
224
+ titleColor?: string;
225
+ subtitleColor?: string;
226
+ accentColor?: string;
227
+ /**
228
+ * Contact details (for covers that render organization cards).
229
+ */
230
+ address?: string;
231
+ email?: string;
232
+ phone?: string;
233
+ website?: string;
234
+ social?: BackCoverSocial;
235
+ copyright?: string;
223
236
  /**
224
237
  * Custom footer notes at the bottom of the cover page.
225
238
  */
@@ -257,10 +270,22 @@ interface BackCoverConfig {
257
270
  * Subtitle / closing statement shown on the back cover.
258
271
  */
259
272
  subtitle?: string;
273
+ /**
274
+ * Author / signatory shown on the closing page.
275
+ */
276
+ author?: string | string[];
260
277
  /**
261
278
  * Organization or company name (falls back to document company).
262
279
  */
263
280
  company?: string;
281
+ /**
282
+ * Document version shown on the back cover.
283
+ */
284
+ version?: string;
285
+ /**
286
+ * Date shown on the back cover.
287
+ */
288
+ date?: string | boolean;
264
289
  /**
265
290
  * Office address or headquarters location.
266
291
  */
@@ -285,6 +310,10 @@ interface BackCoverConfig {
285
310
  * Copyright notice at the bottom (supports tokens like {company}, {date}, {year}).
286
311
  */
287
312
  copyright?: string;
313
+ /**
314
+ * Custom footer text at the bottom.
315
+ */
316
+ footerText?: string;
288
317
  /**
289
318
  * Brand logo path, URL, or Base64 data URI.
290
319
  */
@@ -306,10 +335,14 @@ interface BackCoverConfig {
306
335
  * Custom CSS background gradient or solid hex color for the back cover.
307
336
  */
308
337
  bgGradient?: string;
338
+ backgroundColor?: string;
309
339
  /**
310
- * Custom text color for back cover typography.
340
+ * Custom typography colors.
311
341
  */
312
342
  textColor?: string;
343
+ titleColor?: string;
344
+ subtitleColor?: string;
345
+ accentColor?: string;
313
346
  }
314
347
  interface NumberHeadingsOptions {
315
348
  /**
@@ -658,6 +691,14 @@ declare function parseInlineSpans(text: string): MarkdownInlineSpan[];
658
691
  * Extracts slug from heading text for TOC & anchor links.
659
692
  */
660
693
  declare function slugify(text: string): string;
694
+ /**
695
+ * Applies hierarchical numbering to headings (e.g. "1.", "1.1.", "1.1.1.").
696
+ */
697
+ declare function applyHeadingNumbering(nodes: MarkdownASTNode[], tocEntries: {
698
+ id: string;
699
+ text: string;
700
+ level: number;
701
+ }[], options: NumberHeadingsOptions): void;
661
702
  /**
662
703
  * Parses raw markdown string into rich structured AST nodes.
663
704
  */
@@ -749,28 +790,46 @@ interface NormalizedCoverPage {
749
790
  logo?: string;
750
791
  logoWidth?: number | string;
751
792
  bgGradient?: string;
793
+ backgroundColor?: string;
752
794
  textColor?: string;
795
+ titleColor?: string;
796
+ subtitleColor?: string;
797
+ accentColor?: string;
753
798
  footerText?: string;
799
+ address?: string;
800
+ email?: string;
801
+ phone?: string;
802
+ website?: string;
803
+ social?: Record<string, string>;
804
+ copyright?: string;
754
805
  }
755
806
  interface NormalizedBackCover {
756
807
  enabled: boolean;
757
808
  preset: "modern" | "corporate" | "minimal" | "contact-card";
758
809
  title: string;
759
810
  subtitle?: string;
811
+ author?: string;
760
812
  company?: string;
813
+ version?: string;
814
+ date?: string;
761
815
  address?: string;
762
816
  email?: string;
763
817
  phone?: string;
764
818
  website?: string;
765
819
  social?: Record<string, string>;
766
820
  copyright?: string;
821
+ footerText?: string;
767
822
  badge?: string;
768
823
  badgeColor?: string;
769
824
  badgeTextColor?: string;
770
825
  logo?: string;
771
826
  logoWidth?: number | string;
772
827
  bgGradient?: string;
828
+ backgroundColor?: string;
773
829
  textColor?: string;
830
+ titleColor?: string;
831
+ subtitleColor?: string;
832
+ accentColor?: string;
774
833
  }
775
834
  interface NormalizedNumberHeadings {
776
835
  enabled: boolean;
@@ -823,22 +882,13 @@ interface ResolvedDocumentConfig {
823
882
  syntaxTheme: string;
824
883
  }
825
884
  /**
826
- * Replaces dynamic variables ({title}, {subtitle}, {author}, {version}, {date}, {company}) in text templates.
885
+ * Replaces dynamic variables ({title}, {subtitle}, {author}, {version}, {date}, {company}, {year}, and any custom metadata keys) in text templates.
827
886
  */
828
- declare function replaceDocumentTokens(template: string | undefined, meta: {
829
- title?: string;
830
- subtitle?: string;
831
- author?: string;
832
- version?: string;
833
- date?: string;
834
- company?: string;
835
- year?: string;
836
- [key: string]: string | undefined;
837
- }): string;
887
+ declare function replaceDocumentTokens(template?: string, meta?: Record<string, unknown>): string;
838
888
  /**
839
- * Normalizes watermark configuration into a consistent structured object.
889
+ * Normalizes watermark configuration into a consistent structured object with dynamic token replacement.
840
890
  */
841
- declare function normalizeWatermark(rawWatermark?: string | WatermarkOptions | false): NormalizedWatermark | undefined;
891
+ declare function normalizeWatermark(rawWatermark?: string | WatermarkOptions | false, tokens?: Record<string, unknown>): NormalizedWatermark | undefined;
842
892
  /**
843
893
  * Normalizes an individual left, center, or right header/footer zone slot.
844
894
  */
@@ -868,25 +918,11 @@ declare function normalizeSignatures(raw?: SignatureBlockConfig | SignatureItem[
868
918
  /**
869
919
  * Normalizes Cover Page configuration with token replacement.
870
920
  */
871
- declare function normalizeCoverPage(rawCover?: boolean | CoverPageConfig | Record<string, unknown>, tokenCtx?: {
872
- title?: string;
873
- subtitle?: string;
874
- author?: string;
875
- version?: string;
876
- date?: string;
877
- company?: string;
878
- }): NormalizedCoverPage | undefined;
921
+ declare function normalizeCoverPage(rawCover?: boolean | CoverPageConfig | Record<string, unknown>, tokenCtx?: Record<string, unknown>): NormalizedCoverPage | undefined;
879
922
  /**
880
923
  * Normalizes Back Cover / Closing Page configuration with token replacement.
881
924
  */
882
- declare function normalizeBackCover(rawBack?: boolean | BackCoverConfig | Record<string, unknown>, tokenCtx?: {
883
- title?: string;
884
- subtitle?: string;
885
- author?: string;
886
- version?: string;
887
- date?: string;
888
- company?: string;
889
- }): NormalizedBackCover | undefined;
925
+ declare function normalizeBackCover(rawBack?: boolean | BackCoverConfig | Record<string, unknown>, tokenCtx?: Record<string, unknown>): NormalizedBackCover | undefined;
890
926
  /**
891
927
  * Normalizes numberHeadings configuration.
892
928
  */
@@ -906,13 +942,13 @@ declare function resolveDocumentConfig(frontmatter?: Record<string, unknown>, us
906
942
  */
907
943
  declare function escapeHtml(str: string): string;
908
944
  /**
909
- * Converts Markdown inline spans to HTML markup.
945
+ * Renders inline Markdown spans (bold, italic, links, images, footnotes, math, etc.) to HTML with token replacement.
910
946
  */
911
- declare function renderInlinesToHtml(spans?: MarkdownInlineSpan[], baseDir?: string): Promise<string>;
947
+ declare function renderInlinesToHtml(spans?: MarkdownInlineSpan[], baseDir?: string, tokens?: Record<string, unknown>): Promise<string>;
912
948
  /**
913
949
  * Renders an AST node array to HTML.
914
950
  */
915
- declare function renderNodesToHtml(nodes: MarkdownASTNode[], resolved: ResolvedDocumentConfig, baseDir?: string): Promise<string>;
951
+ declare function renderNodesToHtml(nodes: MarkdownASTNode[], resolved: ResolvedDocumentConfig, baseDir?: string, tokens?: Record<string, unknown>): Promise<string>;
916
952
  /**
917
953
  * Renders the Cover Page HTML and returns { html, css }.
918
954
  */
@@ -1013,8 +1049,8 @@ declare const KATEX_INLINE_CSS = "\n.katex { font: normal 1.21em KaTeX_Main, Tim
1013
1049
  /**
1014
1050
  * Flagship corporate theme — full design system with Blu-by-BCA-Digital cyan palette.
1015
1051
  */
1016
- declare const THEME_CORPORATE = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-text); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; border-bottom: 2px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; }\nh4 { font-size: 1.1rem; }\np { margin: 0.8rem 0; }\n";
1017
- declare const THEME_DEFAULT = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-text); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; border-bottom: 2px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; }\nh4 { font-size: 1.1rem; }\np { margin: 0.8rem 0; }\n";
1052
+ declare const THEME_CORPORATE = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-primary-dark); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; color: var(--mf-primary-dark); border-bottom: 2.5px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; color: var(--mf-primary-dark); }\nh4 { font-size: 1.1rem; color: var(--mf-primary-dark); }\nh5 { font-size: 1.0rem; color: var(--mf-primary-dark); }\nh6 { font-size: 0.9rem; color: var(--mf-primary-dark); }\np { margin: 0.8rem 0; }\n";
1053
+ declare const THEME_DEFAULT = "\n:root {\n --mf-bg: #ffffff;\n --mf-text: #0f172a;\n --mf-text-muted: #64748b;\n --mf-primary: #33CDCF;\n --mf-primary-dark: #009DA0;\n --mf-primary-light: #ECFDFD;\n --mf-border: #e2e8f0;\n --mf-card-bg: #f8fafc;\n --mf-code-bg: #0f172a;\n --mf-code-text: #f8fafc;\n --mf-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n --mf-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n}\nbody { background-color: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font-family); font-size: 15px; line-height: 1.65; margin: 0; padding: 2.5rem; }\n.document-container { max-width: 860px; margin: 0 auto; position: relative; z-index: 1; }\nh1, h2, h3, h4, h5, h6 { color: var(--mf-primary-dark); font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.8rem; line-height: 1.25; }\nh1 { font-size: 2.2rem; color: var(--mf-primary-dark); border-bottom: 2.5px solid var(--mf-primary); padding-bottom: 0.5rem; }\nh2 { font-size: 1.6rem; color: var(--mf-primary-dark); border-bottom: 1px solid #CCFBF1; padding-bottom: 0.4rem; }\nh3 { font-size: 1.3rem; color: var(--mf-primary-dark); }\nh4 { font-size: 1.1rem; color: var(--mf-primary-dark); }\nh5 { font-size: 1.0rem; color: var(--mf-primary-dark); }\nh6 { font-size: 0.9rem; color: var(--mf-primary-dark); }\np { margin: 0.8rem 0; }\n";
1018
1054
  declare const THEMES: Record<string, string>;
1019
1055
 
1020
1056
  /**
@@ -1070,8 +1106,7 @@ declare function loadConfig(customPath?: string, startDir?: string): Promise<{
1070
1106
  }>;
1071
1107
 
1072
1108
  /**
1073
- * Dynamically resolved version — reads from the nearest package.json at runtime.
1074
- * Falls back to the hardcoded FALLBACK_VERSION constant if not found.
1109
+ * Dynamically resolved version — reads strictly from the nearest package.json at runtime.
1075
1110
  */
1076
1111
  declare const MARKFORGE_VERSION: string;
1077
1112
  /**
@@ -1079,4 +1114,4 @@ declare const MARKFORGE_VERSION: string;
1079
1114
  */
1080
1115
  declare function getMarkforgeVersion(fromDir?: string): string;
1081
1116
 
1082
- export { type BackCoverConfig, type BackCoverPreset, type BackCoverSocial, type CompilationResult, type CoverPageConfig, CoverPagePreset, 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, type SignatureAlign, type SignatureBlockConfig, type SignatureItem, type SignatureStyle, SyntaxTheme, type SyntaxToken, THEMES, THEME_CORPORATE, THEME_DEFAULT, Theme, type ThemeProps, type WatermarkOptions, WatermarkPosition, buildDocxDocument, buildHtmlDocument, buildPdfDocument, 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, renderMathToHtml, renderMermaidToPng, renderNodesToHtml, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, startPreviewServer, tokenizeCodeLine };
1117
+ export { type BackCoverConfig, type BackCoverPreset, type BackCoverSocial, type CompilationResult, type CoverPageConfig, CoverPagePreset, 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, type SignatureAlign, type SignatureBlockConfig, type SignatureItem, type SignatureStyle, SyntaxTheme, type SyntaxToken, THEMES, THEME_CORPORATE, THEME_DEFAULT, Theme, type ThemeProps, type WatermarkOptions, WatermarkPosition, applyHeadingNumbering, buildDocxDocument, buildHtmlDocument, buildPdfDocument, 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, renderMathToHtml, renderMermaidToPng, renderNodesToHtml, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, startPreviewServer, tokenizeCodeLine };