@masumdev/markforge 0.2.5 → 0.4.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/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as http from 'node:http';
2
+
1
3
  declare enum OutputFormat {
2
4
  DOCX = "docx",
3
5
  PDF = "pdf",
@@ -151,6 +153,210 @@ interface WatermarkOptions {
151
153
  rotate?: number;
152
154
  position?: "diagonal" | "center" | "top-right" | "bottom-right" | WatermarkPosition;
153
155
  }
156
+ declare enum CoverPagePreset {
157
+ MODERN = "modern",
158
+ CORPORATE_SPLIT = "corporate-split",
159
+ MINIMAL = "minimal",
160
+ CARD = "card"
161
+ }
162
+ type CoverPreset = "modern" | "corporate-split" | "minimal" | "card" | CoverPagePreset;
163
+ interface CoverPageConfig {
164
+ /**
165
+ * Whether the dedicated cover page is enabled.
166
+ * @default true
167
+ */
168
+ enabled?: boolean;
169
+ /**
170
+ * Cover page visual layout template.
171
+ * @default "modern"
172
+ */
173
+ preset?: CoverPreset;
174
+ /**
175
+ * Title shown on the cover page (falls back to document title).
176
+ */
177
+ title?: string;
178
+ /**
179
+ * Subtitle shown on the cover page (falls back to document subtitle).
180
+ */
181
+ subtitle?: string;
182
+ /**
183
+ * Author(s) shown on the cover page (falls back to document author).
184
+ */
185
+ author?: string | string[];
186
+ /**
187
+ * Organization / Company name shown on the cover page.
188
+ */
189
+ company?: string;
190
+ /**
191
+ * Document version shown on the cover page.
192
+ */
193
+ version?: string;
194
+ /**
195
+ * Date shown on the cover page (falls back to document date or current date).
196
+ */
197
+ date?: string | boolean;
198
+ /**
199
+ * Status / Confidentiality badge (e.g. "CONFIDENTIAL", "DRAFT", "TECHNICAL SPECIFICATION").
200
+ */
201
+ badge?: string;
202
+ /**
203
+ * Badge background and text colors.
204
+ */
205
+ badgeColor?: string;
206
+ badgeTextColor?: string;
207
+ /**
208
+ * Corporate logo image path, URL, or Base64 data URI.
209
+ */
210
+ logo?: string;
211
+ /**
212
+ * Width or height of the logo (e.g. 120, "120px", "3.5cm").
213
+ */
214
+ logoWidth?: number | string;
215
+ /**
216
+ * Custom background color or CSS gradient for the cover page.
217
+ */
218
+ bgGradient?: string;
219
+ /**
220
+ * Custom text color for cover typography.
221
+ */
222
+ textColor?: string;
223
+ /**
224
+ * Custom footer notes at the bottom of the cover page.
225
+ */
226
+ footerText?: string;
227
+ }
228
+ type BackCoverPreset = "modern" | "corporate" | "minimal" | "contact-card";
229
+ interface BackCoverSocial {
230
+ github?: string;
231
+ twitter?: string;
232
+ linkedin?: string;
233
+ website?: string;
234
+ [key: string]: string | undefined;
235
+ }
236
+ interface BackCoverConfig {
237
+ /**
238
+ * Whether the standalone back cover / closing page is enabled.
239
+ * @default false
240
+ */
241
+ enabled?: boolean;
242
+ /**
243
+ * Visual layout preset for the back cover:
244
+ * - "modern": Accent colored background with centered logo, thank you typography, and contact footer.
245
+ * - "corporate": Navy/cyan split layout with comprehensive company details, legal notice, and social links.
246
+ * - "minimal": Clean white card with minimalist contact table and copyright line.
247
+ * - "contact-card": Floating elevated glassmorphic contact card with full metadata grid.
248
+ * @default "modern"
249
+ */
250
+ preset?: BackCoverPreset;
251
+ /**
252
+ * Headline title shown on the back cover.
253
+ * @default "Thank You"
254
+ */
255
+ title?: string;
256
+ /**
257
+ * Subtitle / closing statement shown on the back cover.
258
+ */
259
+ subtitle?: string;
260
+ /**
261
+ * Organization or company name (falls back to document company).
262
+ */
263
+ company?: string;
264
+ /**
265
+ * Office address or headquarters location.
266
+ */
267
+ address?: string;
268
+ /**
269
+ * Official contact email address.
270
+ */
271
+ email?: string;
272
+ /**
273
+ * Official contact phone number.
274
+ */
275
+ phone?: string;
276
+ /**
277
+ * Official company website URL.
278
+ */
279
+ website?: string;
280
+ /**
281
+ * Social media links dictionary (e.g. { github: "https://github.com/masumrpg", ... }).
282
+ */
283
+ social?: BackCoverSocial;
284
+ /**
285
+ * Copyright notice at the bottom (supports tokens like {company}, {date}, {year}).
286
+ */
287
+ copyright?: string;
288
+ /**
289
+ * Brand logo path, URL, or Base64 data URI.
290
+ */
291
+ logo?: string;
292
+ /**
293
+ * Logo width (e.g. 140, "140px", "3.5cm").
294
+ */
295
+ logoWidth?: number | string;
296
+ /**
297
+ * Status / confidentiality badge.
298
+ */
299
+ badge?: string;
300
+ /**
301
+ * Badge colors.
302
+ */
303
+ badgeColor?: string;
304
+ badgeTextColor?: string;
305
+ /**
306
+ * Custom CSS background gradient or solid hex color for the back cover.
307
+ */
308
+ bgGradient?: string;
309
+ /**
310
+ * Custom text color for back cover typography.
311
+ */
312
+ textColor?: string;
313
+ }
314
+ interface NumberHeadingsOptions {
315
+ /**
316
+ * Whether hierarchical heading numbering is enabled.
317
+ * @default true
318
+ */
319
+ enabled?: boolean;
320
+ /**
321
+ * Maximum heading level depth to number (e.g. 3 for H1..H3, 4 for H1..H4).
322
+ * @default 3
323
+ */
324
+ depth?: number;
325
+ /**
326
+ * Whether to skip numbering the main H1 document heading.
327
+ * @default false
328
+ */
329
+ skipH1?: boolean;
330
+ /**
331
+ * Custom prefix string prepended to all heading numbers.
332
+ * @default ""
333
+ */
334
+ prefix?: string;
335
+ }
336
+ type NumberHeadingsConfig = boolean | NumberHeadingsOptions;
337
+ interface PdfPermissions {
338
+ printing?: "highResolution" | "lowResolution" | "none" | boolean;
339
+ modifying?: boolean;
340
+ copying?: boolean;
341
+ annotating?: boolean;
342
+ fillingForms?: boolean;
343
+ contentAccessibility?: boolean;
344
+ documentAssembly?: boolean;
345
+ }
346
+ interface SecurityConfig {
347
+ /**
348
+ * Password required to open and view the document.
349
+ */
350
+ userPassword?: string;
351
+ /**
352
+ * Master password required to change document permissions.
353
+ */
354
+ ownerPassword?: string;
355
+ /**
356
+ * Granular permission restrictions on the PDF document.
357
+ */
358
+ permissions?: PdfPermissions;
359
+ }
154
360
  /**
155
361
  * Pure document metadata dictionary (author, title, date, version, etc.).
156
362
  */
@@ -162,9 +368,83 @@ interface DocumentMetadata {
162
368
  version?: string;
163
369
  company?: string;
164
370
  lang?: string;
165
- coverPage?: boolean;
371
+ coverPage?: boolean | CoverPageConfig;
372
+ backCover?: boolean | BackCoverConfig;
166
373
  [key: string]: unknown;
167
374
  }
375
+ type SignatureAlign = "left" | "center" | "right" | "space-between";
376
+ type SignatureStyle = "line" | "box" | "clean";
377
+ interface SignatureItem {
378
+ /**
379
+ * Title or sign-off label above signature (e.g. "Prepared by", "Approved by", "Acknowledged by").
380
+ */
381
+ title?: string;
382
+ /**
383
+ * Signatory person name (supports metadata tokens like {author}, {company}).
384
+ */
385
+ name: string;
386
+ /**
387
+ * Signatory job title, role, or department (e.g. "Lead System Architect", "Chief Technology Officer").
388
+ */
389
+ role?: string;
390
+ /**
391
+ * Signature date string or template (e.g. "2026-08-29", "{date}", or true for auto-formatted current date).
392
+ */
393
+ date?: string | boolean;
394
+ /**
395
+ * Optional signature image path, URL, or Base64 data URI (stamp, digital seal, or handwritten signature).
396
+ */
397
+ image?: string;
398
+ /**
399
+ * Height reserved for physical handwriting signature (e.g. 60, "60px", "1.5cm").
400
+ * @default 60
401
+ */
402
+ signatureHeight?: number | string;
403
+ }
404
+ interface SignatureBlockConfig {
405
+ /**
406
+ * List of 1 to 4 signature slots.
407
+ */
408
+ items: SignatureItem[];
409
+ /**
410
+ * Horizontal alignment of the signature block.
411
+ * @default "right" for 1 item, "space-between" for >= 2 items
412
+ */
413
+ align?: SignatureAlign;
414
+ /**
415
+ * Visual layout style of the signature block:
416
+ * - "line": Traditional signature with a horizontal separator line above name.
417
+ * - "box": Formal bordered rectangular approval card.
418
+ * - "clean": Minimalist blank vertical space without borders.
419
+ * @default "line"
420
+ */
421
+ style?: SignatureStyle;
422
+ /**
423
+ * Border or divider line color.
424
+ * @default "#CBD5E1"
425
+ */
426
+ borderColor?: string;
427
+ /**
428
+ * Color of the signature title / label.
429
+ * @default "#64748B"
430
+ */
431
+ titleColor?: string;
432
+ /**
433
+ * Color of the signatory name.
434
+ * @default "#0F172A"
435
+ */
436
+ nameColor?: string;
437
+ /**
438
+ * Color of the role and date text.
439
+ * @default "#64748B"
440
+ */
441
+ roleColor?: string;
442
+ /**
443
+ * Vertical spacing before the signature block (e.g. "2.5rem", 480).
444
+ * @default "2.5rem"
445
+ */
446
+ spacingBefore?: number | string;
447
+ }
168
448
  /**
169
449
  * Document visual & layout options (theme, orientation, margins, headers, footers, etc.).
170
450
  */
@@ -201,6 +481,11 @@ interface DocumentLayoutConfig {
201
481
  * @default false
202
482
  */
203
483
  toc?: boolean;
484
+ /**
485
+ * Document signature and approval block at the bottom of the document.
486
+ * Supports 1-4 signature items, flexible alignment, and multiple styles ("line", "box", "clean").
487
+ */
488
+ signatures?: SignatureBlockConfig | SignatureItem[];
204
489
  /**
205
490
  * Optional watermark configuration to display across pages.
206
491
  * @default false
@@ -210,6 +495,28 @@ interface DocumentLayoutConfig {
210
495
  * Path(s) to custom CSS stylesheets to inject into the document.
211
496
  */
212
497
  css?: string | string[];
498
+ /**
499
+ * Dedicated standalone Cover Page builder.
500
+ */
501
+ coverPage?: boolean | CoverPageConfig;
502
+ /**
503
+ * Dedicated standalone Back Cover / Closing Page builder.
504
+ */
505
+ backCover?: boolean | BackCoverConfig;
506
+ /**
507
+ * Hierarchical heading numbering (e.g. 1., 1.1, 1.1.1).
508
+ * @default false
509
+ */
510
+ numberHeadings?: NumberHeadingsConfig;
511
+ /**
512
+ * Document security and password protection for PDF outputs.
513
+ */
514
+ security?: SecurityConfig;
515
+ /**
516
+ * Whether LaTeX math equations ($inline$ and $$block$$) are parsed and rendered.
517
+ * @default true
518
+ */
519
+ math?: boolean;
213
520
  /**
214
521
  * Code syntax highlighting theme.
215
522
  * @default "github-dark"
@@ -294,9 +601,9 @@ declare function formatServerTimestamp(date?: Date): string;
294
601
  */
295
602
  declare function compileMarkdown(inputFilePathOrContent: string, userConfig?: MarkforgeConfig, onProgress?: (msg: string) => void): Promise<CompilationResult>;
296
603
 
297
- type MarkdownNodeType = "heading" | "paragraph" | "blockquote" | "callout" | "list" | "listItem" | "table" | "tableRow" | "tableCell" | "codeBlock" | "mermaid" | "htmlBlock" | "thematicBreak" | "image" | "toc";
604
+ type MarkdownNodeType = "heading" | "paragraph" | "blockquote" | "callout" | "list" | "listItem" | "table" | "tableRow" | "tableCell" | "codeBlock" | "mermaid" | "mathBlock" | "footnoteDef" | "columns" | "column" | "htmlBlock" | "thematicBreak" | "image" | "toc";
298
605
  interface MarkdownInlineSpan {
299
- type: "text" | "bold" | "italic" | "code" | "link" | "strikethrough" | "image" | "htmlInline";
606
+ type: "text" | "bold" | "italic" | "code" | "link" | "strikethrough" | "image" | "htmlInline" | "mathInline" | "footnoteRef";
300
607
  content: string;
301
608
  url?: string;
302
609
  title?: string;
@@ -305,6 +612,7 @@ interface MarkdownInlineSpan {
305
612
  height?: number | string;
306
613
  children?: MarkdownInlineSpan[];
307
614
  style?: Record<string, string>;
615
+ footnoteId?: string;
308
616
  }
309
617
  interface MarkdownASTNode {
310
618
  type: MarkdownNodeType;
@@ -321,6 +629,14 @@ interface MarkdownASTNode {
321
629
  rawHtml?: string;
322
630
  id?: string;
323
631
  style?: Record<string, string>;
632
+ columnsCount?: number;
633
+ columnGap?: string;
634
+ footnoteId?: string;
635
+ }
636
+ interface FootnoteDefinition {
637
+ id: string;
638
+ text: string;
639
+ inlines: MarkdownInlineSpan[];
324
640
  }
325
641
  interface ParsedMarkdownDocument {
326
642
  metadata: FrontmatterMetadata;
@@ -332,9 +648,10 @@ interface ParsedMarkdownDocument {
332
648
  level: number;
333
649
  }[];
334
650
  inlinedStyles: string[];
651
+ footnoteDefs: FootnoteDefinition[];
335
652
  }
336
653
  /**
337
- * Parses inline formatting (bold, italic, code, links, images, HTML spans)
654
+ * Parses inline formatting (bold, italic, code, links, images, math, footnotes, HTML spans)
338
655
  */
339
656
  declare function parseInlineSpans(text: string): MarkdownInlineSpan[];
340
657
  /**
@@ -355,6 +672,235 @@ declare function parseMarginToTwip(margin?: string | number, defaultTwip?: numbe
355
672
  */
356
673
  declare function buildDocxDocument(doc: ParsedMarkdownDocument, config: MarkforgeConfig, baseDir?: string): Promise<Buffer>;
357
674
 
675
+ /**
676
+ * Standard paper dimensions in Word Twips (1/20th of a point, 1440 twips = 1 inch).
677
+ */
678
+ declare const PAPER_DIMENSIONS_TWIP: Record<PaperSize, {
679
+ width: number;
680
+ height: number;
681
+ }>;
682
+ interface NormalizedMargins {
683
+ top: string;
684
+ bottom: string;
685
+ left: string;
686
+ right: string;
687
+ topTwip: number;
688
+ bottomTwip: number;
689
+ leftTwip: number;
690
+ rightTwip: number;
691
+ }
692
+ interface NormalizedWatermark {
693
+ text: string;
694
+ color: string;
695
+ opacity: number;
696
+ fontSize: number;
697
+ rotate: number;
698
+ position: "diagonal" | "center" | "top-right" | "bottom-right";
699
+ }
700
+ interface NormalizedHeaderFooterZone {
701
+ text: string;
702
+ color: string;
703
+ fontSize: number;
704
+ fontFamily: string;
705
+ bold: boolean;
706
+ italic: boolean;
707
+ }
708
+ interface NormalizedHeaderFooter {
709
+ left?: NormalizedHeaderFooterZone;
710
+ center?: NormalizedHeaderFooterZone;
711
+ right?: NormalizedHeaderFooterZone;
712
+ font: string;
713
+ size: number;
714
+ color: string;
715
+ divider: boolean;
716
+ dividerColor: string;
717
+ }
718
+ interface NormalizedSignatureItem {
719
+ title?: string;
720
+ name: string;
721
+ role?: string;
722
+ date?: string;
723
+ image?: string;
724
+ signatureHeight: number;
725
+ }
726
+ interface NormalizedSignatureBlock {
727
+ items: NormalizedSignatureItem[];
728
+ align: SignatureAlign;
729
+ style: SignatureStyle;
730
+ borderColor: string;
731
+ titleColor: string;
732
+ nameColor: string;
733
+ roleColor: string;
734
+ spacingBefore: string;
735
+ spacingBeforeTwip: number;
736
+ }
737
+ interface NormalizedCoverPage {
738
+ enabled: boolean;
739
+ preset: "modern" | "corporate-split" | "minimal" | "card";
740
+ title: string;
741
+ subtitle?: string;
742
+ author?: string;
743
+ company?: string;
744
+ version?: string;
745
+ date?: string;
746
+ badge?: string;
747
+ badgeColor?: string;
748
+ badgeTextColor?: string;
749
+ logo?: string;
750
+ logoWidth?: number | string;
751
+ bgGradient?: string;
752
+ textColor?: string;
753
+ footerText?: string;
754
+ }
755
+ interface NormalizedBackCover {
756
+ enabled: boolean;
757
+ preset: "modern" | "corporate" | "minimal" | "contact-card";
758
+ title: string;
759
+ subtitle?: string;
760
+ company?: string;
761
+ address?: string;
762
+ email?: string;
763
+ phone?: string;
764
+ website?: string;
765
+ social?: Record<string, string>;
766
+ copyright?: string;
767
+ badge?: string;
768
+ badgeColor?: string;
769
+ badgeTextColor?: string;
770
+ logo?: string;
771
+ logoWidth?: number | string;
772
+ bgGradient?: string;
773
+ textColor?: string;
774
+ }
775
+ interface NormalizedNumberHeadings {
776
+ enabled: boolean;
777
+ depth: number;
778
+ skipH1: boolean;
779
+ prefix: string;
780
+ }
781
+ interface NormalizedSecurity {
782
+ userPassword?: string;
783
+ ownerPassword?: string;
784
+ permissions?: {
785
+ printing?: "highResolution" | "lowResolution" | "none";
786
+ modifying?: boolean;
787
+ copying?: boolean;
788
+ annotating?: boolean;
789
+ fillingForms?: boolean;
790
+ contentAccessibility?: boolean;
791
+ documentAssembly?: boolean;
792
+ };
793
+ }
794
+ interface ResolvedDocumentConfig {
795
+ title: string;
796
+ subtitle?: string;
797
+ author?: string;
798
+ date?: string;
799
+ version?: string;
800
+ company?: string;
801
+ lang: string;
802
+ theme: MarkforgeTheme;
803
+ orientation: DocumentOrientation;
804
+ paperSize: PaperSize;
805
+ paperDimensions: {
806
+ widthTwip: number;
807
+ heightTwip: number;
808
+ };
809
+ margins: NormalizedMargins;
810
+ header?: NormalizedHeaderFooter;
811
+ footer?: NormalizedHeaderFooter;
812
+ toc: boolean;
813
+ signatures?: NormalizedSignatureBlock;
814
+ watermark?: NormalizedWatermark;
815
+ coverPage?: NormalizedCoverPage;
816
+ backCover?: NormalizedBackCover;
817
+ numberHeadings?: NormalizedNumberHeadings;
818
+ security?: NormalizedSecurity;
819
+ math: boolean;
820
+ css: string[];
821
+ embedImages: boolean;
822
+ bundleHtml: boolean;
823
+ syntaxTheme: string;
824
+ }
825
+ /**
826
+ * Replaces dynamic variables ({title}, {subtitle}, {author}, {version}, {date}, {company}) in text templates.
827
+ */
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;
838
+ /**
839
+ * Normalizes watermark configuration into a consistent structured object.
840
+ */
841
+ declare function normalizeWatermark(rawWatermark?: string | WatermarkOptions | false): NormalizedWatermark | undefined;
842
+ /**
843
+ * Normalizes an individual left, center, or right header/footer zone slot.
844
+ */
845
+ declare function normalizeHeaderFooterSlot(rawSlot: string | HeaderFooterSlot | undefined, parent: HeaderFooterItem | undefined, meta: {
846
+ title?: string;
847
+ subtitle?: string;
848
+ author?: string;
849
+ version?: string;
850
+ date?: string;
851
+ company?: string;
852
+ }): NormalizedHeaderFooterZone | undefined;
853
+ /**
854
+ * Normalizes a header or footer item into a structured NormalizedHeaderFooter object.
855
+ */
856
+ declare function normalizeHeaderFooter(raw: HeaderFooterItem | undefined, meta: {
857
+ title?: string;
858
+ subtitle?: string;
859
+ author?: string;
860
+ version?: string;
861
+ date?: string;
862
+ company?: string;
863
+ }): NormalizedHeaderFooter | undefined;
864
+ /**
865
+ * Normalizes signature and approval block configuration.
866
+ */
867
+ declare function normalizeSignatures(raw?: SignatureBlockConfig | SignatureItem[], meta?: Record<string, unknown>): NormalizedSignatureBlock | undefined;
868
+ /**
869
+ * Normalizes Cover Page configuration with token replacement.
870
+ */
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;
879
+ /**
880
+ * Normalizes Back Cover / Closing Page configuration with token replacement.
881
+ */
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;
890
+ /**
891
+ * Normalizes numberHeadings configuration.
892
+ */
893
+ declare function normalizeNumberHeadings(raw?: NumberHeadingsConfig | Record<string, unknown>): NormalizedNumberHeadings | undefined;
894
+ /**
895
+ * Normalizes security / PDF password encryption configuration.
896
+ */
897
+ declare function normalizeSecurity(raw?: SecurityConfig | Record<string, unknown>): NormalizedSecurity | undefined;
898
+ /**
899
+ * Centralized Single Source of Truth for resolving document configuration.
900
+ * Priority hierarchy: Frontmatter metadata > Project Config File / User Config > DEFAULT_CONFIG
901
+ */
902
+ declare function resolveDocumentConfig(frontmatter?: Record<string, unknown>, userConfig?: MarkforgeConfig): ResolvedDocumentConfig;
903
+
358
904
  /**
359
905
  * Escapes HTML characters safely.
360
906
  */
@@ -363,6 +909,24 @@ declare function escapeHtml(str: string): string;
363
909
  * Converts Markdown inline spans to HTML markup.
364
910
  */
365
911
  declare function renderInlinesToHtml(spans?: MarkdownInlineSpan[], baseDir?: string): Promise<string>;
912
+ /**
913
+ * Renders an AST node array to HTML.
914
+ */
915
+ declare function renderNodesToHtml(nodes: MarkdownASTNode[], resolved: ResolvedDocumentConfig, baseDir?: string): Promise<string>;
916
+ /**
917
+ * Renders the Cover Page HTML and returns { html, css }.
918
+ */
919
+ declare function renderCoverPageHtml(cover: NormalizedCoverPage, baseDir?: string): Promise<{
920
+ html: string;
921
+ css: string;
922
+ }>;
923
+ /**
924
+ * Renders the Back Cover / Closing Page HTML & CSS.
925
+ */
926
+ declare function renderBackCoverHtml(backCover: NormalizedBackCover, baseDir?: string): Promise<{
927
+ html: string;
928
+ css: string;
929
+ }>;
366
930
  /**
367
931
  * Builds standalone self-contained HTML from a parsed Markdown document.
368
932
  */
@@ -437,6 +1001,15 @@ declare function highlightCodeToHtml(code: string, lang?: string, theme?: string
437
1001
  */
438
1002
  declare function renderMermaidToPng(mermaidCode: string, _baseDir?: string): Promise<Buffer | null>;
439
1003
 
1004
+ /**
1005
+ * Renders a LaTeX math formula into clean HTML/MathML markup using KaTeX.
1006
+ */
1007
+ declare function renderMathToHtml(latex: string, displayMode?: boolean): string;
1008
+ /**
1009
+ * Minimal inlined KaTeX CSS required for rendering formulas without external network requests.
1010
+ */
1011
+ declare const KATEX_INLINE_CSS = "\n.katex { font: normal 1.21em KaTeX_Main, Times New Roman, serif; line-height: 1.2; text-indent: 0; text-rendering: auto; border-color: currentColor; }\n.katex * { -ms-high-contrast-adjust: none !important; }\n.katex .katex-html { display: inline-block; }\n.katex .katex-mathml { clip: rect(1px, 1px, 1px, 1px); border: 0; height: 1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }\n.katex-display { display: block; margin: 1em 0; text-align: center; }\n.katex-display > .katex { display: inline-block; text-align: initial; }\n.katex .base { position: relative; white-space: nowrap; width: min-content; }\n.katex .strut { display: inline-block; }\n.katex .mord { display: inline-block; }\n.katex .mbin { display: inline-block; }\n.katex .mrel { display: inline-block; }\n.katex .mopen { display: inline-block; }\n.katex .mclose { display: inline-block; }\n.katex .mpunct { display: inline-block; }\n.katex .minner { display: inline-block; }\n.katex .mop { display: inline-block; }\n.katex .frac-line { width: 100%; border-bottom-style: solid; }\n.katex .vlist-t { display: inline-table; table-layout: fixed; }\n.katex .vlist-r { display: table-row; }\n.katex .vlist { display: table-cell; vertical-align: bottom; position: relative; }\n.katex .msupsub { text-align: left; }\n.katex .sqrt > .root { margin-left: 0.27777778em; margin-right: -0.55555556em; }\n";
1012
+
440
1013
  /**
441
1014
  * Flagship corporate theme — full design system with Blu-by-BCA-Digital cyan palette.
442
1015
  */
@@ -449,17 +1022,41 @@ declare const THEMES: Record<string, string>;
449
1022
  */
450
1023
  declare function generateThemeCss(theme?: MarkforgeTheme): string;
451
1024
 
1025
+ interface PreviewServerOptions {
1026
+ filePath: string;
1027
+ port?: number;
1028
+ open?: boolean;
1029
+ config?: MarkforgeConfig;
1030
+ }
1031
+ interface PreviewServerInstance {
1032
+ server: http.Server;
1033
+ port: number;
1034
+ url: string;
1035
+ close: () => Promise<void>;
1036
+ }
1037
+ /**
1038
+ * Launches an interactive dual-pane Markdown Editor & Live-Reload Preview Server.
1039
+ * Left Pane: Code Editor with line numbers, shortcut triggers, auto-save, and formatting toolbar.
1040
+ * Right Pane: Real-time rendered document preview iframe with scroll preservation.
1041
+ */
1042
+ declare function startPreviewServer(options: PreviewServerOptions): Promise<PreviewServerInstance>;
1043
+
452
1044
  /**
453
1045
  * Type-safe configuration helper for markforge.config.ts
454
1046
  */
455
1047
  declare function defineConfig(config: MarkforgeConfig): MarkforgeConfig;
456
1048
 
457
- declare const DEFAULT_CONFIG: Required<Omit<MarkforgeConfig, "outputDir" | "css" | "margins" | "header" | "footer" | "watermark" | "metadata" | "syntaxTheme">> & {
1049
+ declare const DEFAULT_CONFIG: Required<Omit<MarkforgeConfig, "outputDir" | "css" | "margins" | "header" | "footer" | "watermark" | "metadata" | "syntaxTheme" | "signatures" | "coverPage" | "backCover" | "numberHeadings" | "security">> & {
458
1050
  outputDir?: string;
459
1051
  css?: string | string[];
460
1052
  margins?: MarkforgeConfig["margins"];
461
1053
  header?: MarkforgeConfig["header"];
462
1054
  footer?: MarkforgeConfig["footer"];
1055
+ signatures?: MarkforgeConfig["signatures"];
1056
+ coverPage?: MarkforgeConfig["coverPage"];
1057
+ backCover?: MarkforgeConfig["backCover"];
1058
+ numberHeadings?: MarkforgeConfig["numberHeadings"];
1059
+ security?: MarkforgeConfig["security"];
463
1060
  watermark?: string;
464
1061
  metadata?: MarkforgeConfig["metadata"];
465
1062
  syntaxTheme?: string;
@@ -472,117 +1069,6 @@ declare function loadConfig(customPath?: string, startDir?: string): Promise<{
472
1069
  configPath: string | null;
473
1070
  }>;
474
1071
 
475
- /**
476
- * Standard paper dimensions in Word Twips (1/20th of a point, 1440 twips = 1 inch).
477
- */
478
- declare const PAPER_DIMENSIONS_TWIP: Record<PaperSize, {
479
- width: number;
480
- height: number;
481
- }>;
482
- interface NormalizedMargins {
483
- top: string;
484
- bottom: string;
485
- left: string;
486
- right: string;
487
- topTwip: number;
488
- bottomTwip: number;
489
- leftTwip: number;
490
- rightTwip: number;
491
- }
492
- interface NormalizedWatermark {
493
- text: string;
494
- color: string;
495
- opacity: number;
496
- fontSize: number;
497
- rotate: number;
498
- position: "diagonal" | "center" | "top-right" | "bottom-right";
499
- }
500
- interface NormalizedHeaderFooterZone {
501
- text: string;
502
- color: string;
503
- fontSize: number;
504
- fontFamily: string;
505
- bold: boolean;
506
- italic: boolean;
507
- }
508
- interface NormalizedHeaderFooter {
509
- left?: NormalizedHeaderFooterZone;
510
- center?: NormalizedHeaderFooterZone;
511
- right?: NormalizedHeaderFooterZone;
512
- font: string;
513
- size: number;
514
- color: string;
515
- divider: boolean;
516
- dividerColor: string;
517
- }
518
- interface ResolvedDocumentConfig {
519
- title: string;
520
- subtitle?: string;
521
- author?: string;
522
- date?: string;
523
- version?: string;
524
- company?: string;
525
- lang: string;
526
- theme: MarkforgeTheme;
527
- orientation: DocumentOrientation;
528
- paperSize: PaperSize;
529
- paperDimensions: {
530
- widthTwip: number;
531
- heightTwip: number;
532
- };
533
- margins: NormalizedMargins;
534
- header?: NormalizedHeaderFooter;
535
- footer?: NormalizedHeaderFooter;
536
- toc: boolean;
537
- watermark?: NormalizedWatermark;
538
- css: string[];
539
- embedImages: boolean;
540
- bundleHtml: boolean;
541
- syntaxTheme: string;
542
- }
543
- /**
544
- * Replaces dynamic variables ({title}, {subtitle}, {author}, {version}, {date}, {company}) in text templates.
545
- */
546
- declare function replaceDocumentTokens(template: string | undefined, meta: {
547
- title?: string;
548
- subtitle?: string;
549
- author?: string;
550
- version?: string;
551
- date?: string;
552
- company?: string;
553
- }): string;
554
- /**
555
- * Normalizes watermark configuration into a consistent structured object.
556
- */
557
- declare function normalizeWatermark(rawWatermark?: string | WatermarkOptions | false): NormalizedWatermark | undefined;
558
- /**
559
- * Normalizes an individual left, center, or right header/footer zone slot.
560
- */
561
- declare function normalizeHeaderFooterSlot(rawSlot: string | HeaderFooterSlot | undefined, parent: HeaderFooterItem | undefined, meta: {
562
- title?: string;
563
- subtitle?: string;
564
- author?: string;
565
- version?: string;
566
- date?: string;
567
- company?: string;
568
- }): NormalizedHeaderFooterZone | undefined;
569
- /**
570
- * Normalizes a header or footer item into a structured NormalizedHeaderFooter object.
571
- */
572
- declare function normalizeHeaderFooter(raw: HeaderFooterItem | undefined, meta: {
573
- title?: string;
574
- subtitle?: string;
575
- author?: string;
576
- version?: string;
577
- date?: string;
578
- company?: string;
579
- }): NormalizedHeaderFooter | undefined;
580
- /**
581
- * Centralized Single Source of Truth for resolving document configuration.
582
- * Priority hierarchy: Frontmatter metadata > Project Config File / User Config > DEFAULT_CONFIG
583
- */
584
- declare function resolveDocumentConfig(frontmatter?: Record<string, unknown>, userConfig?: MarkforgeConfig): ResolvedDocumentConfig;
585
-
586
1072
  /**
587
1073
  * Dynamically resolved version — reads from the nearest package.json at runtime.
588
1074
  * Falls back to the hardcoded FALLBACK_VERSION constant if not found.
@@ -593,4 +1079,4 @@ declare const MARKFORGE_VERSION: string;
593
1079
  */
594
1080
  declare function getMarkforgeVersion(fromDir?: string): string;
595
1081
 
596
- export { type CompilationResult, DEFAULT_CONFIG, type DocumentLayoutConfig, type DocumentMetadata, type DocumentOrientation, type FrontmatterMetadata, type GeneratedOutputFile, type HeaderFooterItem, type HeaderFooterSlot, MARKFORGE_VERSION, type MarkdownASTNode, type MarkdownInlineSpan, type MarkdownNodeType, type MarkforgeConfig, type MarkforgeFormat, type MarkforgeTheme, type NormalizedHeaderFooter, type NormalizedHeaderFooterZone, type NormalizedMargins, type NormalizedWatermark, Orientation, OutputFormat, PAPER_DIMENSIONS_TWIP, type PageMargins, type PaperSize, PaperSizeEnum, type ParsedMarkdownDocument, type ResolvedDocumentConfig, type ResolvedImage, SYNTAX_COLORS, 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, normalizeHeaderFooter, normalizeHeaderFooterSlot, normalizeWatermark, parseInlineSpans, parseMarginToTwip, parseMarkdownDocument, renderInlinesToHtml, renderMermaidToPng, replaceDocumentTokens, resolveDocumentConfig, resolveImage, slugify, tokenizeCodeLine };
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 };