1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-06 02:27:20 +00:00

Add NeedPostProcess for Parser interface to improve performance of csv render (#15153)

This commit is contained in:
Lunny Xiao
2021-04-13 15:06:31 +08:00
committed by GitHub
parent bf3e584de2
commit 66f0fd0959
8 changed files with 38 additions and 14 deletions

View File

@ -33,6 +33,7 @@ func Init() {
type Parser interface {
Name() string // markup format name
Extensions() []string
NeedPostProcess() bool
Render(rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte
}
@ -82,10 +83,13 @@ func RenderWiki(filename string, rawBytes []byte, urlPrefix string, metas map[st
func render(parser Parser, rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte {
result := parser.Render(rawBytes, urlPrefix, metas, isWiki)
// TODO: one day the error should be returned.
result, err := PostProcess(result, urlPrefix, metas, isWiki)
if err != nil {
log.Error("PostProcess: %v", err)
if parser.NeedPostProcess() {
var err error
// TODO: one day the error should be returned.
result, err = PostProcess(result, urlPrefix, metas, isWiki)
if err != nil {
log.Error("PostProcess: %v", err)
}
}
return SanitizeBytes(result)
}