summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-08-24 03:44:53 +0200
committerGitHub <noreply@github.com>2020-08-23 21:44:53 -0400
commitee047312a1a3238a8504200f7ded8536ebc838e3 (patch)
treea4e79586f0468725bcf66a083e44c84f9a39ee5b /modules
parent26bf4c51fb900b8a31cfb6d17095515c118a68a1 (diff)
downloadgitea-ee047312a1a3238a8504200f7ded8536ebc838e3.tar.gz
gitea-ee047312a1a3238a8504200f7ded8536ebc838e3.zip
Fix emoji replacements, make emoji images consistent (#12567)
- Fix emoji not being replaced in issue title change text - Make the image attributes consistent, add alt, remove align Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/markup/html.go1
-rw-r--r--modules/markup/html_test.go2
-rw-r--r--modules/templates/helper.go2
3 files changed, 3 insertions, 2 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index 41248654d8..bef6269a69 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -481,6 +481,7 @@ func createCustomEmoji(alias, class string) *html.Node {
Attr: []html.Attribute{},
}
if class != "" {
+ img.Attr = append(img.Attr, html.Attribute{Key: "alt", Val: fmt.Sprintf(`:%s:`, alias)})
img.Attr = append(img.Attr, html.Attribute{Key: "src", Val: fmt.Sprintf(`%s/img/emoji/%s.png`, setting.StaticURLPrefix, alias)})
}
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go
index 69c4e675f5..7f820d3990 100644
--- a/modules/markup/html_test.go
+++ b/modules/markup/html_test.go
@@ -255,7 +255,7 @@ func TestRender_emoji(t *testing.T) {
//Text that should be turned into or recognized as emoji
test(
":gitea:",
- `<p><span class="emoji" aria-label="gitea"><img src="`+setting.StaticURLPrefix+`/img/emoji/gitea.png"/></span></p>`)
+ `<p><span class="emoji" aria-label="gitea"><img alt=":gitea:" src="`+setting.StaticURLPrefix+`/img/emoji/gitea.png"/></span></p>`)
test(
"Some text with 😄 in the middle",
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 718fe8f267..f86287f10b 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -607,7 +607,7 @@ func ReactionToEmoji(reaction string) template.HTML {
if val != nil {
return template.HTML(val.Emoji)
}
- return template.HTML(fmt.Sprintf(`<img src=%s/img/emoji/%s.png></img>`, setting.StaticURLPrefix, reaction))
+ return template.HTML(fmt.Sprintf(`<img alt=":%s:" src="%s/img/emoji/%s.png"></img>`, reaction, setting.StaticURLPrefix, reaction))
}
// RenderNote renders the contents of a git-notes file as a commit message.