19 lines
351 B
Go
19 lines
351 B
Go
|
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
|
||
|
}
|