Skip to content

Commit fed44af

Browse files
committed
improve comment, fix external render ctx check
1 parent 08f0f69 commit fed44af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: modules/markup/external/external.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
102102

103103
_, err = io.Copy(f, input)
104104
if err != nil {
105-
f.Close()
105+
_ = f.Close()
106106
return fmt.Errorf("%s write data to temp file when rendering %s failed: %w", p.Name(), p.Command, err)
107107
}
108108

@@ -113,10 +113,9 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
113113
args = append(args, f.Name())
114114
}
115115

116-
if ctx == nil || ctx.Ctx == nil {
117-
if ctx == nil {
118-
log.Warn("RenderContext not provided defaulting to empty ctx")
119-
ctx = &markup.RenderContext{}
116+
if ctx.Ctx == nil {
117+
if !setting.IsProd || setting.IsInTesting {
118+
panic("RenderContext did not provide context")
120119
}
121120
log.Warn("RenderContext did not provide context, defaulting to Shutdown context")
122121
ctx.Ctx = graceful.GetManager().ShutdownContext()

Diff for: modules/markup/render.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ func render(ctx *RenderContext, renderer Renderer, input io.Reader, output io.Wr
171171
finalProcessor := ctx.RenderInternal.Init(output)
172172
defer finalProcessor.Close()
173173

174-
// input -> pw1 -> pr1 -> renderer -> pw2 -> pr2 -> SanitizeReader -> finalProcessor -> output
174+
// input -> (pw1=pr1) -> renderer -> (pw2=pr2) -> SanitizeReader -> finalProcessor -> output
175+
// no sanitizer: input -> (pw1=pr1) -> renderer -> pw2(finalProcessor) -> output
175176
pr1, pw1, close1 := pipes()
176177
defer close1()
177178

0 commit comments

Comments
 (0)