cpolis/cmd/articles/markdown.go

19 lines
339 B
Go

package articles
import (
"bytes"
"fmt"
"github.com/yuin/goldmark"
)
func ConvertToHTML(md string) (string, error) {
var buf bytes.Buffer
if err := goldmark.Convert([]byte(md), &buf); err != nil {
return "", fmt.Errorf("error: cmd/articles/markdown.go ConvertToHTML goldmark.Convert(): %v", err)
}
return buf.String(), nil
}