diff --git a/models/repo.go b/models/repo.go index 519802632902d..7c6aa9c8fab2f 100644 --- a/models/repo.go +++ b/models/repo.go @@ -9,7 +9,6 @@ import ( "context" "errors" "fmt" - "html/template" "unicode/utf8" // Needed for jpeg support @@ -27,6 +26,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" + "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" @@ -990,13 +990,8 @@ func (repo *Repository) getUsersWithAccessMode(e Engine, mode AccessMode) (_ []* } // DescriptionHTML does special handles to description and return HTML string. -func (repo *Repository) DescriptionHTML() template.HTML { - desc, err := markup.RenderDescriptionHTML([]byte(repo.Description), repo.HTMLURL(), repo.ComposeMetas()) - if err != nil { - log.Error("Failed to render description for %s (ID: %d): %v", repo.Name, repo.ID, err) - return template.HTML(markup.Sanitize(repo.Description)) - } - return template.HTML(markup.Sanitize(string(desc))) +func (repo *Repository) DescriptionHTML() string { + return string(markdown.Render([]byte(repo.Description), repo.HTMLURL(), repo.ComposeMetas())) } func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) { diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 9e4e438a849e4..2ab2bab4cdbb2 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -40,7 +40,11 @@
- {{if .DescriptionHTML}}

{{.DescriptionHTML}}

{{end}} + {{if .DescriptionHTML}} +
+ {{Str2html .DescriptionHTML}} +
+ {{end}} {{if .Topics }}
{{range .Topics}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index c9cc3725f174b..918bc9677ccac 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -5,7 +5,11 @@ {{template "base/alert" .}}
- {{if .Repository.DescriptionHTML}}{{.Repository.DescriptionHTML}}{{else if .IsRepositoryAdmin}}{{.i18n.Tr "repo.no_desc"}}{{end}} + {{if .Repository.DescriptionHTML}} + {{.Repository.DescriptionHTML | Str2html}} + {{else if .IsRepositoryAdmin}} + {{.i18n.Tr "repo.no_desc"}} + {{end}} {{.Repository.Website}}
{{if .RepoSearchEnabled}}