Documentation ¶
Overview ¶
Package withtoc adds the ability to get a table of contents to the goldmark parser.
Example ¶
package main import ( "fmt" "io/ioutil" "log" withtoc "github.com/mdigger/goldmark-withtoc" ) func main() { var source = []byte(` # Title paragraph text ## Section *1* paragraph text ### Subsection *1.1* paragraph text ## Section *2* paragraph text `) toc, err := withtoc.Convert(source, ioutil.Discard) if err != nil { log.Fatal(err) } for _, header := range toc { fmt.Printf("%+v\n", header) } }
Output: {ID:toc:01 Level:1 Text:Title} {ID:toc:02 Level:2 Text:Section 1} {ID:toc:03 Level:3 Text:Subsection 1.1} {ID:toc:04 Level:2 Text:Section 2}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var IDFormat = "toc:%02d"
IDFormat define the format of generated header ID.
Functions ¶
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.