...
1
2
3
4
5 package godoc
6
7 import (
8 "bytes"
9
10 "github.com/yuin/goldmark"
11 "github.com/yuin/goldmark/parser"
12 "github.com/yuin/goldmark/renderer/html"
13 )
14
15
16
17
18
19
20 func renderMarkdown(src []byte) ([]byte, error) {
21
22
23 md := goldmark.New(
24 goldmark.WithParserOptions(parser.WithHeadingAttribute()),
25 goldmark.WithRendererOptions(html.WithUnsafe()))
26 var buf bytes.Buffer
27 if err := md.Convert(src, &buf); err != nil {
28 return nil, err
29 }
30 return buf.Bytes(), nil
31 }
32
View as plain text