This commit is contained in:
Kirill Zhuravlev 2023-02-14 21:26:32 +01:00 committed by Avelino
parent bf28343c15
commit e318f94283
No known key found for this signature in database
GPG Key ID: B345B4D52E98180A
3 changed files with 8 additions and 8 deletions

View File

@ -12,8 +12,8 @@ import (
"github.com/yuin/goldmark/util"
)
// ConvertMarkdownToHTML converts markdown byte slice to a HTML byte slice
func ConvertMarkdownToHTML(markdown []byte) ([]byte, error) {
// ToHTML converts markdown byte slice to a HTML byte slice
func ToHTML(markdown []byte) ([]byte, error) {
md := goldmark.New(
goldmark.WithExtensions(extension.GFM),
goldmark.WithParserOptions(

View File

@ -5,7 +5,7 @@ import (
"testing"
)
func TestConvertMarkdownToHTML(t *testing.T) {
func TestToHTML(t *testing.T) {
input := []byte(
`## some headline
followed by some paragraph with [a link](https://example.local)
@ -46,12 +46,12 @@ and some list:</p>
<p><a href="https://example.local">embedded HTML is allowed</a></p>`,
)
got, err := ConvertMarkdownToHTML(input)
got, err := ToHTML(input)
if err != nil {
t.Errorf("ConvertMarkdownToHTML() error = %v", err)
t.Errorf("ToHTML() error = %v", err)
return
}
if strings.TrimSpace(string(got)) != strings.TrimSpace(string(expected)) {
t.Errorf("ConvertMarkdownToHTML() got = %v, want %v", string(got), string(expected))
t.Errorf("ToHTML() got = %v, want %v", string(got), string(expected))
}
}

View File

@ -15,7 +15,7 @@ func readme() []byte {
if err != nil {
panic(err)
}
html, err := markdown.ConvertMarkdownToHTML(input)
html, err := markdown.ToHTML(input)
if err != nil {
panic(err)
}
@ -42,7 +42,7 @@ func GenerateHTML(srcFilename, outFilename string) error {
return err
}
body, err := markdown.ConvertMarkdownToHTML(input)
body, err := markdown.ToHTML(input)
if err != nil {
return err
}