npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

markdownforge

v0.0.4

Published

Forge professional documents from Markdown with DOCX and PDF support, including Mermaid diagrams and admonitions

Readme

MarkdownForge

A powerful Node.js CLI tool for forging professional documents from Markdown files to DOCX and PDF formats with full Mermaid diagram support and admonitions. Designed for seamless npx usage without installation.

npm version License: MIT Node.js CI

Features

  • 🚀 Zero Installation: Use directly with npx - no global installation required
  • 📄 Multiple Formats: Convert to both PDF and DOCX simultaneously
  • 🎨 Mermaid Diagrams: Full support for Mermaid diagrams with automatic rendering
  • ⚠️ Admonitions: Support for styled callout boxes (warning, note, tip, info, etc.)
  • 🎭 Themes: Multiple built-in themes for professional document styling
  • Fast: Optimized for quick execution and minimal resource usage
  • 🔧 Configurable: Extensive configuration options via CLI or config files
  • 🌐 Cross-Platform: Works on Windows, macOS, and Linux

Quick Start

# Forge a Markdown file to both PDF and DOCX
npx markdownforge document.md

# Forge to PDF only
npx markdownforge document.md --format pdf

# Forge with custom output directory
npx markdownforge document.md --output ./exports

# Forge with GitHub theme
npx markdownforge document.md --theme github --verbose

Installation

npx Usage (Recommended)

No installation required! Just use npx:

npx markdownforge your-document.md

Global Installation

npm install -g markdownforge
markdownforge your-document.md

Local Installation

npm install markdownforge
npx markdownforge your-document.md

Prerequisites

The tool will automatically check for dependencies and provide installation instructions if needed.

Usage

Basic Usage

npx markdownforge <input-file> [options]

Options

| Option | Short | Description | Default | |--------|-------|-------------|---------| | --format | -f | Output formats: pdf, docx, or pdf,docx | pdf,docx | | --output | -o | Output directory | ./output | | --name | -n | Base name for output files | Input filename | | --theme | -t | Theme: default, github, academic | default | | --diagram-format | | Diagram format: png, svg | png | | --verbose | -v | Enable verbose logging | false | | --help | -h | Show help information | | | --version | -V | Show version number | |

Examples

# Basic forging
npx markdownforge README.md

# PDF only with custom name
npx markdownforge docs/guide.md --format pdf --name user-guide

# Academic theme with verbose output
npx markdownforge thesis.md --theme academic --verbose

# Custom output directory
npx markdownforge report.md --output ./exports --name final-report

Mermaid Diagram Support

The tool automatically detects and renders Mermaid diagrams in your Markdown files:

```mermaid
graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Action 1]
    B -->|No| D[Action 2]
    C --> E[End]
    D --> E
```

Supported diagram types:

  • Flowcharts
  • Sequence diagrams
  • Class diagrams
  • State diagrams
  • Gantt charts
  • Pie charts
  • And more!

Admonition Support

FileConverter CLI supports styled admonitions (callout boxes) for highlighting important information:

!!! warning "Custom Title"
    This is a warning admonition with a custom title.

!!! note
    This is a note admonition with the default "Note" title.

Supported Admonition Types

| Type | Icon | Use Case | |------|------|----------| | warning | ⚠️ | Warnings and cautions | | note | 📝 | Important notes | | info | ℹ️ | Additional information | | tip | 💡 | Helpful tips and suggestions | | success | ✅ | Success messages | | error | ❌ | Error messages | | danger | 🚨 | Critical warnings |

Admonition Syntax

!!! type "Optional Custom Title"
    Content goes here with 4-space indentation.
    
    Multiple paragraphs are supported.
    
    You can use **bold**, *italic*, and `code` formatting.

Admonitions are rendered with:

  • PDF: Colored borders, backgrounds, and icons
  • DOCX: Styled text boxes with colored borders and backgrounds

See examples/admonitions-demo.md for comprehensive examples.

Configuration

MarkdownForge supports extensive configuration for customizing conversion settings. Create a configuration file in your project root using any of these formats:

  • .markdownforgerc (JSON)
  • .markdownforgerc.json
  • .markdownforgerc.yaml / .markdownforgerc.yml
  • .markdownforgerc.js
  • markdownforge.config.js
  • package.json (under markdownforge key)

Basic Configuration

{
  "format": ["pdf", "docx"],
  "output": "./output",
  "theme": "default",
  "diagramFormat": "png",
  "verbose": false
}

Advanced DOCX Formatting

Customize DOCX output with detailed formatting options:

{
  "docx": {
    "formatting": {
      "headingSpacing": {
        "before": 400,
        "after": 200
      },
      "paragraphSpacing": {
        "before": 0,
        "after": 150
      },
      "sectionSpacing": {
        "before": 300,
        "after": 200
      },
      "fontSize": 22,
      "headingFontSizes": {
        "h1": 32,
        "h2": 28,
        "h3": 24,
        "h4": 22,
        "h5": 20,
        "h6": 18
      },
      "colors": {
        "headings": "2E74B5",
        "text": "000000",
        "code": "D73A49"
      },
      "alignment": {
        "paragraphs": "justified",
        "headings": "left"
      }
    }
  }
}

PDF Configuration

