mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
rename
This commit is contained in:
parent
bf28343c15
commit
e318f94283
@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/yuin/goldmark/util"
|
"github.com/yuin/goldmark/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConvertMarkdownToHTML converts markdown byte slice to a HTML byte slice
|
// ToHTML converts markdown byte slice to a HTML byte slice
|
||||||
func ConvertMarkdownToHTML(markdown []byte) ([]byte, error) {
|
func ToHTML(markdown []byte) ([]byte, error) {
|
||||||
md := goldmark.New(
|
md := goldmark.New(
|
||||||
goldmark.WithExtensions(extension.GFM),
|
goldmark.WithExtensions(extension.GFM),
|
||||||
goldmark.WithParserOptions(
|
goldmark.WithParserOptions(
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConvertMarkdownToHTML(t *testing.T) {
|
func TestToHTML(t *testing.T) {
|
||||||
input := []byte(
|
input := []byte(
|
||||||
`## some headline
|
`## some headline
|
||||||
followed by some paragraph with [a link](https://example.local)
|
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>`,
|
<p><a href="https://example.local">embedded HTML is allowed</a></p>`,
|
||||||
)
|
)
|
||||||
|
|
||||||
got, err := ConvertMarkdownToHTML(input)
|
got, err := ToHTML(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("ConvertMarkdownToHTML() error = %v", err)
|
t.Errorf("ToHTML() error = %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.TrimSpace(string(got)) != strings.TrimSpace(string(expected)) {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ func readme() []byte {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
html, err := markdown.ConvertMarkdownToHTML(input)
|
html, err := markdown.ToHTML(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ func GenerateHTML(srcFilename, outFilename string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := markdown.ConvertMarkdownToHTML(input)
|
body, err := markdown.ToHTML(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user