fix: resolve message sending failure when containing "\n" using webhook and custom channel (#111)
* 使用webhook和custom通道发送消息时如果内容中包含\n会推送失败的问题 * 消息查看页面增加markdown内容解析,访问链接页面增加GFM拓展解析 * 访问链接页面GFM footnote支持
This commit is contained in:
+13
-1
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/google/uuid"
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"html/template"
|
||||
"log"
|
||||
"net"
|
||||
@@ -148,7 +149,13 @@ func Markdown2HTML(markdown string) (HTML string, err error) {
|
||||
return "", nil
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
err = goldmark.Convert([]byte(markdown), &buf)
|
||||
goldMarkEntity := goldmark.New(
|
||||
goldmark.WithExtensions(
|
||||
extension.GFM,
|
||||
extension.Footnote,
|
||||
),
|
||||
)
|
||||
err = goldMarkEntity.Convert([]byte(markdown), &buf)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("Markdown 渲染出错:%s", err.Error()), err
|
||||
}
|
||||
@@ -159,3 +166,8 @@ func Markdown2HTML(markdown string) (HTML string, err error) {
|
||||
func GetTimestamp() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
func Replace(s, old, new string, n int) string {
|
||||
new = strings.TrimPrefix(strings.TrimSuffix(fmt.Sprintf("%q", new), "\""), "\"")
|
||||
return strings.Replace(s, old, new, n)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user