Add go dependencies for mdtoc

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-07-21 14:00:47 -04:00
parent cb33c4ed26
commit 36959a4878
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
63 changed files with 12675 additions and 0 deletions

57
vendor/github.com/mmarkdown/mmark/mparser/title.go generated vendored Normal file
View file

@ -0,0 +1,57 @@
package mparser
import (
"log"
"github.com/BurntSushi/toml"
"github.com/gomarkdown/markdown/ast"
"github.com/mmarkdown/mmark/mast"
)
// TitleHook will parse a title and returns it. The start and ending can
// be signalled with %%% or --- (the later to more inline with Hugo and other markdown dialects.
func TitleHook(data []byte) (ast.Node, []byte, int) {
i := 0
if len(data) < 3 {
return nil, nil, 0
}
c := data[i] // first char can either be % or -
if c != '%' && c != '-' {
return nil, nil, 0
}
if data[i] != c || data[i+1] != c || data[i+2] != c {
return nil, nil, 0
}
i += 3
beg := i
found := false
// search for end.
for i < len(data) {
if data[i] == c && data[i+1] == c && data[i+2] == c {
found = true
break
}
i++
}
if !found {
return nil, nil, 0
}
node := mast.NewTitle(c)
buf := data[beg:i]
if c == '-' {
node.Content = buf
return node, nil, i + 3
}
if _, err := toml.Decode(string(buf), node.TitleData); err != nil {
log.Printf("Failure parsing title block: %s", err)
}
node.Content = buf
return node, nil, i + 3
}