Files
max-sixty__worktrunk/docs/templates/shortcodes/terminal.html
Maximilian Roos 063e3da50d docs: wrap command-only terminal blocks; fix blank-line prompts (#3126)
The `wt list` JSON-output section (and every command-recipe block on the
docs site) rendered badly: the blank lines between recipes showed as
stray bare `$` prompts, and long `jq` pipelines overflowed the block's
right edge — scrolling out of view behind macOS's hidden overlay
scrollbar, so the tail of a command was simply invisible.

The recipe content in `src/cli/mod.rs` is clean Markdown; the defects
were entirely in the docs rendering layer, so the fix lives there and
leaves the auto-generated pages and the CLI source untouched.

- `docs/templates/shortcodes/terminal.html` — empty `|||` segments now
emit a real blank line instead of a `$ ` prompt, and command-only blocks
(no fixed-width output body) get a `terminal--commands` class.
- `docs/sass/custom.scss` — `.terminal--commands code { white-space:
pre-wrap }` wraps long pipelines at spaces, falling back to horizontal
scroll only for a single unbreakable token. Fixed-width tables and ASCII
output are untagged and keep their existing no-wrap + horizontal-scroll
behavior.

Verified against a local Zola build on `/list/` and `/tips-patterns/`:
command blocks wrap with 0px overflow, show no stray prompts, and keep
their group spacing; the three `wt list` tables are unaffected. No
`white-space` override exists in the narrow-width media queries, so
wrapping holds on mobile.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 10:14:55 -07:00

34 lines
1.1 KiB
HTML

{% if cmd %}
{% set fence = "```" %}
{% set cmd_lines = cmd | split(pat="|||") %}
{% if body is defined %}
{% set clean_body = body | regex_replace(pattern='<span class="cmd">[^<]*</span>\n?', rep="") %}
{% set extra_class = "" %}
{% else %}
{% set clean_body = "" %}
{% set extra_class = " terminal--commands" %}
{% endif %}
<pre class="terminal{{ extra_class }}"><code>
{%- for cmd_line in cmd_lines -%}
{%- set cmd_line = cmd_line | replace(from="__WT_OPEN__", to="{{") | replace(from="__WT_CLOSE__", to="}}") | replace(from="__WT_QUOT__", to='"') -%}
{%- if cmd_line | trim == "" -%}
{{ "
" }}
{%- else -%}
{%- set md = fence ~ "bash
" ~ cmd_line ~ "
" ~ fence -%}
{%- set raw = md | markdown -%}
{%- set hl = raw | regex_replace(pattern="(?s)<pre[^>]*><code[^>]*>(.*)</code>\s*</pre>", rep="$1") | trim -%}
{%- if cmd_line is starting_with("#") -%}
{{ hl | safe }}
{% else -%}
<span class="cmd">{{ hl | safe }}</span>
{% endif -%}
{%- endif -%}
{%- endfor -%}
{{ clean_body | safe }}</code></pre>
{% else %}
<pre class="terminal"><code>{{ body | safe }}</code></pre>
{% endif %}