Skip to content

Commit b209531

Browse files
silverwindtechknowlogick
authored andcommitted
fix hljs unintenionally highlighting commit links (#7244)
* fix hljs unintenionally highlighting commit links * fix unit tests
1 parent a205155 commit b209531

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

modules/markup/html.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ func createCodeLink(href, content string) *html.Node {
323323
code := &html.Node{
324324
Type: html.ElementNode,
325325
Data: atom.Code.String(),
326+
Attr: []html.Attribute{{Key: "class", Val: "nohighlight"}},
326327
}
327328

328329
code.AppendChild(text)

modules/markup/html_internal_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ func TestRender_AutoLink(t *testing.T) {
197197

198198
// render valid commit URLs
199199
tmp := util.URLJoin(AppSubURL, "commit", "d8a994ef243349f321568f9e36d5c3f444b99cae")
200-
test(tmp, "<a href=\""+tmp+"\"><code>d8a994ef24</code></a>")
200+
test(tmp, "<a href=\""+tmp+"\"><code class=\"nohighlight\">d8a994ef24</code></a>")
201201
tmp += "#diff-2"
202-
test(tmp, "<a href=\""+tmp+"\"><code>d8a994ef24 (diff-2)</code></a>")
202+
test(tmp, "<a href=\""+tmp+"\"><code class=\"nohighlight\">d8a994ef24 (diff-2)</code></a>")
203203

204204
// render other commit URLs
205-
tmp = "https://external-link.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2"
206-
test(tmp, "<a href=\""+tmp+"\"><code>d8a994ef24 (diff-2)</code></a>")
205+
tmp = "https://external-link.gitea.io/go-gitea/gitea/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2"
206+
test(tmp, "<a href=\""+tmp+"\"><code class=\"nohighlight\">d8a994ef24 (diff-2)</code></a>")
207207
}
208208

209209
func TestRender_FullIssueURLs(t *testing.T) {

0 commit comments

Comments
 (0)