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

markdown-multilevel-numbering

v1.1.9

Published

Core library for markdown multilevel numbering

Downloads

1,000

Readme

Markdown Multilevel Numbering (mmn)

English | 中文

A tool for adding multilevel numbering to markdown documents, supporting both mainbody and appendix numbering modes with flexible control via directives.

1. Features

  • Mainbody mode numbering for headings and paragraphs: 1., 1.1., 1.1.1. ...
  • Appendix mode numbering for headings and paragraphs: A., A.1., A.1.1. ...
  • Appendix H2 heading format: Appendix A Heading
  • Flexible control of numbering behavior via directives
  • Level 1 headings never participate in numbering
  • Only processes content within the logical scope of the first H1; subsequent H1s and their content are ignored
  • Reliable AST-based parsing that protects code blocks, lists, tables, and math expressions from being accidentally modified

2. Control Directives

Insert control directives in markdown using HTML comments to control numbering behavior.

Comment format: <!-- mmn: command [command...] -->

| command | Description | | ---------- | --------------------------------------------------------- | | mainbody | Numbering mode directive, starts mainbody mode with default depth h | | appendix | Numbering mode directive, starts appendix mode with default depth h | | h | Depth directive, number all heading levels | | h+p | Depth directive, number all heading levels and paragraphs | | h2 | Depth directive, number level 2 headings only | | h3 | Depth directive, number level 2-3 headings | | h4 | Depth directive, number level 2-4 headings | | h5 | Depth directive, number level 2-5 headings | | h6 | Depth directive, number level 2-6 headings | | end | End numbering |

After program starts, it defaults to mainbody mode.

3. Coding Logic Examples

See doc/numbering-logic-demo.md

4. Implementation Approach

  • Parse markdown into AST
  • Traverse elements: extract directives, add numbering (update) / remove numbering (remove)
  • Convert AST back to markdown

5. Installation

Using npm:

npm install markdown-multilevel-numbering

Using pnpm:

pnpm add markdown-multilevel-numbering

6. Usage

import {
  updateText,
  removeText,
  updateFile,
  removeFile,
} from "markdown-multilevel-numbering";

// Process text
const numbered = updateText(markdownContent);
const cleaned = removeText(numberedContent);

// Process files directly
await updateFile("./input.md");
await removeFile("./numbered.md");

7. License

MIT