2024-02-18 10:07:49 +01:00
|
|
|
package articles
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/yuin/goldmark"
|
|
|
|
)
|
|
|
|
|
2024-02-18 12:41:49 +01:00
|
|
|
func ConvertToHTML(md string) (string, error) {
|
2024-02-18 10:07:49 +01:00
|
|
|
var buf bytes.Buffer
|
|
|
|
|
2024-02-18 12:41:49 +01:00
|
|
|
if err := goldmark.Convert([]byte(md), &buf); err != nil {
|
2024-02-18 10:07:49 +01:00
|
|
|
return "", fmt.Errorf("error: cmd/articles/markdown.go ConvertToHTML goldmark.Convert(): %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf.String(), nil
|
|
|
|
}
|