tableofcontents

package
v0.91.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: Apache-2.0 Imports: 1 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	StartLevel: 2,
	EndLevel:   3,
	Ordered:    false,
}

DefaultConfig is the default ToC configuration.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Heading start level to include in the table of contents, starting
	// at h1 (inclusive).
	StartLevel int

	// Heading end level, inclusive, to include in the table of contents.
	// Default is 3, a value of -1 will include everything.
	EndLevel int

	// Whether to produce a ordered list or not.
	Ordered bool
}

type Heading added in v0.84.1

type Heading struct {
	ID   string
	Text string

	Headings Headings
}

Heading holds the data about a heading and its children.

func (Heading) IsZero added in v0.84.1

func (h Heading) IsZero() bool

IsZero is true when no ID or Text is set.

type Headings added in v0.84.1

type Headings []Heading

Headings holds the top level headings.

type Root

type Root struct {
	Headings Headings
}

Root implements AddAt, which can be used to build the data structure for the ToC.

func (*Root) AddAt

func (toc *Root) AddAt(h Heading, row, level int)

AddAt adds the heading into the given location.

func (Root) ToHTML

func (toc Root) ToHTML(startLevel, stopLevel int, ordered bool) string

ToHTML renders the ToC as HTML.

Jump to

Keyboard shortcuts

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