Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"errors"
"fmt"
"html/template"
"unicode/utf8"

// Needed for jpeg support
Expand All @@ -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"
Expand Down Expand Up @@ -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()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think markup.RenderDescriptionHTML has done that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a little different with markdown.
example:
image

I wander why design this special ruler to render it.

}

func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) {
Expand Down
6 changes: 5 additions & 1 deletion templates/explore/repo_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
</div>
</div>
<div class="description">
{{if .DescriptionHTML}}<p>{{.DescriptionHTML}}</p>{{end}}
{{if .DescriptionHTML}}
<div class="ui markdown">
{{Str2html .DescriptionHTML}}
</div>
{{end}}
{{if .Topics }}
<div class="ui tags">
{{range .Topics}}
Expand Down
6 changes: 5 additions & 1 deletion templates/repo/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
{{template "base/alert" .}}
<div class="ui repo-description">
<div id="repo-desc">
{{if .Repository.DescriptionHTML}}<span class="description">{{.Repository.DescriptionHTML}}</span>{{else if .IsRepositoryAdmin}}<span class="no-description text-italic">{{.i18n.Tr "repo.no_desc"}}</span>{{end}}
{{if .Repository.DescriptionHTML}}
<span class="description markdown">{{.Repository.DescriptionHTML | Str2html}}</span>
{{else if .IsRepositoryAdmin}}
<span class="no-description text-italic">{{.i18n.Tr "repo.no_desc"}}</span>
{{end}}
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
</div>
{{if .RepoSearchEnabled}}
Expand Down