@@ -121,23 +121,7 @@ func (ut *RenderUtils) RenderIssueSimpleTitle(text string) template.HTML {
121121 return ret
122122}
123123
124- func (ut * RenderUtils ) RenderLabelWithLink (label * issues_model.Label , link any ) template.HTML {
125- var attrHref template.HTML
126- switch link .(type ) {
127- case template.URL , string :
128- attrHref = htmlutil .HTMLFormat (`href="%s"` , link )
129- default :
130- panic (fmt .Sprintf ("unexpected type %T for link" , link ))
131- }
132- return ut .renderLabelWithTag (label , "a" , attrHref )
133- }
134-
135124func (ut * RenderUtils ) RenderLabel (label * issues_model.Label ) template.HTML {
136- return ut .renderLabelWithTag (label , "span" , "" )
137- }
138-
139- // RenderLabel renders a label
140- func (ut * RenderUtils ) renderLabelWithTag (label * issues_model.Label , tagName , tagAttrs template.HTML ) template.HTML {
141125 locale := ut .ctx .Value (translation .ContextKey ).(translation.Locale )
142126 var extraCSSClasses string
143127 textColor := util .ContrastColor (label .Color )
@@ -151,8 +135,8 @@ func (ut *RenderUtils) renderLabelWithTag(label *issues_model.Label, tagName, ta
151135
152136 if labelScope == "" {
153137 // Regular label
154- return htmlutil .HTMLFormat (`<%s %s class="ui label %s" style="color: %s !important; background-color: %s !important;" data-tooltip-content title="%s"><span class="gt-ellipsis">%s</span></%s >` ,
155- tagName , tagAttrs , extraCSSClasses , textColor , label .Color , descriptionText , ut .RenderEmoji (label .Name ), tagName )
138+ return htmlutil .HTMLFormat (`<span class="ui label %s" style="color: %s !important; background-color: %s !important;" data-tooltip-content title="%s"><span class="gt-ellipsis">%s</span></span >` ,
139+ extraCSSClasses , textColor , label .Color , descriptionText , ut .RenderEmoji (label .Name ))
156140 }
157141
158142 // Scoped label
@@ -187,29 +171,25 @@ func (ut *RenderUtils) renderLabelWithTag(label *issues_model.Label, tagName, ta
187171
188172 if label .ExclusiveOrder > 0 {
189173 // <scope> | <label> | <order>
190- return htmlutil .HTMLFormat (`<%s %s class="ui label %s scope-parent" data-tooltip-content title="%s">` +
174+ return htmlutil .HTMLFormat (`<span class="ui label %s scope-parent" data-tooltip-content title="%s">` +
191175 `<div class="ui label scope-left" style="color: %s !important; background-color: %s !important">%s</div>` +
192176 `<div class="ui label scope-middle" style="color: %s !important; background-color: %s !important">%s</div>` +
193177 `<div class="ui label scope-right">%d</div>` +
194- `</%s>` ,
195- tagName , tagAttrs ,
178+ `</span>` ,
196179 extraCSSClasses , descriptionText ,
197180 textColor , scopeColor , scopeHTML ,
198181 textColor , itemColor , itemHTML ,
199- label .ExclusiveOrder ,
200- tagName )
182+ label .ExclusiveOrder )
201183 }
202184
203185 // <scope> | <label>
204- return htmlutil .HTMLFormat (`<%s %s class="ui label %s scope-parent" data-tooltip-content title="%s">` +
186+ return htmlutil .HTMLFormat (`<span class="ui label %s scope-parent" data-tooltip-content title="%s">` +
205187 `<div class="ui label scope-left" style="color: %s !important; background-color: %s !important">%s</div>` +
206188 `<div class="ui label scope-right" style="color: %s !important; background-color: %s !important">%s</div>` +
207- `</%s>` ,
208- tagName , tagAttrs ,
189+ `</span>` ,
209190 extraCSSClasses , descriptionText ,
210191 textColor , scopeColor , scopeHTML ,
211- textColor , itemColor , itemHTML ,
212- tagName )
192+ textColor , itemColor , itemHTML )
213193}
214194
215195// RenderEmoji renders html text with emoji post processors
@@ -246,18 +226,19 @@ func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML { //nolint:rev
246226func (ut * RenderUtils ) RenderLabels (labels []* issues_model.Label , repoLink string , issue * issues_model.Issue ) template.HTML {
247227 isPullRequest := issue != nil && issue .IsPull
248228 baseLink := fmt .Sprintf ("%s/%s" , repoLink , util .Iif (isPullRequest , "pulls" , "issues" ))
249- var htmlCode strings. Builder
250- htmlCode .WriteString (`<span class="labels-list">` )
229+ var htmlCode htmlutil. HTMLBuilder
230+ htmlCode .WriteHTML (`<span class="labels-list">` )
251231 for _ , label := range labels {
252232 // Protect against nil value in labels - shouldn't happen but would cause a panic if so
253233 if label == nil {
254234 continue
255235 }
256- link := fmt .Sprintf ("%s?labels=%d" , baseLink , label .ID )
257- htmlCode .WriteString (string (ut .RenderLabelWithLink (label , template .URL (link ))))
236+ htmlCode .WriteFormat (`<a class="item" href="%s?labels=%d">` , baseLink , label .ID )
237+ htmlCode .WriteHTML (ut .RenderLabel (label ))
238+ htmlCode .WriteHTML ("</a>" )
258239 }
259- htmlCode .WriteString ("</span>" )
260- return template . HTML ( htmlCode .String () )
240+ htmlCode .WriteHTML ("</span>" )
241+ return htmlCode .HTMLString ( )
261242}
262243
263244func (ut * RenderUtils ) RenderThemeItem (info * webtheme.ThemeMetaInfo , iconSize int ) template.HTML {
0 commit comments