Categories: None [Edit]

mdtoc

https://rubygems.org/gems/mdtoc
https://github.com/andornaut/mdtoc
# mdtoc - Markdown Table of Contents [![CI](https://github.com/andornaut/mdtoc/actions/workflows/release.yml/badge.svg)](https://github.com/andornaut/mdtoc/actions/workflows/release.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) Read Markdown files and output a table of contents. ## Installation Requirements: * [Ruby](https://www.ruby-lang.org/en/) (see [.ruby-version](./.ruby-version)) ```bash gem install mdtoc ``` ## Usage ```bash mdtoc --help Usage: mdtoc [options] files or directories... -h, --help Show this message -o, --output PATH Update a table of contents in the file at PATH -a, --[no-]append Append to the --output file if a tag isn't found -c, --[no-]create Create the --output file if it does not exist ``` 1. Add a `` tag to a Markdown file. ```bash echo '' >> README.md ``` 2. Run `mdtoc` and specify input files or directories (eg. the "test/samples" directory) and an output file (eg. "README.md"). ```bash mdtoc -aco README.md test/samples ``` ## Example Rakefile Create a `Rakefile` with the contents below, then run [`rake`](https://github.com/ruby/rake) to: * Run `mdtoc` to update the generated table of contents in the ./README.md file * `git add` any `*.md` files * Git commit, pull, and push any changes ```ruby task default: %w[mdtoc] desc 'Update Markdown table of contents and push changes to the git repository' task :mdtoc do command = <<~CMD set -e if [ -n "$(git diff --name-only --diff-filter=U)" ]; then echo 'Error: conflicts exist' >&2 exit 1 fi mdtoc --append --create --output README.md docs/ git add README.md docs/*.md git commit -qm 'Update TOC' || true git pull git push CMD sh command, verbose: false do |ok, status| unless ok fail "Failed with status: #{status.exitstatus}" end end end ``` See [and...

Total

Ranking: 107,309 of 197,941
Downloads: 7,793

Daily

Ranking: 45,920 of 197,891
Downloads: 10

Depended by

RankDownloadsName

Depends on

RankDownloadsName
81,450,183,950rake
141,329,779,666minitest
55767,344,678rubocop
343157,508,190sorbet-runtime
530104,212,299unparser
92658,110,206sorbet
1,45231,624,383rubocop-sorbet

Owners

#GravatarHandle
1iconandornaut