A Node.js CLI tool for converting Markdown files to DOCX and PDF formats with Mermaid diagram support, designed for global NPM distribution and npx execution.
graph TD
CLI[CLI Interface] --> Parser[Argument Parser]
Parser --> Validator[Input Validator]
Validator --> Processor[Document Processor]
Processor --> MermaidRenderer[Mermaid Renderer]
Processor --> MarkdownParser[Markdown Parser]
MermaidRenderer --> PuppeteerEngine[Puppeteer Engine]
MarkdownParser --> HTMLConverter[HTML Converter]
HTMLConverter --> DOCXConverter[DOCX Converter]
HTMLConverter --> PDFConverter[PDF Converter]
DOCXConverter --> PandocEngine[Pandoc Engine]
PDFConverter --> PuppeteerPDF[Puppeteer PDF Engine]
PandocEngine --> OutputHandler[Output Handler]
PuppeteerPDF --> OutputHandler
OutputHandler --> FileSystem[File System]
Responsibility: Command-line interface and user interaction
Files:
bin/markdownforge.js
- Executable entry pointsrc/cli/commander.js
- Command definitions and parsingsrc/cli/help.js
- Help system and usage documentationResponsibility: File validation and preprocessing
Files:
src/validators/fileValidator.js
- Input file validationsrc/validators/configValidator.js
- Configuration validationsrc/utils/fileUtils.js
- File system utilitiesResponsibility: Orchestrate conversion workflow
Files:
src/core/documentProcessor.js
- Main processing orchestratorsrc/core/conversionPipeline.js
- Conversion workflow managementsrc/core/tempFileManager.js
- Temporary file handlingResponsibility: Convert Mermaid diagrams to images
Files:
src/renderers/mermaidRenderer.js
- Main Mermaid processingsrc/renderers/diagramExtractor.js
- Extract diagrams from Markdownsrc/renderers/puppeteerManager.js
- Browser automation managementResponsibility: Handle specific format conversions
Files:
src/converters/docxConverter.js
- DOCX conversion logicsrc/converters/pdfConverter.js
- PDF conversion logicsrc/converters/htmlConverter.js
- Markdown to HTML conversionResponsibility: Handle output file generation and cleanup
Files:
src/output/outputManager.js
- Output file managementsrc/output/cleanupManager.js
- Temporary file cleanupsrc/output/reportGenerator.js
- Conversion reportssequenceDiagram
participant User
participant CLI
participant Processor
participant MermaidRenderer
participant Converters
participant FileSystem
User->>CLI: npx markdownforge input.md
CLI->>CLI: Parse arguments
CLI->>Processor: Initialize conversion
Processor->>MermaidRenderer: Extract & render diagrams
MermaidRenderer->>MermaidRenderer: Launch Puppeteer
MermaidRenderer->>Processor: Return diagram images
Processor->>Converters: Convert to target formats
Converters->>FileSystem: Generate output files
FileSystem->>User: Conversion complete
markdownforge/
├── bin/
│ └── fileconverter.js # Executable entry point
├── src/
│ ├── index.js # Main entry point
│ ├── core/
│ │ ├── documentProcessor.js # Main orchestrator
│ │ └── tempFileManager.js # Temp file handling
│ ├── validators/
│ │ └── fileValidator.js # Input validation
│ ├── renderers/
│ │ └── mermaidRenderer.js # Mermaid processing
│ ├── converters/
│ │ ├── docxConverter.js # DOCX conversion
│ │ └── pdfConverter.js # PDF conversion
│ ├── output/
│ │ └── outputManager.js # Output management
│ └── utils/
│ ├── configLoader.js # Configuration management
│ ├── errors.js # Error handling
│ └── logger.js # Logging system
├── tests/
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── fixtures/ # Test fixtures
├── docs/
│ ├── architecture.md # This document
│ ├── api.md # API documentation
│ └── examples/ # Usage examples
├── package.json # NPM configuration
├── README.md # Project documentation
├── .gitignore # Git ignore rules
└── .npmignore # NPM ignore rules
.markdownforgerc
)