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

@lbevilacqua/markdown-it-fancy-lists

v1.1.1

Published

Extension for markdown-it to support additional numbering types for ordered lists

Downloads

1

Readme

NPM version

markdown-it-fancy-lists

Plugin for the markdown-it markdown parser.

Uses unofficial markdown syntax based on the syntax supported by Pandoc. See the section Syntax below for details.

Installation

This library can be installed from the NPM package registry. Using NPM:

npm install markdown-it-fancy-lists

or Yarn

yarn add markdown-it-fancy-lists

Usage

ES module:

import * as MarkdownIt from "markdown-it";
import { markdownItFancyListPlugin } from "markdown-it-fancy-lists";

const parser = new MarkdownIt("default");
parser.use(markdownItFancyListPlugin);
parser.render(/* markdown string */);

CommonJS:

const MarkdownIt = require('markdown-it');
const markdownItFancyListPlugin = require("markdown-it-fancy-lists").markdownItFancyListPlugin;

const parser = new MarkdownIt("default");
parser.use(markdownItFancyListPlugin);
parser.render(/* markdown string */);

Syntax

The supported markdown syntax is based on the one used by Pandoc.

A simple example:

i. foo
ii. bar
iii. baz

The will yield HTML output like:

<ol type="i">
  <li>foo</li>
  <li>bar</li>
  <li>baz</li>
</ol>

A more complex example:

c. charlie
#. delta
   iv) subfour
   #) subfive
   #) subsix
#. echo

A short description of the syntactical rules:

  • Apart from numbers, also letters (uppercase or lowercase) and Roman numerals (uppercase or lowercase) can be used to number ordered list items. Like lists marked with numbers, they need to be followed by a single right-parenthesis or period.
  • Changing list marker types (also between uppercase and lowercase, or the symbol after the 'number') starts a new list.
  • The numeral of the first item determines the numbering of the list. If the first item is numbered "b", the next item will be numbered "c", even if it is marked "z" in the source. This corresponds to the normal markdown-it behavior for numeric lists, and essentially also implements Pandoc's startnum extension.
  • If the first list item is numbered "I" or "i", the list is considered to be numbered using Roman numerals, starting at 1. If the list starts with another single letter that could be interpreted as a Roman numeral, the list is numbered using letters: a first item marked with "C." uses uppercase letters starting at 3, not Roman numerals starting a 100.
  • In subsequent list items, such symbols can be used without any ambiguity: in "B.", "C.", "D." the "C" is the letter "C"; in "IC.", "C.", "CI." the "C" is a Roman 100.
  • A "#" may be used in place of any numeral to continue a list. If the first item in a list is marked with "#", that list is numbered "1", "2", "3", etc.
  • A list marker consisting of a single uppercase letter followed by a period (including Roman numerals like "I." or "V.") needs to be followed by at least two spaces (rationale).

All of the above are entirely compatible with how Pandoc works. There are two small differences with Pandoc's syntax:

  • This plugin does not support list numbers enclosed in parentheses, as the Commonmark spec does not support these either for lists numbered with Arabic numerals.
  • Pandoc does not allow any list to interrupt a paragraph. In the spirit of the Commonmark spec (which allows only lists starting with 1 to interrupt a paragraph), this plugins allows lists that start with "A", "a", "I" or "i" (i.e. all 'first numerals') to interrupt a paragraph. The same holds for the "#" generic numbered list item marker.

Configuration

Options can be provided as a second argument when registering the plugin:

parser.use(markdownItFancyListPlugin, {
    /* options */
});

Supported configuration options:

  • allowOrdinal - Whether to allow an ordinal indicator (º) after the numeral, as occurs in e.g. legal documents (default: false). If this option is enabled, input like

    1º. foo
    2º. bar
    3º. baz

    will be converted to

    <ol class="ordinal">
      <li>foo</li>
      <li>bar</li>
      <li>baz</li>
    </ol>

    You will need custom CSS to re-insert the ordinal indicator into the displayed output based on the ordinal class.

    Because the ordinal indicator is commonly confused with other characters like the degree symbol, these characters are tolerated and considered equivalent to the ordinal indicator.

Versioning

This project adheres to Semantic Versioning.

Contributing

Contributions to this project are more than welcome. When reporting an issue, please include the input to reproduce the issue, along with the expected output. When submitting a PR, please include tests with your changes.

License

This project is released under the MIT license.