项目作者: mdigger

项目描述 :
This goldmark parser extension adds support for generating table of content
高级语言: Go
项目地址: git://github.com/mdigger/goldmark-toc.git
创建时间: 2019-12-19T19:00:05Z
项目社区:https://github.com/mdigger/goldmark-toc

开源协议:MIT License

下载


goldmark-toc

GoDoc

Goldmark extension for generating table of content.

  1. var source = []byte(`
  2. # Title
  3. paragraph text
  4. ## Section *1*
  5. paragraph text
  6. ### Subsection *1.1*
  7. paragraph text
  8. ## Section *2*
  9. paragraph text
  10. ## Заголовок на русском
  11. `)
  12. info, err := toc.Convert(source, ioutil.Discard)
  13. if err != nil {
  14. log.Fatal(err)
  15. }
  16. for _, header := range info.Headers {
  17. fmt.Printf("%+v\n", header)
  18. }
  1. {Level:1 Text:Title ID:title}
  2. {Level:2 Text:Section 1 ID:section-1}
  3. {Level:3 Text:Subsection 1.1 ID:subsection-1-1}
  4. {Level:2 Text:Section 2 ID:section-2}
  5. {Level:2 Text:Заголовок на русском ID:zagolovok-na-russkom}