From b209531959104cb6d5a8079ec567386720f3aaf3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 19 Jun 2019 00:31:31 +0200 Subject: [PATCH] fix hljs unintenionally highlighting commit links (#7244) * fix hljs unintenionally highlighting commit links * fix unit tests --- modules/markup/html.go | 1 + modules/markup/html_internal_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index dbfc8dbe85..3e976929c7 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -323,6 +323,7 @@ func createCodeLink(href, content string) *html.Node { code := &html.Node{ Type: html.ElementNode, Data: atom.Code.String(), + Attr: []html.Attribute{{Key: "class", Val: "nohighlight"}}, } code.AppendChild(text) diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go index 10bc4973cd..f0d894532b 100644 --- a/modules/markup/html_internal_test.go +++ b/modules/markup/html_internal_test.go @@ -197,13 +197,13 @@ func TestRender_AutoLink(t *testing.T) { // render valid commit URLs tmp := util.URLJoin(AppSubURL, "commit", "d8a994ef243349f321568f9e36d5c3f444b99cae") - test(tmp, "d8a994ef24") + test(tmp, "d8a994ef24") tmp += "#diff-2" - test(tmp, "d8a994ef24 (diff-2)") + test(tmp, "d8a994ef24 (diff-2)") // render other commit URLs - tmp = "https://external-link.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2" - test(tmp, "d8a994ef24 (diff-2)") + tmp = "https://external-link.gitea.io/go-gitea/gitea/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2" + test(tmp, "d8a994ef24 (diff-2)") } func TestRender_FullIssueURLs(t *testing.T) {