this repo has no description
1package pages
2
3import (
4 "bytes"
5
6 "github.com/yuin/goldmark"
7 "github.com/yuin/goldmark/extension"
8 "github.com/yuin/goldmark/parser"
9 "github.com/yuin/goldmark/renderer/html"
10)
11
12func renderMarkdown(source string) string {
13 md := goldmark.New(
14 goldmark.WithExtensions(extension.GFM),
15 goldmark.WithParserOptions(
16 parser.WithAutoHeadingID(),
17 ),
18 goldmark.WithRendererOptions(
19 html.WithHardWraps(),
20 html.WithXHTML(),
21 ),
22 )
23 var buf bytes.Buffer
24 if err := md.Convert([]byte(source), &buf); err != nil {
25 return source
26 }
27 return buf.String()
28}