cpolis/cmd/articles/markdown.go

19 lines
339 B
Go
Raw Normal View History

package articles
import (
"bytes"
"fmt"
"github.com/yuin/goldmark"
)
2024-02-18 12:41:49 +01:00
func ConvertToHTML(md string) (string, error) {
var buf bytes.Buffer
2024-02-18 12:41:49 +01:00
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
}