Skip to content

Commit 3ea237b

Browse files
Add markdown support in organization description (#13549)
Similarly to how you can write some markdown in user profile description, you can now use the same feature in organization description. As discussed in discord. kudos to @mrsdizzie and @zeripath visualization: ![image](https://user-images.githubusercontent.com/61180606/99115919-8004a200-25f3-11eb-8bbd-ab33de2cabb3.png)
1 parent d025d84 commit 3ea237b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

routers/org/home.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/models"
1111
"code.gitea.io/gitea/modules/base"
1212
"code.gitea.io/gitea/modules/context"
13+
"code.gitea.io/gitea/modules/markup/markdown"
1314
"code.gitea.io/gitea/modules/setting"
1415
)
1516

@@ -34,6 +35,9 @@ func Home(ctx *context.Context) {
3435

3536
ctx.Data["PageIsUserProfile"] = true
3637
ctx.Data["Title"] = org.DisplayName()
38+
if len(org.Description) != 0 {
39+
ctx.Data["RenderedDescription"] = string(markdown.Render([]byte(org.Description), ctx.Repo.RepoLink, map[string]string{"mode": "document"}))
40+
}
3741

3842
var orderBy models.SearchOrderBy
3943
ctx.Data["SortType"] = ctx.Query("sort")

templates/org/home.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</span>
1414
{{if .IsOrganizationOwner}}<a class="middle text grey" href="{{.OrgLink}}/settings">{{svg "octicon-gear"}}</a>{{end}}
1515
</div>
16-
{{if .Org.Description}}<p class="desc">{{.Org.Description}}</p>{{end}}
16+
{{if $.RenderedDescription}}<p class="render-content markdown">{{$.RenderedDescription|Str2html}}</p>{{end}}
1717
<div class="text grey meta">
1818
{{if .Org.Location}}<div class="item">{{svg "octicon-location"}} <span>{{.Org.Location}}</span></div>{{end}}
1919
{{if .Org.Website}}<div class="item">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}

0 commit comments

Comments
 (0)