1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Refactor markup render system (#32612)

This PR removes (almost) all path tricks, and introduces "renderhelper"
package.

Now we can clearly see the rendering behaviors for comment/file/wiki,
more details are in "renderhelper" tests.

Fix #31411 , fix #18592, fix #25632 and maybe more problems. (ps: fix
#32608 by the way)
This commit is contained in:
wxiaoguang
2024-11-24 16:18:57 +08:00
committed by GitHub
parent fa175c1694
commit 633785a5f3
65 changed files with 1096 additions and 1194 deletions

View File

@@ -10,10 +10,10 @@ import (
"net/http"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/renderhelper"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
@@ -267,12 +267,8 @@ func UpdateCommentContent(ctx *context.Context) {
var renderedContent template.HTML
if comment.Content != "" {
renderedContent, err = markdown.RenderString(markup.NewRenderContext(ctx).
WithLinks(markup.Links{Base: ctx.FormString("context")}).
WithMetas(ctx.Repo.Repository.ComposeMetas(ctx)).
WithGitRepo(ctx.Repo.GitRepo).
WithRepoFacade(ctx.Repo.Repository),
comment.Content)
rctx := renderhelper.NewRenderContextRepoComment(ctx, ctx.Repo.Repository)
renderedContent, err = markdown.RenderString(rctx, comment.Content)
if err != nil {
ctx.ServerError("RenderString", err)
return