Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added apps/cli/markforge/assets/company-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 48 additions & 4 deletions apps/cli/markforge/docs/full-all-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,58 @@ def check_environment():
> Use `--watch` flag during local authoring for instant live updates.

> [!IMPORTANT]
> Both Word Twips and CSS `@page` dimensions are accurately synchronized.
> Both Word Twips and CSS `@page` dimensions are accurately synchronized.## Heading 2### Heading 3
| Column 1 | Column 2 | Column 3 |
| :--- | :---: | ---: |
| Data A | Data B | Data C |
| Data D | Data E | Data F |

| Column 1 | Column 2 | Column 3 |
| :--- | :---: | ---: |
| Data A | Data B | Data C |
| Data D | Data E | Data F |

| Column 1 | Column 2 | Column 3 |
| :--- | :---: | ---: |
| Data A | Data B | Data C |
| Data D | Data E | Data F |


---

# Mathematical Foundations

MarkForge provides native KaTeX math compilation for both inline physics equations such as $E = mc^2$ and complex display block proofs[^euler]:

$$\oint_C \mathbf{B} \cdot d\mathbf{l} = \mu_0 \left( I_{\text{enc}} + \varepsilon_0 \frac{d\Phi_E}{dt} \right)$$

---

# Multi-Column Comparison

:::columns 2
:::col
### Cloud Architecture
- Globally distributed edge routing
- Low-latency WebSocket connections
- Automatic failover clustering
:::
:::col
### On-Premises Security
- Air-gapped deployment support
- Hardware Security Module (HSM) keys
- Strict local audit logging
:::
:::

---

# Benchmark Metrics

| Pipeline Component | Target Output | Processing Time | Quality Level |
| :--- | :--- | :---: | :---: |
| Native DOCX Packager | `sample.docx` | 45ms | Pixel-Perfect Word Layout |
| Headless Chromium | `sample.pdf` | 650ms | 300 DPI Vector PDF |
| HTML5 Bundler | `sample.html` | 18ms | Single Self-Contained File |
| Native DOCX Packager | `full-all-properties.docx` | 45ms | Pixel-Perfect Word Layout |
| Headless Chromium | `full-all-properties.pdf` | 650ms | 300 DPI Vector PDF |
| HTML5 Bundler | `full-all-properties.html` | 18ms | Single Self-Contained File |

[^euler]: Maxwell, J. C. (1865). A Dynamical Theory of the Electromagnetic Field. Philosophical Transactions of the Royal Society of London.
29 changes: 29 additions & 0 deletions apps/cli/markforge/examples/5-preview-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Example 5: Interactive Live-Reload Preview Server
* Demonstrates starting the programmatic preview server with SSE auto-reload.
*
* Author: Ma'sum (@masumrpg)
*/
import * as path from "node:path";
import { startPreviewServer } from "@masumdev/markforge";

async function main() {
const filePath = path.resolve(__dirname, "../docs/full-all-properties.md");
const port = 3000;

console.log("Starting MarkForge Live-Reload Preview Server...");
const server = await startPreviewServer({
filePath,
port,
open: true, // Automatically opens your default web browser
});

console.log(`Server is running at: ${server.url}`);
console.log(`Watching file: ${filePath}`);
console.log("Press Ctrl+C to terminate the server.");
}

main().catch((err) => {
console.error("Failed to start preview server:", err);
process.exit(1);
});
170 changes: 170 additions & 0 deletions apps/cli/markforge/examples/6-bulk-generation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/**
* Example 6: Bulk & Batch Document Generation
* Demonstrates compiling multiple documents in parallel from dynamic data and templates.
*
* Author: Ma'sum (@masumrpg)
*/
import * as path from "node:path";
import * as fs from "node:fs";
import { compileMarkdown, Theme, OutputFormat } from "@masumdev/markforge";

// Sample dataset: 5 enterprise quarterly department reports
const departmentReports = [
{
dept: "Engineering",
lead: "Alexander Wright",
budget: "$1,450,000",
status: "On Track",
kpis: ["99.99% Uptime", "38 Releases Shipped", "0 Security Breaches"],
},
{
dept: "Product Design",
lead: "Sarah Jenkins",
budget: "$620,000",
status: "Completed",
kpis: ["Design System 2.0", "14 Usability Labs", "NPS Score 78"],
},
{
dept: "Infrastructure & Security",
lead: "David Chen",
budget: "$890,000",
status: "On Track",
kpis: ["Multi-Region Failover", "Zero-Trust mTLS", "SOC2 Compliance"],
},
{
dept: "Finance & Operations",
lead: "Ma'sum",
budget: "$2,100,000",
status: "Reviewed",
kpis: ["18% Cost Optimization", "Clean Audit Report", "Automated Payroll"],
},
{
dept: "Customer Success",
lead: "Elena Rostova",
budget: "$480,000",
status: "Exceeded",
kpis: ["< 15min SLA Response", "96% CSAT Score", "Zero Churn Key Accounts"],
},
];

