Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate post-summary divider HTML shortcodes #9423

Closed
wants to merge 1 commit into from

Conversation

ptgott
Copy link
Contributor

@ptgott ptgott commented Jan 25, 2022

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

@ptgott ptgott force-pushed the 6513-html-summary-split branch from 0917332 to 459cdeb Compare January 29, 2022 15:28
@ptgott ptgott force-pushed the 6513-html-summary-split branch from 459cdeb to 26ccb55 Compare February 12, 2022 16:31
@ptgott ptgott force-pushed the 6513-html-summary-split branch 2 times, most recently from d1fe9b9 to 6a9d40b Compare March 5, 2022 17:39
@ptgott ptgott force-pushed the 6513-html-summary-split branch 4 times, most recently from 66df11b to 13e6b47 Compare March 18, 2022 12:59
@ptgott ptgott force-pushed the 6513-html-summary-split branch 2 times, most recently from 1116eae to 3228206 Compare March 26, 2022 21:10
@ptgott ptgott force-pushed the 6513-html-summary-split branch from 3228206 to 5b1a1e7 Compare April 10, 2022 17:46
@ptgott ptgott force-pushed the 6513-html-summary-split branch from 5b1a1e7 to 86192bb Compare April 23, 2022 18:39
@ptgott ptgott force-pushed the 6513-html-summary-split branch 2 times, most recently from b2b362b to efdb204 Compare May 21, 2022 16:09
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 gohugoio#6513
@ptgott ptgott force-pushed the 6513-html-summary-split branch from efdb204 to f3b4104 Compare June 15, 2022 13:37
@github-actions
Copy link

This PR has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
Please check https://github.com/gohugoio/hugo/blob/master/CONTRIBUTING.md#code-contribution and verify that this code contribution fits with the description. If yes, tell is in a comment.
This PR will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Jun 16, 2023
@github-actions github-actions bot closed this Aug 12, 2023
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shortcodes do not get evaluated in HTML content files with manual summary splitting
1 participant