Skip to content

fix(hugo): render option-tabs buttons instead of escaping them (#1591) - #1597

Merged
jung-thomas merged 1 commit into
mainfrom
worktree-fix-1591-option-tabs-buttons
Aug 10, 2026
Merged

jung-thomas merged 1 commit into
mainfrom
worktree-fix-1591-option-tabs-buttons

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Fixes #1591

Problem

On tutorials that use [OPTION BEGIN] blocks (e.g. hana-cloud-mission-trial-3), the tab buttons rendered as escaped HTML source text inside a <pre><code> block instead of as clickable tabs:

<button class=&quot;fd-tabs__item is-selected&quot; ...&gt;Free Tier&lt;/button&gt;

The tab panels rendered fine — only the button bar was broken.

Root cause

scripts/parsers/options.ts emits the tab group as a percent-delimited shortcode ({{% option-tabs %}}). Percent delimiters tell Hugo to re-process the shortcode's rendered output as markdown. The template:

  1. indented the <button> lines 4 spaces, and
  2. put {{ range }} / {{ end }} on their own lines, producing blank lines inside the output.

Goldmark closed the raw-HTML block at the first blank line, then parsed the 4-space-indented <button> lines as an indented code block → escaped them.

Fix

Whitespace-trim the control lines ({{- -}}) and de-indent the <button> so the shortcode output is one contiguous, un-indented HTML block that Goldmark passes through verbatim. Panels are unaffected (they arrive via .Inner).

Testing

  • Added test/unit/option-tabs-render.test.ts — spins up a throwaway Hugo site with the real shortcode templates and asserts the buttons render as real <button> elements, not escaped source. Verified it fails against the old template and passes against the fix.
  • Existing scripts/__tests__/options-hugo.test.ts still green (20/20 with the new test).

The option-tabs shortcode is invoked with percent delimiters
({{% option-tabs %}}), so Hugo re-processes its rendered output as
markdown. The template indented the <button> lines 4 spaces and emitted
blank lines between the wrapping <div>s (from {{ range }}/{{ end }} on
their own lines). Goldmark then closed the raw-HTML block at the blank
line and parsed the indented <button> lines as an indented code block,
escaping them into <pre><code>&lt;button...&gt;</code></pre>.

Symptom: the Free Tier / Production tab buttons on
tutorials/hana-cloud-mission-trial-3 showed as escaped HTML source
instead of clickable tabs.

Fix: whitespace-trim the control lines ({{- -}}) and de-indent the
<button> so the output stays a single un-indented HTML block that
Goldmark passes through verbatim. Adds a Hugo-render regression test
that fails on the old template and passes on the new one.
@jung-thomas
jung-thomas merged commit ef6faca into main Aug 10, 2026
4 checks passed
@jung-thomas
jung-thomas deleted the worktree-fix-1591-option-tabs-buttons branch August 13, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML Buttons not rendering in tutorials -

1 participant