Skip to content

Commit f16185e

Browse files
committed
refactor: improve HTML caption formatting for artwork details
1 parent ea7c9db commit f16185e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

telegram/utils/utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var tagCharsReplacer = strings.NewReplacer(
7676
// 获取作品的 HTML 格式描述, 已转义
7777
func GetArtworkHTMLCaption(artwork *types.Artwork) string {
7878
caption := fmt.Sprintf("<a href=\"%s\"><b>%s</b></a>", artwork.SourceURL, common.EscapeHTML(artwork.Title))
79-
caption += "\n<b>Author:</b> " + common.EscapeHTML(artwork.Artist.Name)
79+
caption += fmt.Sprintf("\nAuthor: <b>%s</b>", common.EscapeHTML(artwork.Artist.Name))
8080
if artwork.Description != "" {
8181
desc := artwork.Description
8282
if len(artwork.Description) > 500 {
@@ -100,11 +100,12 @@ func GetArtworkHTMLCaption(artwork *types.Artwork) string {
100100
tags += "#" + strings.TrimSpace(common.EscapeHTML(tag)) + " "
101101
}
102102
caption += fmt.Sprintf("\n<blockquote expandable=true>%s</blockquote>\n", tags)
103-
if ChannelChatID.Username != "" {
103+
posted := ChannelChatID.Username != "" && artwork.ID != ""
104+
if posted {
104105
caption += common.EscapeHTML(ChannelChatID.Username)
105106
}
106107
if artwork.ID != "" && config.Cfg.API.SiteURL != "" {
107-
if ChannelChatID.Username != "" {
108+
if posted {
108109
caption += " | "
109110
}
110111
caption += fmt.Sprintf("<a href=\"%s/artwork/%s\">在网站查看</a>", config.Cfg.API.SiteURL, artwork.ID)

0 commit comments

Comments
 (0)