Terminal comment stripping removes full-line # comments from the copy-button payload while keeping them visible in the displayed code. Readers see the explanatory comments; pasting produces only the runnable commands.
How it works
Lines where the first non-whitespace character is # are removed from the copy payload. The displayed code is completely unaffected.
```bash title="setup"# Install dependenciesnpm install# Build the projectnpm run build# Start the servernpm start```# Install dependenciesnpm install# Build the projectnpm run build# Start the servernpm start→ The terminal block displays all six lines. Clicking the copy button copies only the three commands: npm install, npm run build, npm start. The # comment lines are excluded from the clipboard.
Stripping rules:
- A line is stripped if its first non-whitespace character is
#. Indented comments like# step 2are also stripped. - Inline
#after content (e.g.,echo hello # note) is preserved because the line starts withe, not#. - Blank lines between commands are preserved.
When it applies
Terminal comment stripping is gated on the block's resolved frame type, not the language. It applies to any block that resolves to FrameTerminal:
- Terminal languages (
bash,sh,zsh,powershell,fish,console, etc.) auto-detect as terminal frame whenWithFrameDetectionis active. ansiblocks also auto-detect as terminal frame.- Explicit
frame="terminal"on any language triggers stripping. - Editor frames and frameless blocks are unaffected regardless of language.
Disabling
To keep comments in the copy payload, disable stripping at engine construction:
engine := kazari.New( kazari.WithHighlighter(hl), kazari.WithTerminalCommentStripping(false),)Or in the config file:
terminalCommentStripping: falseConfiguration
| Option | Layer | Default | Description |
|---|---|---|---|
WithTerminalCommentStripping(bool) |
Go API | true |
Enable or disable comment stripping from the copy payload |
terminalCommentStripping |
Config file | true |
YAML/JSON equivalent |
Stripping is enabled by default. There is no per-block meta string override. It is an engine-wide setting.
Edge cases
- Enabled by default. Only affects the copy payload (
data-codeattribute). The displayed code is unchanged. - Inline
#after content (e.g.,echo hello # note) is preserved. Only full-line comments are stripped. - Indented comments (e.g.,
# step 2) are also stripped. - There is no
#!shebang exception in the stripping logic. However, shebang lines force auto-detection to editor frame, so stripping does not trigger under normal usage. Explicitframe="terminal"on code containing#!/bin/bashwould strip the shebang line from the copy payload. - Stripping also affects
BlockInfo.RawCodepassed to post-render callbacks registered viaWithPostRender.