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

@mmsc/md-document-converter

v1.0.0

Published

Convert Markdown files to HTML, PDF, or Word documents with plugin support and robust logging.

Readme

Markdown Document Converter

A TypeScript-based tool for converting Markdown files to HTML, PDF, or Word documents. Features plugin-based extensions and comprehensive logging via Winston.

Features

  • Multi-Format Conversion: Transform Markdown files to HTML, PDF, or Word (docx)
  • Comprehensive Logging: Track all operations via console and file logging
  • Plugin Architecture: Extend functionality with pre- and post-conversion plugins
  • Robust Error Handling: Detailed error reporting for efficient debugging

Installation

Install via npm:

npm install -g md-document-converter

Or clone and install manually:

git clone https://github.com/yourusername/md-document-converter.git
cd md-document-converter
npm install

CLI Usage

Convert documents using the command-line interface:

mdconvert <inputFile> [options]

Options

  • -f, --format <format>: Output format (html, pdf, docx)
  • -o, --output <outputPath>: Output file path
  • -c, --css <cssFile>: CSS file for HTML/PDF styling
  • -h, --help: Display help information

Example

Convert to PDF:

mdconvert input.md -f pdf -o output/document.pdf

Programmatic Usage

import { convertMarkdown } from './dist/converter';
import { ConversionOptions } from './dist/types';

const options: ConversionOptions = {
  outputFormat: 'pdf',
  outputPath: 'output/document.pdf',
  metadata: {
    title: 'Converted Document',
    author: 'John Doe'
  },
  cssFile: 'styles/custom.css',
  plugins: [
    {
      beforeConvert: async (content) => {
        return content.replace(/foo/g, 'bar');
      }
    }
  ]
};

convertMarkdown('input.md', options)
  .then((result) => console.log('Conversion succeeded:', result))
  .catch((error) => console.error('Conversion failed:', error));

Logging

The project utilizes Winston for comprehensive logging:

  • Console Output: Real-time logging in the terminal
  • File Logging: Persistent logs stored in logs/conversion.log
  • Log Levels: Configurable levels for errors, warnings, and info messages

Example log entries:

2024-11-13T12:00:00 [ERROR]: FileReadError: Input file not found: input.md
2024-11-13T12:01:00 [INFO]: Conversion succeeded. Output saved at output/document.pdf

Error Handling

Custom error classes provide detailed error information:

  • FileReadError: File access and reading issues
  • ConversionError: Conversion process failures
  • PluginError: Plugin execution problems

Example usage:

import { FileReadError } from './dist/types';

try {
  // File operations
} catch (error) {
  if (error instanceof FileReadError) {
    console.error('File read failed:', error.message);
  }
}

Plugin System

Extend functionality with custom plugins:

const customPlugin: ConverterPlugin = {
  beforeConvert: async (content, options) => {
    return content.replace(/foo/g, 'bar');
  },
  afterConvert: async (result) => {
    console.log('Post-conversion action:', result);
  }
};

Plugin Hooks

  • beforeConvert(content, options): Pre-conversion content modification
  • afterConvert(result): Post-conversion processing

Quick Start

Convert a Markdown file to PDF:

import { convertMarkdown } from './dist/converter';

convertMarkdown('input.md', { outputFormat: 'pdf' })
  .then((result) => console.log('Conversion successful:', result))
  .catch((error) => console.error('Error during conversion:', error));

Contributing

  1. Fork the repository
  2. Clone your fork:
git clone https://github.com/yourusername/md-document-converter.git
  1. Create a feature branch:
git checkout -b feature/your-feature-name
  1. Make your changes
  2. Commit changes:
git commit -m "Add your commit message here"
  1. Push to your fork:
git push origin feature/your-feature-name
  1. Open a Pull Request

Please ensure your code follows our style guidelines and includes appropriate documentation.

License

MIT License