Skip to content

Commit 16c7ce5

Browse files
committed
fix: markdown escape
1 parent a67132a commit 16c7ce5

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
Version string = "0.7.2"
10+
Version string = "0.7.3"
1111
)
1212

1313
var VersionCmd = &cobra.Command{

sources/bilibili/common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var ReqClient *req.Client
1111

1212
var (
13-
dynamicURLRegexp *regexp.Regexp = regexp.MustCompile(`t.bilibili.com/(\d+)|m.bilibili.com/opus/(\d+)`)
13+
dynamicURLRegexp *regexp.Regexp = regexp.MustCompile(`t.bilibili.com/(\d+)|bilibili.com/opus/(\d+)`)
1414
numberRegexp *regexp.Regexp = regexp.MustCompile(`\d+`)
1515
apiURLFormat string = "https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&platform=web&id=%s&features=itemOpusStyle"
1616
)

telegram/utils.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,11 @@ func GetArtworkMarkdownCaption(artwork *types.Artwork) string {
105105
caption := fmt.Sprintf("[*%s*](%s)", common.EscapeMarkdown(artwork.Title), artwork.SourceURL)
106106
caption += "\n" + "*Author:* " + common.EscapeMarkdown(artwork.Artist.Name)
107107
if artwork.Description != "" {
108-
desc := artwork.Description
109-
lines := strings.Split(desc, "\n")
110-
for i, line := range lines {
111-
lines[i] = ">" + common.EscapeMarkdown(line)
112-
if i == len(lines)-1 {
113-
lines[i] += "**"
114-
}
115-
}
116-
desc = strings.Join(lines, "\n")
108+
desc := strings.ReplaceAll(artwork.Description, "\n", " ")
117109
if len(desc) > 500 {
118-
caption += "\n\n" + desc[:500] + "\\.\\.\\."
110+
caption += "\n\n>" + common.EscapeMarkdown(desc) + "\\.\\.\\."
119111
} else {
120-
caption += "\n\n" + desc
112+
caption += "\n\n>" + common.EscapeMarkdown(desc)
121113
}
122114
}
123115
tags := ""

0 commit comments

Comments
 (0)