@@ -5,7 +5,6 @@ package markup
55
66import (
77 "bytes"
8- "fmt"
98 "io"
109 "net/url"
1110 "path"
@@ -809,29 +808,31 @@ func fullIssuePatternProcessor(ctx *RenderContext, node *html.Node) {
809808 if ctx .Metas == nil {
810809 return
811810 }
812- fmt .Println ("ctx.Metas" )
813- fmt .Println (ctx .Metas )
814811 next := node .NextSibling
815812 for node != nil && node != next {
816813 m := getIssueFullPattern ().FindStringSubmatchIndex (node .Data )
817814 if m == nil {
818815 return
819816 }
820817
821- Changedm := getFilesChangedFullPattern ().FindStringSubmatchIndex (node .Data )
822- // if the link is from files changed tab in pull requests, leave it as it is
823- if Changedm != nil {
818+ mDiffView := getFilesChangedFullPattern ().FindStringSubmatchIndex (node .Data )
819+ // if the link is from "Files Changed" tab in pull requests https://domain/org/repo/pulls/27/files (aka: the files diff view)
820+ // leave it as it is
821+ if mDiffView != nil {
824822 return
825823 }
826824
827825 link := node .Data [m [0 ]:m [1 ]]
828826 id := "#" + node .Data [m [2 ]:m [3 ]]
829-
827+ text := id
830828 // if m[4] and m[5] is not -1, then link is to a comment
831829 // indicate that in the text by appending (comment)
832830 if m [4 ] != - 1 && m [5 ] != - 1 {
833- locale := translation .NewLocale (ctx .Metas ["language" ])
834- id += " " + locale .Tr ("repo.from_comment" )
831+ if locale , ok := ctx .Ctx .Value (translation .ContextKey ).(translation.Locale ); ok {
832+ text += " " + locale .Tr ("repo.from_comment" )
833+ } else {
834+ text += " " + " (comment)"
835+ }
835836 }
836837
837838 // extract repo and org name from matched link like
@@ -841,10 +842,10 @@ func fullIssuePatternProcessor(ctx *RenderContext, node *html.Node) {
841842 matchRepo := linkParts [len (linkParts )- 3 ]
842843
843844 if matchOrg == ctx .Metas ["user" ] && matchRepo == ctx .Metas ["repo" ] {
844- replaceContent (node , m [0 ], m [1 ], createLink (link , id , "ref-issue" ))
845+ replaceContent (node , m [0 ], m [1 ], createLink (link , text , "ref-issue" ))
845846 } else {
846- orgRepoID : = matchOrg + "/" + matchRepo + id
847- replaceContent (node , m [0 ], m [1 ], createLink (link , orgRepoID , "ref-issue" ))
847+ text = matchOrg + "/" + matchRepo + text
848+ replaceContent (node , m [0 ], m [1 ], createLink (link , text , "ref-issue" ))
848849 }
849850 node = node .NextSibling .NextSibling
850851 }
0 commit comments