更改:获取wiki详情内容实用blackfriday

This commit is contained in:
yystopf 2022-12-29 15:34:54 +08:00
parent 15018595fe
commit f625463cf9
1 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"strings"
repo_model "code.gitea.io/gitea/models/repo"
"github.com/russross/blackfriday/v2"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
@ -267,6 +268,7 @@ func GetWiki(ctx *context.APIContext) {
IsWiki: true,
}
var buf strings.Builder
content := blackfriday.Run(data)
if err := markdown.Render(rctx, bytes.NewReader(data), &buf); err != nil {
ctx.ServerError("markdown.Render", err)
return
@ -301,7 +303,7 @@ func GetWiki(ctx *context.APIContext) {
},
CommitCounts: commitsCount,
MdContent: string(data),
SimpleContent: buf.String(),
SimpleContent: string(content),
}
ctx.JSON(http.StatusOK, wiki)
}