Commit 25814d6
committed
fix(layouts): trim whitespace in render-codeblock placeholder/callout 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 #70791 parent 37ac898 commit 25814d6
1 file changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments