package tableofcontents
import "github.com/gohugoio/hugo/markup/tableofcontents"
Index ¶
- Variables
- type Builder
- func (b *Builder) AddAt(h *Heading, row, level int)
- func (b Builder) Build() *Fragments
- func (b *Builder) SetIdentifiers(ids []string)
- type Config
- type Fragments
- type Heading
- type Headings
Variables ¶
DefaultConfig is the default ToC configuration.
Empty is an empty ToC.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to build the ToC data structure.
func (*Builder) AddAt ¶
AddAt adds the heading to the ToC.
func (Builder) Build ¶
Build returns the ToC.
func (*Builder) SetIdentifiers ¶
SetIdentifiers sets the identifiers in the ToC.
type Config ¶
type Config struct { // Heading start level to include in the table of contents, starting // at h1 (inclusive). // <docsmeta>{ "identifiers": ["h1"] }</docsmeta> 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 Fragments ¶
type Fragments struct { // Headings holds the top level headings. Headings Headings // Identifiers holds all the identifiers in the ToC as a sorted slice. // Note that collections.SortedStringSlice has both a Contains and Count method // that can be used to identify missing and duplicate IDs. Identifiers collections.SortedStringSlice // HeadingsMap holds all the headings in the ToC as a map. // Note that with duplicate IDs, the last one will win. HeadingsMap map[string]*Heading }
Fragments holds the table of contents for a page.
func (*Fragments) ToHTML ¶
ToHTML renders the ToC as HTML.
type Heading ¶
Heading holds the data about a heading and its children.
func (Heading) IsZero ¶
IsZero is true when no ID or Text is set.
type Headings ¶
type Headings []*Heading
Headings holds the top level headings.
func (Headings) FilterBy ¶
FilterBy returns a new Headings slice with all headings that matches the given predicate. For internal use only.
Source Files ¶
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 13 hours ago –
Tools for package owners.