https://github.com/jceb/remark-format-cli
remark-based CLI formatter for Markdown files
https://github.com/jceb/remark-format-cli
cli deno github javascript markdown markdown-toc readme shell table-of-contents toc
Last synced: about 2 months ago
JSON representation
remark-based CLI formatter for Markdown files
- Host: GitHub
- URL: https://github.com/jceb/remark-format-cli
- Owner: jceb
- License: mit
- Created: 2022-12-07T15:48:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-30T16:58:55.000Z (10 months ago)
- Last Synced: 2025-03-17T21:44:06.805Z (2 months ago)
- Topics: cli, deno, github, javascript, markdown, markdown-toc, readme, shell, table-of-contents, toc
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remark-format-cli
remark-based CLI formatter for Markdown files, that generates table of contents.
- Source code:
[github.com/jceb/remark-format-cli](https://github.com/jceb/remark-format-cli)
- Deno module:
[deno.land/x/remark_format_cli](https://deno.land/x/remark_format_cli)## Table of Contents
1. [Usage](#usage)
2. [Install](#install)
3. [Configuration](#configuration)
4. [History](#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:
```bash
deno run --allow-read --allow-write https://deno.land/x/[email protected]/remark-format.js README.md
```Or with the locally [installed](#install) script:
```bash
remark-format README.md
```## Install
```bash
deno install --allow-read --allow-write https://deno.land/x/[email protected]/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`](./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`](https://github.com/remarkjs/remark-toc) and opted for
[`deno`](https://deno.land/) 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`](https://github.com/remarkjs/remark-toc)
plugin.TOC generators I've tried before:
- [ycd/toc](https://github.com/ycd/toc) - works well but the installation is a
bit of a struggle
- [gh-md-toc](https://github.com/ekalinin/github-markdown-toc) - doesn't support
ordered tocs