{
  "pdf": {
    "format": "A4",
    "margin": {
      "top": "1in",
      "right": "1in",
      "bottom": "1in",
      "left": "1in"
    },
    "displayHeaderFooter": false,
    "printBackground": true
  }
}

Mermaid Diagram Configuration

{
  "mermaid": {
    "theme": "default",
    "backgroundColor": "white",
    "width": 800,
    "height": 600
  }
}

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | format | Array | ["pdf", "docx"] | Output formats | | output | String | "./output" | Output directory | | theme | String | "default" | Document theme | | diagramFormat | String | "png" | Diagram output format | | verbose | Boolean | false | Enable verbose logging |

DOCX Formatting Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | headingSpacing.before | Number | 400 | Space before headings (twips) | | headingSpacing.after | Number | 200 | Space after headings (twips) | | paragraphSpacing.before | Number | 0 | Space before paragraphs (twips) | | paragraphSpacing.after | Number | 150 | Space after paragraphs (twips) | | sectionSpacing.before | Number | 300 | Space before sections (twips) | | sectionSpacing.after | Number | 200 | Space after sections (twips) | | fontSize | Number | 22 | Default font size (half-points) | | headingFontSizes.h1-h6 | Number | Various | Heading font sizes (half-points) | | colors.headings | String | "2E74B5" | Heading color (hex) | | colors.text | String | "000000" | Text color (hex) | | colors.code | String | "D73A49" | Code color (hex) | | alignment.paragraphs | String | "justified" | Paragraph alignment: left, center, right, justified | | alignment.headings | String | "left" | Heading alignment: left, center, right, justified |

Note: Spacing values are in twips (1/20th of a point). Font sizes are in half-points (22 = 11pt).

Example Configuration File

Copy the example configuration and customize as needed:

cp .markdownforgerc.example .markdownforgerc

Environment Variables

# Disable anonymous usage analytics
export MARKDOWNFORGE_ANALYTICS=false

# Custom temporary directory
export MARKDOWNFORGE_TEMP_DIR=/custom/temp/path

Themes

Available Themes

| Theme | Description | Best For | |-------|-------------|----------| | default | Clean, professional styling | General documents | | github | GitHub-flavored styling | Technical documentation | | academic | Academic paper formatting | Research papers, reports |

Custom Themes

You can create custom themes by providing CSS files:

npx markdownforge document.md --theme ./custom-theme.css

API Usage

You can also use MarkdownForge programmatically:

const { DocumentProcessor } = require('markdownforge');

const processor = new DocumentProcessor({
  format: ['pdf', 'docx'],
  theme: 'github',
  verbose: true
});

async function forge() {
  try {
    const result = await processor.processDocument('./input.md');
    console.log('Forging completed:', result.outputs);
  } catch (error) {
    console.error('Forging failed:', error.message);
  }
}

forge();

Architecture

MarkdownForge is built with a modular architecture:

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   CLI Interface │────│ Document         │────│ Output          │
│                 │    │ Processor        │    │ Manager         │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                │
                    ┌───────────┼───────────┐
                    │           │           │
            ┌───────▼────┐ ┌────▼────┐ ┌───▼──────┐
            │  Mermaid   │ │  DOCX   │ │   PDF    │
            │  Renderer  │ │Converter│ │Converter │
            └────────────┘ └─────────┘ └──────────┘

For detailed architecture documentation, see docs/architecture.md.

Performance

Benchmarks

| Document Size | Processing Time | Memory Usage | |---------------|----------------|--------------| | Small (< 1MB) | < 5 seconds | < 100MB | | Medium (1-10MB) | < 30 seconds | < 200MB | | Large (> 10MB) | < 2 minutes | < 500MB |

Optimization Features

  • Concurrent Processing: Diagrams rendered in parallel
  • Resource Management: Automatic cleanup of temporary files
  • Caching: Intelligent diagram caching to avoid re-rendering
  • Memory Optimization: Streaming for large files

Troubleshooting

Common Issues

Pandoc Not Found

Error: Pandoc not found. Please install Pandoc to enable DOCX conversion.

Solution: Install Pandoc from pandoc.org

Puppeteer Launch Failed

Error: Failed to launch Chrome browser

Solution: Install Chrome dependencies:

  • Ubuntu/Debian: sudo apt-get install -y chromium-browser
  • CentOS/RHEL: sudo yum install -y chromium

Permission Denied

Error: EACCES: permission denied, mkdir './output'

Solution: Check directory permissions or use a different output directory

Debug Mode

Enable verbose logging for detailed troubleshooting:

npx markdownforge document.md --verbose

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/rauofthameem/markdownforge.git
cd markdownforge

# Install dependencies
npm install

# Run tests
npm test

# Run in development mode
npm start -- your-test-file.md

Testing

# Run all tests
npm test

# Run unit tests only
npm run test:unit

# Run integration tests only
npm run test:integration

# Run tests in watch mode
npm run test:watch

Roadmap

  • [ ] Plugin System: Support for custom converters and themes
  • [ ] Batch Processing: Convert multiple files simultaneously
  • [ ] Watch Mode: Auto-convert on file changes
  • [ ] Template Support: Custom document templates
  • [ ] Cloud Integration: Direct upload to cloud storage
  • [ ] Web Interface: Browser-based conversion tool

License

MIT License - see the LICENSE file for details.

Support

Acknowledgments


Made with ❤️ for forging beautiful documents

NPM