loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Render code blocks in repo description (#26830)

Backtick syntax now works in repo description too. Also, I replaced the
CSS for this was a new single class, making it more flexible and not
dependent on a parent. Also, very slightly reduced font size from 16.8px
to 16px.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

authored by

silverwind
wxiaoguang
and committed by
GitHub
3d109861 c35b16a9

+5 -10
+2 -3
modules/templates/util_render.go
··· 108 108 // Match text that is between back ticks. 109 109 var codeMatcher = regexp.MustCompile("`([^`]+)`") 110 110 111 - // RenderCodeBlock renders "`…`" as highlighted "<code>" block. 112 - // Intended for issue and PR titles, these containers should have styles for "<code>" elements 111 + // RenderCodeBlock renders "`…`" as highlighted "<code>" block, intended for issue and PR titles 113 112 func RenderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML { 114 - htmlWithCodeTags := codeMatcher.ReplaceAllString(string(htmlEscapedTextToRender), "<code>$1</code>") // replace with HTML <code> tags 113 + htmlWithCodeTags := codeMatcher.ReplaceAllString(string(htmlEscapedTextToRender), `<code class="inline-code-block">$1</code>`) // replace with HTML <code> tags 115 114 return template.HTML(htmlWithCodeTags) 116 115 } 117 116
+2 -2
templates/repo/home.tmpl
··· 6 6 {{template "repo/code/recently_pushed_new_branches" .}} 7 7 {{if and (not .HideRepoInfo) (not .IsBlame)}} 8 8 <div class="ui repo-description"> 9 - <div id="repo-desc"> 9 + <div id="repo-desc" class="gt-font-16"> 10 10 {{$description := .Repository.DescriptionHTML $.Context}} 11 - {{if $description}}<span class="description">{{$description}}</span>{{else if .IsRepositoryAdmin}}<span class="no-description text-italic">{{.locale.Tr "repo.no_desc"}}</span>{{end}} 11 + {{if $description}}<span class="description">{{$description | RenderCodeBlock}}</span>{{else if .IsRepositoryAdmin}}<span class="no-description text-italic">{{.locale.Tr "repo.no_desc"}}</span>{{end}} 12 12 <a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a> 13 13 </div> 14 14 {{if .RepoSearchEnabled}}
+1 -1
web_src/css/base.css
··· 454 454 background: var(--color-hover); 455 455 } 456 456 457 - .issue-title code { 457 + .inline-code-block { 458 458 padding: 2px 4px; 459 459 border-radius: var(--border-radius-medium); 460 460 background-color: var(--color-markup-code-block);
-4
web_src/css/repo.css
··· 236 236 } 237 237 } 238 238 239 - .repository.file.list #repo-desc { 240 - font-size: 1.2em; 241 - } 242 - 243 239 .repository.file.list .repo-path { 244 240 word-break: break-word; 245 241 }