Revise the fix for shortcode vs output format nilpointer

We do lazy initialization and (potentially) reuse of an output format's rendered content. We do this evaluation when we
start a new rendering a new output format. There are, however, situation where these borders gets crossed (e.g.
accessing content from another output format). We have a check for this in place for most cases, but not the content
rendering of inner markdown blocks inside shortcodes. This patch applies that same logic to the newly introduced
RenderContent method (which is not available from the templates).

Fixes #10391
This commit is contained in:
Bjørn Erik Pedersen
2022-10-26 10:09:38 +02:00
parent e5d2a8f6a3
commit 631d768be9
7 changed files with 47 additions and 17 deletions

View File

@@ -381,19 +381,8 @@ func renderShortcode(
// Pre Hugo 0.55 this was the behaviour even for the outer-most
// shortcode.
if sc.doMarkup && (level > 0 || sc.configVersion() == 1) {
cp := p.pageOutput.cp
if cp == nil {
var err error
cp, err = newPageContentOutput(p, p.pageOutput)
if err != nil {
return "", false, err
}
p.pageOutput.initContentProvider(cp)
}
var err error
b, err := p.pageOutput.cp.renderContent([]byte(inner), false)
b, err := p.pageOutput.contentRenderer.RenderContent([]byte(inner), false)
if err != nil {
return "", false, err
}