From e40fc75bac65933f2ed3de8fbc5fb336195b59f5 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 --- 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 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. diff --git a/web_src/css/base.css b/web_src/css/base.css index 18db136bc9..368bc56126 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -300,8 +300,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 */