package main import ( "bytes" "flag" // "fmt" "io" "log" "os" "github.com/yuin/goldmark" "github.com/yuin/goldmark-meta" // "github.com/yuin/goldmark/extension" "github.com/yuin/goldmark/parser" ) func LoadNote(r io.Reader) (interface{}, error) { var buf bytes.Buffer markdown := goldmark.New( goldmark.WithExtensions( meta.Meta, ), ) context := parser.NewContext() io.Copy(&buf, r) if err := markdown.Convert(buf.Bytes(), &buf, parser.WithContext(context)); err != nil { return nil, err } metaData := meta.Get(context) log.Printf("%#+v\n", metaData) return nil, nil } func main() { var ( note string ) flag.StringVar(¬e, "note", "demo.md", "filename of test note") flag.Parse() f, err := os.Open(note) if err != nil { log.Fatalf("error opening markdown file: %s\n", err) } LoadNote(f) }