Evaluate post-summary divider HTML shortcodes #9423
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In HTML content pages with summary dividers, shortcodes after
the summary divider are not evaluated but are simply printed
as-is within the .Content of the page.
The issue takes place in hugolib.newPageContentOutput. In this
function, we apply various transformations to cp.workContent,
and at the end of the function, make this assignment:
cp.content = helpers.BytesToHTML(cp.workContent)
If a page has a manual summary divider and is HTML, we perform
this transformation on cp.workContent:
cp.workContent = src[cp.p.source.posBodyStart:]
While this sets the workContent to all content after the
summary divider, it does so after newPageContentOutput
calls replaceShortcodeTokens and evaluates shortcodes. This
means that evaluated shortcodes are replaced with
unevaluated ones after the summary divider.
The fix is to reuse logic from the function we use to
evaluate the summary divider for non-HTML pages,
hugolib.splitUserDefinedSummaryAndContent. While the current
code branches on whether the page is HTML before calling
this function, this change branches within the function,
since the function already includes a "markup" parameter we
can use to perform the branching.
And since this function already splits the summary/content
while preserving evaluated shortcodes, we can reuse its splitting
logic to fix the issue.
Fixes #6513