async function main() {
const outputDir = path.resolve(__dirname, "../.temp/bulk-reports");
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}

console.log(`Starting bulk compilation of ${departmentReports.length} department reports...`);
const startTime = Date.now();

// Parallel Batch Compilation using Promise.all
const results = await Promise.all(
departmentReports.map(async (data, index) => {
// 1. Construct dynamic Markdown template for each record
const markdown = `---
title: "${data.dept} - Quarterly Performance Report"
subtitle: "Executive Summary & Operational Review — Q3 2026"
author: "${data.lead}"
company: "Enterprise Global Holdings"
version: "1.0.${index + 1}"
date: "${new Date().toISOString().split("T")[0]}"
theme: "corporate"
toc: true
coverPage:
enabled: true
preset: "modern"
badge: "${data.status.toUpperCase()}"
badgeColor: "#ECFDFD"
badgeTextColor: "#0D998D"
footerText: "Confidential Internal Report — Masum Dev Monorepo"
numberHeadings:
enabled: true
depth: 2
---

# Executive Summary

This document presents the Q3 operational review for the **${data.dept}** division. Under the leadership of **${data.lead}**, the department maintained an allocated operating budget of **${data.budget}**.

> [!NOTE]
> Operational status for this period is verified as **${data.status}**.

---

# Key Performance Indicators

Below is the summary table of verified achievements for Q3:

| Metric Indicator | Status | Quarter Goal |
| :--- | :---: | ---: |
${data.kpis.map((kpi, i) => `| KPI #${i + 1}: ${kpi} | Passed | 100% |`).join("\n")}

---

# Strategic Architecture & Workflow

\`\`\`mermaid
graph LR
A[Planning] --> B(${data.dept} Pipeline)
B --> C{Review}
C -->|Approved| D[Execution]
C -->|Revisions| B
\`\`\`

---

:::columns 2
:::col
### Department Lead
- Name: ${data.lead}
- Role: Division Principal
- Office: Global HQ
:::
:::col
### Operational Metrics
- Budget: ${data.budget}
- Fiscal Period: Q3 2026
- Compliance: ISO 27001
:::
:::

---

# Signatures & Verification

Academic and administrative sign-off verification[^audit].

[^audit]: Verified by independent internal audit procedures pursuant to enterprise bylaws.
`;

const fileBaseName = `Report-${data.dept.toLowerCase().replace(/[^a-z0-9]+/g, "-")}.md`;
const tempMdPath = path.join(outputDir, fileBaseName);
fs.writeFileSync(tempMdPath, markdown, "utf-8");

// 2. Compile directly to DOCX, PDF, and HTML
const compileRes = await compileMarkdown(tempMdPath, {
to: [OutputFormat.DOCX, OutputFormat.PDF, OutputFormat.HTML],
outputDir,
theme: Theme.CORPORATE,
});

console.log(`[OK] Generated: ${data.dept} (${compileRes.files.length} files in ${compileRes.durationMs}ms)`);
return compileRes;
})
);

const totalDuration = Date.now() - startTime;
const totalFiles = results.reduce((acc, r) => acc + r.files.length, 0);

console.log("======================================================");
console.log(`Bulk generation completed successfully!`);
console.log(`Total Documents : ${departmentReports.length}`);
console.log(`Total Files : ${totalFiles} files (.docx, .pdf, .html)`);
console.log(`Total Time : ${totalDuration}ms (average ${Math.round(totalDuration / departmentReports.length)}ms/doc)`);
console.log(`Output Folder : ${outputDir}`);
console.log("======================================================");
}

main().catch((err) => {
console.error("Bulk generation error:", err);
process.exit(1);
});
8 changes: 8 additions & 0 deletions apps/cli/markforge/markforge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ export default defineConfig({
},
toc: true,
embedImages: true,

// Optional enterprise features (uncomment to activate):
// coverPage: { enabled: true, preset: "modern", logo: "./assets/company-logo.png", badge: "SPECIFICATION" },
// backCover: { enabled: true, preset: "corporate", logo: "./assets/company-logo.png" },
// numberHeadings: { enabled: true, depth: 3 },
// watermark: "CONFIDENTIAL",
// security: { userPassword: "open_password", ownerPassword: "admin_password", permissions: { modifying: false, copying: false } },
// math: true,
});
Loading
Loading