JSPM

mdast-sort-lists

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q23994F
  • License MIT

Transforms a Markdown Abstract Syntax Tree (mdast) so that list items are naturally sorted.

Package Exports

  • mdast-sort-lists

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mdast-sort-lists) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mdast-sort-lists

Transforms a Markdown Abstract Syntax Tree (mdast) so that list items are naturally alphabetized. Mutates the input AST.

Installation

npm install mdast-sort-lists

Usage

const fs = require("fs");
const remarkParse = require("remark-parse");
const remarkStringify = require("remark-stringify");
const sortLists = require("mdast-sort-lists");

const doc = fs.readFileSync("test/unsorted.md")

const tree = unified().use(remarkParse).parse(doc);
sortLists(tree);
const sorted = unified().use(remarkStringify).stringify(tree);

Markdown input:

# Animals

- Zoo Animals
  - Herbivores
    - Zebra
    - Gazelle
  - Omnivores
    - Gorilla
    - Baboon
    - Chimpanzee
  - Carnivores
    - Tiger
    - Lion
- Domestic Animals
  - Felines
    - Tabby
    - Bengal
    - Siamese
  - Canines
    - German Shepherd
    - Cocker Spaniel

Markdown output:

# Animals

- Domestic Animals
  - Canines
    - Cocker Spaniel
    - German Shepherd
  - Felines
    - Bengal
    - Siamese
    - Tabby
- Zoo Animals
  - Carnivores
    - Lion
    - Tiger
  - Herbivores
    - Gazelle
    - Zebra
  - Omnivores
    - Baboon
    - Chimpanzee
    - Gorilla

License

MIT