mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
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:
@@ -123,7 +123,7 @@ func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, err
|
||||
isHTML := cp.p.m.markup == "html"
|
||||
|
||||
if !isHTML {
|
||||
r, err := cp.renderContent(cp.workContent, true)
|
||||
r, err := po.contentRenderer.RenderContent(cp.workContent, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, err
|
||||
}
|
||||
}
|
||||
} else if cp.p.m.summary != "" {
|
||||
b, err := cp.renderContent([]byte(cp.p.m.summary), false)
|
||||
b, err := po.contentRenderer.RenderContent([]byte(cp.p.m.summary), false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -629,7 +629,7 @@ func (p *pageContentOutput) setAutoSummary() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cp *pageContentOutput) renderContent(content []byte, renderTOC bool) (converter.Result, error) {
|
||||
func (cp *pageContentOutput) RenderContent(content []byte, renderTOC bool) (converter.Result, error) {
|
||||
if err := cp.initRenderHooks(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user