fix(layouts): trim whitespace in render-codeblock placeholder/callout branch#7084
Merged
jstirnaman merged 1 commit intomasterfrom Apr 9, 2026
Merged
Conversation
… branch Commit d80eb2f (#7069) refactored `layouts/_default/_markup/render-codeblock.html` to support the new `callout` fence attribute alongside the existing `placeholders` attribute. The refactor introduced a new conditional branch that handles placeholder/callout code blocks, but several of its interior action tags use bare `{{ ... }}` delimiters instead of the whitespace-trimming `{{- ... -}}` form used in the `else` branch: {{- if or .Attributes.placeholders .Attributes.callout -}} {{ $code := highlight .Inner .Type }} ... {{ $code | safeHTML }} Each non-trimmed action leaks two leading spaces and a trailing newline into the render-hook output. For a placeholder code block the final render-hook output then looks like: [2 spaces][newline] [4 spaces][newline] [4 spaces][newline] [2 spaces]<div class="highlight">...</div>[newline] Goldmark sees this as an indented code block preceded by blank lines, wraps the leading highlighted HTML in `<pre><code>`, and HTML-escapes every `<` and `>`. The visible symptom is a wall of escaped `<span class="line">...` fragments on every page with a placeholder or callout code block, including every InfluxDB 3 sample-data page, the enterprise backup-restore page, the clustered users/add page, and about 18 other admin pages. The regression landed on Apr 8 with #7069 and was reported as #7079. Fix: apply `{{- ... -}}` whitespace trimming to every action inside the placeholder/callout branch, matching the pattern the `else` branch already uses. No content files change. Verified with a local Hugo 0.149 build — every previously affected page now renders with zero escaped highlight blocks, and the site-wide count of pages containing `<div class="highlight` drops from 23 to 0. Closes #7079
Contributor
|
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the root cause of the site-wide broken-code-block regression reported in #7079. The merged PR #7083 collapsed two wrapper shortcode templates as a band-aid that worked around the visible symptom on sample-data pages, but the same bug was still affecting ~18 other admin/install pages with placeholder code blocks (e.g.
/influxdb3/enterprise/admin/backup-restore/,/influxdb3/clustered/admin/users/add/,/influxdb3/enterprise/admin/upgrade/). This PR fixes the underlying cause inlayouts/_default/_markup/render-codeblock.html.Root cause
Commit d80eb2f from #7069 (Apr 8) refactored
render-codeblock.htmlto support the newcalloutfence attribute alongsideplaceholders. The refactor introduced a new conditional branch:The outer
{{- if -}}trims its own surrounding whitespace, but the inner action tags use bare{{ ... }}instead of{{- ... -}}. Each bare assignment leaks its leading indent (2 or 4 spaces) and trailing newline into the rendered output. For a placeholder code block the final render-hook output looks like:Goldmark sees a run of indented whitespace-only lines followed by an indented HTML block, interprets the leading portion as an indented code block, wraps it in
<pre><code>, and HTML-escapes every<→<. Users see a wall of escaped<span class="line">fragments instead of a code block.The
elsebranch (non-placeholder/non-callout code blocks) already uses{{- ... -}}on every action, which is why ordinary code blocks were unaffected. The regression only hit pages that use either theplaceholdersorcalloutfence attribute — i.e. almost every admin CLI / install / backup / sample-data page.Fix
Apply
{{- ... -}}whitespace trimming to every action inside theif or .Attributes.placeholders .Attributes.calloutbranch, matching the pattern theelsebranch already uses. No content files change, no shortcode templates change.Why not keep the collapse band-aid from #7083
The collapses in
layouts/shortcodes/influxdb/custom-timestamps.htmlandlayouts/shortcodes/code-tab-content.htmlfixed the sample-data pages only. They didn't help pages that wrap placeholder code blocks in other shortcodes (tab-content,expand, plain bullet lists, etc.), which is why backup-restore, users/add, upgrade, and ~15 others were still broken. Fixingrender-codeblock.htmlitself eliminates the class of bug everywhere in one place, so any wrapper shortcode works correctly regardless of whether its template has indented.Inner.Verification
Built locally with Hugo 0.149.0 extended against
origin/masterplus this commit.Site-wide count of pages containing the escaped-highlight pattern (
<div class="highlight):Specific pages spot-checked:
/influxdb3/enterprise/admin/backup-restore/✅/influxdb3/enterprise/admin/upgrade/✅/influxdb3/enterprise/admin/mcp-server/✅/influxdb3/enterprise/admin/backup-restore/✅/influxdb3/enterprise/admin/upgrade-from-core/✅/influxdb3/enterprise/reference/cli/influxdb3/write/✅/influxdb3/enterprise/write-data/best-practices/optimize-writes/✅/influxdb3/clustered/admin/users/add/✅/influxdb3/clustered/install/secure-cluster/auth/✅/influxdb3/clustered/write-data/best-practices/optimize-writes/✅/influxdb3/explorer/install/✅/influxdb3/core/get-started/write/and/query/— no regressions ✅Follow-ups (not in this PR)
<div class="highlightto catch any future regression of this class.Test plan
/influxdb3/enterprise/admin/backup-restore/Closes #7079