fix: render description as HTML when rendering message (close #42)

This commit is contained in:
JustSong
2023-01-06 14:23:07 +08:00
parent ccf131037b
commit 89e7a10d20
4 changed files with 23 additions and 14 deletions

View File

@@ -1,8 +1,10 @@
package common
import (
"bytes"
"fmt"
"github.com/google/uuid"
"github.com/yuin/goldmark"
"html/template"
"log"
"net"
@@ -139,3 +141,13 @@ func Max(a int, b int) int {
return b
}
}
func Markdown2HTML(markdown string) (HTML string, err error) {
var buf bytes.Buffer
err = goldmark.Convert([]byte(markdown), &buf)
if err != nil {
return fmt.Sprintf("Markdown 渲染出错:%s", err.Error()), err
}
HTML = buf.String()
return
}