aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2024-03-28 11:42:31 +0100
committerGitHub <noreply@github.com>2024-03-28 10:42:31 +0000
commite40fc75bac65933f2ed3de8fbc5fb336195b59f5 (patch)
tree7299d69acf28fce949ac192220beb8142c1bfe1b /modules
parenteca4c485343069fc3e59f0dba7823cc13b5ab1d8 (diff)
downloadgitea-e40fc75bac65933f2ed3de8fbc5fb336195b59f5.tar.gz
gitea-e40fc75bac65933f2ed3de8fbc5fb336195b59f5.zip
Render code tags in commit messages (#30146)
Extend https://github.com/go-gitea/gitea/pull/21432 to commit messages. Color is changed because the markup code block bg does not offer enough contrast on varying backgrounds. <img width="568" alt="Screenshot 2024-03-27 at 19 52 55" src="https://github.com/go-gitea/gitea/assets/115237/ddc9307e-f32f-4e97-8b88-91f88ced2a36"> <img width="573" alt="Screenshot 2024-03-27 at 19 53 33" src="https://github.com/go-gitea/gitea/assets/115237/14b30fd2-bf28-46b8-9e82-eb60a28f6bf2"> <img width="422" alt="Screenshot 2024-03-27 at 19 53 01" src="https://github.com/go-gitea/gitea/assets/115237/a12136b5-c02b-460c-9830-f830542987ae"> <img width="397" alt="Screenshot 2024-03-27 at 19 53 27" src="https://github.com/go-gitea/gitea/assets/115237/c9f05d81-c73e-468e-98e9-e5929bc0da3e"> <img width="333" alt="Screenshot 2024-03-27 at 19 53 07" src="https://github.com/go-gitea/gitea/assets/115237/06b5a9f9-f95d-46b6-8c57-df0b02555652"> <img width="279" alt="Screenshot 2024-03-27 at 19 53 21" src="https://github.com/go-gitea/gitea/assets/115237/b06a0afc-ddd8-48ae-b557-a6dc47802e68">
Diffstat (limited to 'modules')
-rw-r--r--modules/templates/util_render.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go
index 7ed3a8b9b4..d1c9b082fa 100644
--- a/modules/templates/util_render.go
+++ b/modules/templates/util_render.go
@@ -41,7 +41,7 @@ func RenderCommitMessage(ctx context.Context, msg string, metas map[string]strin
if len(msgLines) == 0 {
return template.HTML("")
}
- return template.HTML(msgLines[0])
+ return RenderCodeBlock(template.HTML(msgLines[0]))
}
// RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to
@@ -68,7 +68,7 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string,
log.Error("RenderCommitMessageSubject: %v", err)
return template.HTML("")
}
- return template.HTML(renderedMessage)
+ return RenderCodeBlock(template.HTML(renderedMessage))
}
// RenderCommitBody extracts the body of a commit message without its title.