Skip to content

Commit 3de3e4d

Browse files
committed
fix
1 parent 171edfc commit 3de3e4d

File tree

8 files changed

+26
-17
lines changed

8 files changed

+26
-17
lines changed

modules/markup/html.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,10 @@ func RenderCommitMessageSubject(ctx *RenderContext, defaultLink, content string)
213213

214214
// RenderIssueTitle to process title on individual issue/pull page
215215
func RenderIssueTitle(ctx *RenderContext, title string) (string, error) {
216-
// do not render other issue/commit links in an issue's title - which in most cases is already a link.
217216
return postProcessString(ctx, []processor{
217+
issueIndexPatternProcessor,
218+
commitCrossReferencePatternProcessor,
219+
hashCurrentPatternProcessor,
218220
emojiShortCodeProcessor,
219221
emojiProcessor,
220222
}, title)

modules/templates/util_render.go

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ func (ut *RenderUtils) RenderIssueTitle(text string, metas map[string]string) te
114114
return template.HTML(renderedText)
115115
}
116116

117+
// RenderIssueSimpleTitle only renders with emoji and inline code block
118+
func (ut *RenderUtils) RenderIssueSimpleTitle(text string) template.HTML {
119+
ret := ut.RenderEmoji(text)
120+
ret = renderCodeBlock(ret)
121+
return ret
122+
}
123+
117124
// RenderLabel renders a label
118125
func (ut *RenderUtils) RenderLabel(label *issues_model.Label) template.HTML {
119126
locale := ut.ctx.Value(translation.ContextKey).(translation.Locale)

modules/templates/util_render_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
164164
<span class="emoji" aria-label="thumbs up">👍</span>
165165
mail@domain.com
166166
@mention-user test
167-
#123
167+
<a href="/user13/repo11/issues/123" class="ref-issue">#123</a>
168168
space<SPACE><SPACE>
169169
`
170170
expected = strings.ReplaceAll(expected, "<SPACE>", " ")
171-
assert.EqualValues(t, expected, string(newTestRenderUtils().RenderIssueTitle(testInput(), nil)))
171+
assert.EqualValues(t, expected, string(newTestRenderUtils().RenderIssueTitle(testInput(), testMetas)))
172172
}
173173

174174
func TestRenderMarkdownToHtml(t *testing.T) {

templates/repo/issue/card.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="issue-card-icon">
1515
{{template "shared/issueicon" .}}
1616
</div>
17-
<a class="issue-card-title muted issue-title tw-break-anywhere" href="{{.Link}}">{{.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
17+
<a class="issue-card-title muted issue-title tw-break-anywhere" href="{{.Link}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
1818
{{if and $.isPinnedIssueCard $.Page.IsRepoAdmin}}
1919
<a role="button" class="issue-card-unpin muted tw-flex tw-items-center" data-tooltip-content={{ctx.Locale.Tr "repo.issues.unpin_issue"}} data-issue-id="{{.ID}}" data-unpin-url="{{$.Page.Link}}/unpin/{{.Index}}">
2020
{{svg "octicon-x" 16}}

templates/repo/pulse.tmpl

+7-7
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
<span class="ui green label">{{ctx.Locale.Tr "repo.activity.published_release_label"}}</span>
126126
{{.TagName}}
127127
{{if not .IsTag}}
128-
<a class="title" href="{{$.RepoLink}}/src/{{.TagName | PathEscapeSegments}}">{{.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
128+
<a class="title" href="{{$.RepoLink}}/src/{{.TagName | PathEscapeSegments}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
129129
{{end}}
130130
{{DateUtils.TimeSince .CreatedUnix}}
131131
</p>
@@ -145,7 +145,7 @@
145145
{{range .Activity.MergedPRs}}
146146
<p class="desc">
147147
<span class="ui purple label">{{ctx.Locale.Tr "repo.activity.merged_prs_label"}}</span>
148-
#{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
148+
#{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
149149
{{DateUtils.TimeSince .MergedUnix}}
150150
</p>
151151
{{end}}
@@ -164,7 +164,7 @@
164164
{{range .Activity.OpenedPRs}}
165165
<p class="desc">
166166
<span class="ui green label">{{ctx.Locale.Tr "repo.activity.opened_prs_label"}}</span>
167-
#{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
167+
#{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
168168
{{DateUtils.TimeSince .Issue.CreatedUnix}}
169169
</p>
170170
{{end}}
@@ -183,7 +183,7 @@
183183
{{range .Activity.ClosedIssues}}
184184
<p class="desc">
185185
<span class="ui red label">{{ctx.Locale.Tr "repo.activity.closed_issue_label"}}</span>
186-
#{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
186+
#{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
187187
{{DateUtils.TimeSince .ClosedUnix}}
188188
</p>
189189
{{end}}
@@ -202,7 +202,7 @@
202202
{{range .Activity.OpenedIssues}}
203203
<p class="desc">
204204
<span class="ui green label">{{ctx.Locale.Tr "repo.activity.new_issue_label"}}</span>
205-
#{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
205+
#{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
206206
{{DateUtils.TimeSince .CreatedUnix}}
207207
</p>
208208
{{end}}
@@ -220,9 +220,9 @@
220220
<span class="ui green label">{{ctx.Locale.Tr "repo.activity.unresolved_conv_label"}}</span>
221221
#{{.Index}}
222222
{{if .IsPull}}
223-
<a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
223+
<a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
224224
{{else}}
225-
<a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
225+
<a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
226226
{{end}}
227227
{{DateUtils.TimeSince .UpdatedUnix}}
228228
</p>

templates/shared/issuelist.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="flex-item-main">
1414
<div class="flex-item-header">
1515
<div class="flex-item-title">
16-
<a class="tw-no-underline issue-title" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}">{{ctx.RenderUtils.RenderEmoji .Title | RenderCodeBlock}}</a>
16+
<a class="tw-no-underline issue-title" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}">{{.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
1717
{{if .IsPull}}
1818
{{if (index $.CommitStatuses .PullRequest.ID)}}
1919
{{template "repo/commit_statuses" dict "Status" (index $.CommitLastStatus .PullRequest.ID) "Statuses" (index $.CommitStatuses .PullRequest.ID)}}

templates/user/dashboard/feeds.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@
100100
<a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{ctx.Locale.Tr "action.compare_commits" $push.Len}} »</a>
101101
{{end}}
102102
{{else if .GetOpType.InActions "create_issue"}}
103-
<span class="text truncate issue title">{{index .GetIssueInfos 1 | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</span>
103+
<span class="text truncate issue title">{{index .GetIssueInfos 1 | ctx.RenderUtils.RenderIssueSimpleTitle}}</span>
104104
{{else if .GetOpType.InActions "create_pull_request"}}
105-
<span class="text truncate issue title">{{index .GetIssueInfos 1 | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</span>
105+
<span class="text truncate issue title">{{index .GetIssueInfos 1 | ctx.RenderUtils.RenderIssueSimpleTitle}}</span>
106106
{{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}}
107-
<a href="{{.GetCommentLink ctx}}" class="text truncate issue title">{{(.GetIssueTitle ctx) | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</a>
107+
<a href="{{.GetCommentLink ctx}}" class="text truncate issue title">{{(.GetIssueTitle ctx) | ctx.RenderUtils.RenderIssueSimpleTitle}}</a>
108108
{{$comment := index .GetIssueInfos 1}}
109109
{{if $comment}}
110110
<div class="markup tw-text-14">{{ctx.RenderUtils.MarkdownToHtml $comment}}</div>
111111
{{end}}
112112
{{else if .GetOpType.InActions "merge_pull_request"}}
113113
<div class="flex-item-body text black">{{index .GetIssueInfos 1}}</div>
114114
{{else if .GetOpType.InActions "close_issue" "reopen_issue" "close_pull_request" "reopen_pull_request"}}
115-
<span class="text truncate issue title">{{(.GetIssueTitle ctx) | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}</span>
115+
<span class="text truncate issue title">{{(.GetIssueTitle ctx) | ctx.RenderUtils.RenderIssueSimpleTitle}}</span>
116116
{{else if .GetOpType.InActions "pull_review_dismissed"}}
117117
<div class="flex-item-body text black">{{ctx.Locale.Tr "action.review_dismissed_reason"}}</div>
118118
<div class="flex-item-body text black">{{index .GetIssueInfos 2 | ctx.RenderUtils.RenderEmoji}}</div>

templates/user/notification/notification_div.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<div class="notifications-bottom-row tw-text-16 tw-py-0.5">
5454
<span class="issue-title tw-break-anywhere">
5555
{{if .Issue}}
56-
{{.Issue.Title | ctx.RenderUtils.RenderEmoji | RenderCodeBlock}}
56+
{{.Issue.Title | ctx.RenderUtils.RenderIssueSimpleTitle}}
5757
{{else}}
5858
{{.Repository.FullName}}
5959
{{end}}

0 commit comments

Comments
 (0)