From 3ccb0c2512cb551943945aaa3f2bd0b1e2abd3b8 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 28 Mar 2024 11:42:31 +0100 Subject: [PATCH] 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. Screenshot 2024-03-27 at 19 52 55 Screenshot 2024-03-27 at 19 53 33 Screenshot 2024-03-27 at 19 53 01 Screenshot 2024-03-27 at 19 53 27 Screenshot 2024-03-27 at 19 53 07 Screenshot 2024-03-27 at 19 53 21 (cherry picked from commit e40fc75bac65933f2ed3de8fbc5fb336195b59f5) --- modules/templates/util_render.go | 4 ++-- web_src/css/base.css | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index cdff31698c..5deb051abe 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -40,7 +40,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 @@ -67,7 +67,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. diff --git a/web_src/css/base.css b/web_src/css/base.css index 4fdc38b2c3..a63a3ddde5 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -311,8 +311,8 @@ a.label, .inline-code-block { padding: 2px 4px; - border-radius: var(--border-radius-medium); - background-color: var(--color-markup-code-block); + border-radius: .24em; + background-color: var(--color-label-bg); } /* fix Fomantic's line-height cutting off "g" on Windows Chrome with Segoe UI */