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

@tenedev/markdom

v1.0.3

Published

A Markdown and HTML parser for Node.js with TOC generation and anchor support.

Readme

Markdom

npm downloads size maintenance Node.js contribute stars forks issues last commit workflow license

@tenedev/markdom is a Markdown parser for Node.js that effortlessly converts Markdown files into HTML with automatic Table of Contents (TOC) generation, heading anchors, and more. Whether you’re building docs, wikis, or simply rendering Markdown to HTML, Markdom makes it easy to transform your Markdown into a beautiful, navigable HTML structure.

🚀 Key Features

  • 📄 Markdown to HTML Parsing: Converts Markdown to clean HTML, maintaining the original structure and formatting.
  • 📑 Table of Contents (TOC): Automatically generates a TOC based on your Markdown headings.
  • 🔗 Anchor Links for Headings: Creates clickable anchor links for each heading, making navigation seamless.
  • 🎨 Customizable: Tailor the HTML and TOC generation to fit your needs.
  • 🖥️ CLI Support: Use the built-in CLI to quickly parse Markdown files and output HTML to a file.

🗂️ Table of Contents

🛠️ Installation

To get started with @tenedev/markdom, install it using your preferred package manager:

Using npm:

npm install @tenedev/markdom

Using yarn:

yarn add @tenedev/markdom

📋 Prerequisites

  • Node.js version 16.x or higher
  • Basic familiarity with Markdown syntax

🧑‍💻 How to Use

Node.js API

Import @tenedev/markdom into your project and start converting Markdown to HTML:

import { markdom } from '@tenedev/markdom';

// Example usage
const markdown = `# Example Heading\n\nThis is a sample markdown document.`;
const { html, toc } = markdom.parse(markdown);

console.log(html);
console.log(toc);

markdom.parse function returns:

  • html: The generated HTML content.
  • toc: An array of Table of Contents items, each containing:
    • id: Slugified heading ID
    • title: The heading text
    • level: Heading level (e.g., 1 for H1, 2 for H2, etc.)

📡 Command-Line Interface (CLI)

You can also use the powerful CLI provided by @tenedev/markdom to convert Markdown files directly from the terminal.

  1. Basic Usage:
npx @tenedev/markdom <input.md>
  1. With Output Option:
npx @tenedev/markdom <input.md> -o output.html

Note: The -o option supports only .html or .htm extensions. Other file types will trigger an error.


🛠️ API Documentation

markdom.parse(md: string): { html: string, toc: TOC[] }

Parameters:

  • md (string): The input Markdown string to be parsed.

Returns:

  • html (string): The resulting HTML content after parsing.
  • toc (array): An array representing the Table of Contents, with each item containing:
    • id (string): A slugified version of the heading.
    • title (string): The title of the heading.
    • level (number): The level of the heading (1 for H1, 2 for H2, etc.).

🗂️ Table of Contents (TOC) Generation

The Table of Contents (TOC) is automatically generated and inserted at the <!-- TOC-HERE --> comment in your Markdown. For example:

<!-- TOC-HERE -->

# Heading 1

Some content.

## Heading 2

More content.

Resulting TOC:

<nav class="markdown-toc">
  <ul>
    <li class="toc-level-1"><a href="#heading-1">Heading 1</a></li>
    <li class="toc-level-2"><a href="#heading-2">Heading 2</a></li>
  </ul>
</nav>

Rendering of Headings

Markdown headings automatically receive anchor links for easy navigation:

# Heading 1

This is rendered as:

<h1 id="heading-1">
  <a href="#heading-1" class="heading-anchor">🔗</a> Heading 1
</h1>

💻 Example Output

Input (Markdown):

<!-- TOC-HERE -->

# Introduction

This is a Markdown document.

## Subheading 1

Details about subheading 1.

## Subheading 2

Details about subheading 2.

Output (HTML):

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="description"
      content="Markdom is a Markdown and HTML parser for Node.js with TOC generation and anchor support."
    />
    <title>Markdown Output - @tenedev/markdom</title>
  </head>
  <body>
    <h1 id="introduction">
      <a href="#introduction" class="heading-anchor">🔗</a> Introduction
    </h1>
    <p>This is a Markdown document.</p>

    <h2 id="subheading-1">
      <a href="#subheading-1" class="heading-anchor">🔗</a> Subheading 1
    </h2>
    <p>Details about subheading 1.</p>

    <h2 id="subheading-2">
      <a href="#subheading-2" class="heading-anchor">🔗</a> Subheading 2
    </h2>
    <p>Details about subheading 2.</p>

    <nav class="markdown-toc">
      <ul>
        <li class="toc-level-1"><a href="#introduction">Introduction</a></li>
        <li class="toc-level-2"><a href="#subheading-1">Subheading 1</a></li>
        <li class="toc-level-2"><a href="#subheading-2">Subheading 2</a></li>
      </ul>
    </nav>
  </body>
</html>

🤝 Contributing

We welcome contributions from the community!

If you have ideas, suggestions, or bug reports, feel free to open an issue or submit a pull request on GitHub.

Let's make @tenedev/markdom better together!

📜 License

This project is licensed under the MIT License.
Copyright © TenEplaysOfficial