Skip to main content
Deno 2 is finally here šŸŽ‰ļø
Learn more
Module

x/remark_format_cli/README.md

remark-based CLI formatter for Markdown files
Go to Latest
File

remark-format-cli

remark-based CLI formatter for Markdown files, including table of contents genreation.

Contents

  1. Usage
  2. Install
  3. Configuration
  4. History

Usage

If you want to generate a table of contents in your markdown file, Add a heading called Contents before running the script. The table of contents will be added beneath the heading.

Format a Markdown file:

deno run --unstable --allow-read --allow-write https://deno.land/x/remark_format_cli@v0.0.8/remark-format.js README.md

Or with the locally installed script:

remark-format README.md

Install

deno install --unstable --allow-read --allow-write https://deno.land/x/remark_format_cli@v0.0.8/remark-format.js

Once installed, the local command remark-format will be available.

Configuration

Currently, there are no configuration or command line options. Hopefully, configuration options will be added in the future. For the moment, itā€™s very easy to customize the code directly in ./remark-format.js

History

There are many markdown table of contents generators. However, I havenā€™t found one yet that generates an ordered list and is well maintained. Furthermore, Iā€™d very much prefer a simple, if possible non-existent, installation process.

With this in mind, I found remark-toc and opted for deno as a runtime since it recently added support for NPM modules. This combination made it very simple to create a custom remark CLI that integrates the remark-toc plugin.

TOC generators Iā€™ve tried before:

  • ycd/toc - works well but the installation is a bit of a struggle
  • gh-md-toc - doesnā€™t support ordered tocs