toc

command module
v0.0.0-...-65f5d4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 7 Imported by: 0

README

toc

Status GoDoc codecov Go Report Card

A simple table of contents generator for markdowns written in golang

Contents

  1. Install
  2. Usage
    1. Output to stdin
    2. Inplace update
    3. Custom heading IDs

Install

$ go get github.com/tvastar/toc

Usage

The table of contents of this README.md is itself maintaained using this tool.

Output to stdin
$ toc $(go env GOPATH)/src/github.com/tvastar/toc/README.md
## Table of Contents
1. [Contents](#contents)
2. [Install](#install)
3. [Usage](#usage)
    1. [Output to stdin](#output-to-stdin)
    2. [Inplace update](#inplace-update)
    3. [Custom heading IDs](#custom)
Inplace update
$ cd $(go env GOPATH)/src/github.com/tvastar/toc
$ toc -o README.md -h Contents README.md
Custom heading IDs

As with regular markdown, a custom heading ID may be specified via {#id} suffix to the heading line. This is properly parsed and used for headings.

Ignored

Top level sections are ignored by default

Documentation

Overview

Command main generates a TOC markdown representation of the provided markdown file.

The header option specifies what the header should be called.

The output option can be used to rewrite a similarly named section in the same markdown file

Usage

$ toc README.md > TOC.md
$ toc -h "Walkthrough" -o README.md README.md

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL