internal/markdown/markdown.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | package markdown
import (
"io"
fences "github.com/stefanfritsch/goldmark-fences"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
htmlrenderer "github.com/yuin/goldmark/renderer/html"
"gitlab.com/tozd/go/errors"
)
var markdown = goldmark.New(
goldmark.WithRendererOptions(
htmlrenderer.WithUnsafe(),
),
goldmark.WithExtensions(
extension.GFM,
extension.Footnote,
extension.Typographer,
&fences.Extender{},
),
)
func Convert(content []byte, w io.Writer) errors.E {
return errors.WithStack(markdown.Convert(content, w))
}
|