]> source.dussan.org Git - gitea.git/commitdiff
fix hljs unintenionally highlighting commit links (#7244)
authorsilverwind <me@silverwind.io>
Tue, 18 Jun 2019 22:31:31 +0000 (00:31 +0200)
committertechknowlogick <techknowlogick@gitea.io>
Tue, 18 Jun 2019 22:31:31 +0000 (18:31 -0400)
* fix hljs unintenionally highlighting commit links

* fix unit tests

modules/markup/html.go
modules/markup/html_internal_test.go

index dbfc8dbe85f7164b9c4101b5274815b6ea4e0f5b..3e976929c7b24e393758e051939b3b51bb633aef 100644 (file)
@@ -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)
index 10bc4973cd525fdf4517d12abc2ad5ddfc22aa1a..f0d894532b69d991a71ee867adb49532d137aa0e 100644 (file)
@@ -197,13 +197,13 @@ func TestRender_AutoLink(t *testing.T) {
 
        // render valid commit URLs
        tmp := util.URLJoin(AppSubURL, "commit", "d8a994ef243349f321568f9e36d5c3f444b99cae")
-       test(tmp, "<a href=\""+tmp+"\"><code>d8a994ef24</code></a>")
+       test(tmp, "<a href=\""+tmp+"\"><code class=\"nohighlight\">d8a994ef24</code></a>")
        tmp += "#diff-2"
-       test(tmp, "<a href=\""+tmp+"\"><code>d8a994ef24 (diff-2)</code></a>")
+       test(tmp, "<a href=\""+tmp+"\"><code class=\"nohighlight\">d8a994ef24 (diff-2)</code></a>")
 
        // render other commit URLs
-       tmp = "https://external-link.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2"
-       test(tmp, "<a href=\""+tmp+"\"><code>d8a994ef24 (diff-2)</code></a>")
+       tmp = "https://external-link.gitea.io/go-gitea/gitea/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2"
+       test(tmp, "<a href=\""+tmp+"\"><code class=\"nohighlight\">d8a994ef24 (diff-2)</code></a>")
 }
 
 func TestRender_FullIssueURLs(t *testing.T) {