1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor markup render system (#32589)

This PR mainly moves some code and introduces `RenderContext.WithXxx`
functions
This commit is contained in:
wxiaoguang
2024-11-22 13:48:09 +08:00
committed by GitHub
parent 81ac8d914c
commit c4e27cb27b
49 changed files with 486 additions and 626 deletions

View File

@@ -219,15 +219,11 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
}
// This is the body of the new issue or comment, not the mail body
body, err := markdown.RenderString(&markup.RenderContext{
Ctx: ctx,
Repo: ctx.Issue.Repo,
Links: markup.Links{
AbsolutePrefix: true,
Base: ctx.Issue.Repo.HTMLURL(),
},
Metas: ctx.Issue.Repo.ComposeMetas(ctx),
}, ctx.Content)
body, err := markdown.RenderString(markup.NewRenderContext(ctx).
WithRepoFacade(ctx.Issue.Repo).
WithLinks(markup.Links{AbsolutePrefix: true, Base: ctx.Issue.Repo.HTMLURL()}).
WithMetas(ctx.Issue.Repo.ComposeMetas(ctx)),
ctx.Content)
if err != nil {
return nil, err
}

View File

@@ -56,14 +56,11 @@ func mailNewRelease(ctx context.Context, lang string, tos []*user_model.User, re
locale := translation.NewLocale(lang)
var err error
rel.RenderedNote, err = markdown.RenderString(&markup.RenderContext{
Ctx: ctx,
Repo: rel.Repo,
Links: markup.Links{
Base: rel.Repo.HTMLURL(),
},
Metas: rel.Repo.ComposeMetas(ctx),
}, rel.Note)
rel.RenderedNote, err = markdown.RenderString(markup.NewRenderContext(ctx).
WithRepoFacade(rel.Repo).
WithLinks(markup.Links{Base: rel.Repo.HTMLURL()}).
WithMetas(rel.Repo.ComposeMetas(ctx)),
rel.Note)
if err != nil {
log.Error("markdown.RenderString(%d): %v", rel.RepoID, err)
return