1// Package markup is an umbrella package for all markups and their renderers.
2package markup
3
4import (
5 "bytes"
6
7 "github.com/yuin/goldmark"
8 "github.com/yuin/goldmark/extension"
9 "github.com/yuin/goldmark/parser"
10)
11
12func RenderMarkdown(source string) string {
13 md := goldmark.New(
14 goldmark.WithExtensions(extension.GFM),
15 goldmark.WithParserOptions(
16 parser.WithAutoHeadingID(),
17 ),
18 )
19 var buf bytes.Buffer
20 if err := md.Convert([]byte(source), &buf); err != nil {
21 return source
22 }
23 return buf.String()
24}