Skip to content

Commit d572833

Browse files
committed
fix test
1 parent ebd88a5 commit d572833

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

modules/markup/html.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ package markup
55

66
import (
77
"bytes"
8-
"fmt"
9-
"html/template"
108
"io"
119
"regexp"
10+
"slices"
1211
"strings"
1312
"sync"
1413

@@ -227,15 +226,16 @@ func RenderCommitMessageSubject(
227226
ctx *RenderContext,
228227
defaultLink, content string,
229228
) (string, error) {
230-
procs := commitMessageSubjectProcessors
231-
rendered, err := renderProcessString(ctx, procs, content)
232-
if err != nil {
233-
return "", err
234-
}
235-
if defaultLink != "" {
236-
rendered = fmt.Sprintf(`<a href="%s" class="muted">%s</a>`, template.HTMLEscapeString(defaultLink), rendered)
237-
}
238-
return rendered, nil
229+
procs := slices.Clone(commitMessageSubjectProcessors)
230+
procs = append(procs, func(ctx *RenderContext, node *html.Node) {
231+
ch := &html.Node{Parent: node, Type: html.TextNode, Data: node.Data}
232+
node.Type = html.ElementNode
233+
node.Data = "a"
234+
node.DataAtom = atom.A
235+
node.Attr = []html.Attribute{{Key: "href", Val: defaultLink}, {Key: "class", Val: "muted"}}
236+
node.FirstChild, node.LastChild = ch, ch
237+
})
238+
return renderProcessString(ctx, procs, content)
239239
}
240240

241241
// RenderIssueTitle to process title on individual issue/pull page

0 commit comments

Comments
 (0)