cpolis/cmd/articles/markdown.go

19 lines
351 B
Go
Raw Normal View History

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