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 🙏

© 2024 – Pkg Stats / Ryan Hefner

markdown-it-auto-parnum

v2.0.0

Published

A markdown-it plugin for automatic paragraph numbering.

Downloads

6

Readme

build Coverage Status

Paragraph numbering for Markdown

This markdown-it plugin numbers paragraphs automatically.

Installation

yarn add markdown-it-auto-parnum

Usage

const md = require('markdown-it')()
  .use(require('markdown-it-auto-parnum'))
md.render('This is a paragraph.')

Options

This library has several options, most of which should not be needed under normal circumstances. These are (with their default values):

  • sign ('¶'): The sign used in Markdown files for manual numbering of paragraphs, and rendered as html attributes in the resulting html. Changing this setting will break cross-compatibility for Markdown documents.
  • delimiter ('.'): The character that will separate multi-level numbering schemes when none is explicitly provided in the Markdown.
  • addLinks (true): Whether the anchors for paragraphs should be rendered as links.
  • headingLevels (1): The maximum number of headings to include in multi-level paragraph numbers, unless explicitly specified in a document.
  • headingSign (''): A symbol or text that should be placed in the html id attribute given to numbered headings. For example, if this is set to "sec", the headers will be rendered with id="sec1".
  • numberedElements ('p'): A comma-separated list of HTML elements or markdown-it token types which should receive paragraph numbers. Only block-level elements can receive paragraph numbers. To give each fenced code block a paragraph number, one could set this to 'p,fence', where p is the HTML tag and fence is the markdown-it token type.
  • skippedElements ('footnote_block'): A comma-separted list of markdown-it token types only inside which any paragraphs should not be numbered. Only block-level elements with nesting can be skipped. To number blockquotes but not the paragraphs inside them, one could set the options { numberedElements: 'paragraph,blockquote', skippedElements: 'blockquote' }.

Multi-level numbering

If no numbering scheme is explicitly set within a document, this library will try to determine the best numbering scheme based on its headings. The algorithm for this is to number:

  • ...the lowest-level heading, i.e. h1, then h2, etc.
  • ...which occurs more than once in the document
  • ...up to the headingLevels setting.

So, by default a document with a single h1 and multiple h2 and h3 elements will receive paragraph numbers like 1.1, where the first number is incremented with each h2 element.

Explicit numbering within a document

Within a markdown document, numbering for a given paragraph or heading may be explicitly specified by adding the html attribute "¶". Using the markdown-it-attrs plugin, this would look like {¶=123} at the end of a block of text. For multi-level numbering, any non-numeric characters in a specified paragraph number will set the scheme for subsequent paragraph numbering; for example, if the first paragraph is numbered as {¶=1:1} then the next paragraph will automatically be numbered 1:2, and the next numbered heading will be 2, and the following paragraph 2:1, etc.

There are also a few control words for altering the automated paragraph numbering:

  • ¶=manual: For subsequent paragraphs, number only the ones that are explicitly specified in the Markdown.
  • ¶=auto or ¶=start or ¶=on: Number subsequent paragraphs automatically.
  • ¶=stop or ¶=off: Do not number subsequent paragraphs until numbering is turned on with an explicit number or auto, start, or on.
  • ¶=skip or ¶=none: Skip numbering for the specified paragraph only.