toc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 7 Imported by: 0

README

toc

Table of contents

Summary

A tool to generate table of contents section within a Markdown file from a list of paths or headers found in a document.

Manual

$ notatio toc --help
NAME:
   notatio toc

USAGE:
   notatio toc [command options]

DESCRIPTION:
   Table of contents generator.

COMMANDS:
   int      Generate table of content from headers within a document 
              e.g. toc --document=README.md --header="Table of contents" --limiter-right="##" int.
   ext      Generate table of content within a document and use provided paths as a list 
              e.g. toc --document=README.md --header="Table of contents" --limiter-right="##" ext --path=one/document.md --path=two/document.md.
   help, h  Shows a list of commands or help for one command

OPTIONS:
   --document value       markdown file path to be updated
   --header value         header to use for document lookups and generation
   --limiter-left value   string to use as a lookup limiter (default: "##")
   --limiter-right value  string to use as a lookup limiter - empty will use end of file as a limit (default: "##")
   --help, -h             show help

Usage

Example

Original Markdown file content
...

## Table of contents

  - [Summary](#summary)
  - [Manual](#manual)
  - [Usage](#usage)
  - [Example](#example)
    - [Original Markdown file content](#original-markdown-file-content)
    - [Command](#command)
    - [Result Markdown file content](#result-markdown-file-content)

## Summary

...
Command

The following command will take all provided paths and generate a list of links within a document.

notatio toc --document=README.md --header="Table of contents" --limiter-right=## ext --path=one/one.md --path=two/two.md
Result Markdown file content
...

## Table of contents

  - [Summary](#summary)
  - [Manual](#manual)
  - [Usage](#usage)
  - [Example](#example)
    - [Original Markdown file content](#original-markdown-file-content)
    - [Command](#command)
    - [Result Markdown file content](#result-markdown-file-content)

## Summary

...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var App = cli.Command{
	Name:         "toc",
	Aliases:      nil,
	Usage:        "",
	UsageText:    "",
	Description:  "Table of contents generator.",
	ArgsUsage:    "",
	Category:     "",
	BashComplete: nil,
	Before:       before,
	After:        nil,
	Action:       nil,
	OnUsageError: nil,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "document",
			Usage:    "markdown file path to be updated",
			Required: true,
		},
		&cli.StringFlag{
			Name:     "header",
			Usage:    "header to use for document lookups and generation",
			Required: true,
		},
		&cli.StringFlag{
			Name:  "limiter-left",
			Usage: "string to use as a lookup limiter",
			Value: "##",
		},
		&cli.StringFlag{
			Name:  "limiter-right",
			Usage: "string to use as a lookup limiter - empty will use end of file as a limit",
			Value: "##",
		},
	},
	Subcommands: []*cli.Command{
		{
			Name: "int",
			Usage: `Generate table of content from headers within a document 
	e.g. toc --document=README.md --header="Table of contents" --limiter-right="##" int.`,
			Flags: []cli.Flag{
				&cli.IntFlag{
					Name:     "start-from-level",
					Usage:    "indicate what level of headers to start from",
					Required: false,
					Value:    0,
				},
				&cli.IntFlag{
					Name:     "start-from-item",
					Usage:    "indicate what item from the list to start from",
					Required: false,
					Value:    0,
				},
			},
			Action: internal,
		},
		{
			Name: "ext",
			Usage: `Generate table of content within a document and use provided paths as a list 
	e.g. toc --document=README.md --header="Table of contents" --limiter-right="##" ext --path=one/document.md --path=two/document.md.`,
			Flags: []cli.Flag{
				&cli.StringSliceFlag{
					Name:  "path",
					Usage: "path to be included in the table of contents",
				},
				&cli.StringFlag{
					Name:     "summary-header",
					Usage:    "summary header to use for document lookups",
					Required: true,
				},
				&cli.StringFlag{
					Name:  "summary-limiter-left",
					Usage: "string to use as a summary lookup limiter",
					Value: "##",
				},
				&cli.StringFlag{
					Name:  "summary-limiter-right",
					Usage: "string to use as a summary lookup limiter - empty will use end of file as a limit",
					Value: "##",
				},
			},
			Action: external,
		},
	},
}

App main application.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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