Documentation
¶
Overview ¶
Package toc adds the ability to get a table of contents to the goldmark parser.
Example ¶
package main import ( "fmt" "io/ioutil" "log" toc "github.com/mdigger/goldmark-toc" ) func main() { var source = []byte(` # Title paragraph text ## Section *1* paragraph text ### Subsection *1.1* paragraph text ## Section *2* paragraph text ## Заголовок на русском `) toc, err := toc.Convert(source, ioutil.Discard) if err != nil { log.Fatal(err) } // fmt.Printf("%+v\n", info) for _, header := range toc { fmt.Printf("%+v\n", header) } }
Output: 1 {Level:1 Text:Title ID:title} {Level:2 Text:Section 1 ID:section-1} {Level:3 Text:Subsection 1.1 ID:subsection-1-1} {Level:2 Text:Section 2 ID:section-2} {Level:2 Text:Заголовок на русском ID:zagolovok-na-russkom}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Lang = ""
Lang define the default language for generating slug id fo headers.
Functions ¶
func WithIDs ¶
func WithIDs() parser.ParseOption
WithIDs return new initializer parser option with ID generator.
Types ¶
type ConverterFunc ¶
ConverterFunc is markdown converting function.
func Markdown ¶
func Markdown(m goldmark.Markdown) ConverterFunc
Markdown extends initialied goldmark.Markdown and return converter function.
func New ¶
func New(options ...goldmark.Option) ConverterFunc
New return markdown converter with table of content support.
Click to show internal directories.
Click to hide internal directories.