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 🙏

© 2025 – Pkg Stats / Ryan Hefner

markdowntorender

v1.0.9

Published

A renderer for markdown with extensive feature support

Readme

MarkdownToRender

A powerful renderer for Markdown with extensive feature support including math formulas (KaTeX), diagrams (Mermaid), and code syntax highlighting.

Installation

npm install markdowntorender

Features

  • Markdown rendering - High-quality Markdown to HTML conversion
  • Math formulas - Render mathematical expressions using KaTeX
  • Diagrams - Create diagrams using Mermaid syntax
  • Syntax highlighting - Code blocks with syntax highlighting via highlight.js

Basic Usage

import { renderMarkdown, renderMarkdownToHtml } from 'markdowntorender';

// Basic markdown rendering
const result = renderMarkdown('# Hello World');
console.log(result.html); // "<h1>Hello World</h1>"

// Complete HTML document with all features
const html = renderMarkdownToHtml(`
# Document with Features

## Math formula

$E = mc^2$

## Diagram

\`\`\`mermaid
graph TD
    A[Start] --> B[Process]
    B --> C[End]
\`\`\`

## Code

\`\`\`javascript
function hello() {
  console.log("Hello world!");
}
\`\`\`
`);

// Write to file
const fs = require('fs');
fs.writeFileSync('output.html', html);

Rendering a Markdown File

import { renderMarkdownFile } from 'markdowntorender';

renderMarkdownFile('input.md', 'output.html', {
  title: 'My Document',
  lang: 'en'
});

API Reference

Main Functions

  • renderMarkdown(markdown, options) - Renders markdown to HTML with all features
  • renderMarkdownToHtml(markdown, options) - Renders a complete HTML document
  • renderMarkdownFile(inputPath, outputPath, options) - Renders a markdown file to HTML
  • createMarkdownRenderer(options) - Creates a configured markdown-it instance

Component Functions

  • getKaTexResources(options) - Get KaTeX resource tags
  • processMathFormulas(html, options) - Process math formulas in HTML
  • getMermaidResources(options) - Get Mermaid resource tags
  • processMermaidDiagrams(html, options) - Process Mermaid diagrams in HTML
  • getHighlightJsResources(options) - Get highlight.js resource tags
  • processCodeBlocks(html, options) - Process code blocks for syntax highlighting

Configuration Options

Markdown Options

const options = {
  markdown: {
    html: true,          // Enable HTML tags
    breaks: false,       // Convert '\n' to <br>
    linkify: true,       // Autoconvert URLs to links
    typographer: true    // Enable typographic replacements
  }
};

KaTeX Options

const options = {
  katex: {
    version: '0.16.9',   // KaTeX version
    displayMode: false,  // Display mode for all formulas
    autoRender: true,    // Auto-render formulas
    configOverrides: {}  // Additional KaTeX configuration
  }
};

Mermaid Options

const options = {
  mermaid: {
    version: '10.6.1',   // Mermaid version
    darkMode: false,     // Use dark theme
    startOnLoad: true,   // Initialize on page load
    configOverrides: {}  // Additional Mermaid configuration
  }
};

Syntax Highlighting Options

const options = {
  highlight: {
    version: '11.9.0',           // highlight.js version
    theme: 'default',            // CSS theme
    languages: ['python', 'js'], // Additional languages
    autoInit: true,              // Initialize on page load
    configOverrides: {}          // Additional configuration
  }
};

Complete Example

import { renderMarkdownToHtml } from 'markdowntorender';

const html = renderMarkdownToHtml(markdownContent, {
  title: 'My Document',
  lang: 'en',
  markdown: {
    html: true,
    breaks: true
  },
  katex: {
    displayMode: false
  },
  mermaid: {
    darkMode: true
  },
  highlight: {
    theme: 'github',
    languages: ['javascript', 'python', 'css']
  }
});

License

MIT