Skip to content

Commit e40fc75

Browse files
authored
Render code tags in commit messages (#30146)
Extend #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">
1 parent eca4c48 commit e40fc75

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

modules/templates/util_render.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func RenderCommitMessage(ctx context.Context, msg string, metas map[string]strin
4141
if len(msgLines) == 0 {
4242
return template.HTML("")
4343
}
44-
return template.HTML(msgLines[0])
44+
return RenderCodeBlock(template.HTML(msgLines[0]))
4545
}
4646

4747
// RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to
@@ -68,7 +68,7 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string,
6868
log.Error("RenderCommitMessageSubject: %v", err)
6969
return template.HTML("")
7070
}
71-
return template.HTML(renderedMessage)
71+
return RenderCodeBlock(template.HTML(renderedMessage))
7272
}
7373

7474
// RenderCommitBody extracts the body of a commit message without its title.

web_src/css/base.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ a.label,
300300

301301
.inline-code-block {
302302
padding: 2px 4px;
303-
border-radius: var(--border-radius-medium);
304-
background-color: var(--color-markup-code-block);
303+
border-radius: .24em;
304+
background-color: var(--color-label-bg);
305305
}
306306

307307
/* fix Fomantic's line-height cutting off "g" on Windows Chrome with Segoe UI */

0 commit comments

Comments
 (0)