Skip to content

Render ANSI colours in evaluated command output - #17

Merged
jhidding merged 1 commit into
mainfrom
docs/ansi-output
Nov 15, 2026
Merged

jhidding merged 1 commit into
mainfrom
docs/ansi-output

Conversation

@jhidding

Copy link
Copy Markdown
Contributor

Summary

The eval Lua filter inserts the output of {.bash .eval} code blocks into the documentation. In CI, rich-click forces colours (it detects GITHUB_ACTIONS), so the raw ANSI escape codes ended up in the HTML.

  • Spans instead of escape codes: the filter turns ANSI styles into <span> elements with classes (ansi-bold, ansi-dim, ansi-fg-3, …). 256-colour and true-colour codes become inline styles. Other escape sequences are removed, and so are all escape codes for formats other than HTML.
  • Colours in dark.css: the 16 standard colours, suited to the dark code-block background.
  • Same output everywhere: commands run with FORCE_COLOR=1, TERM=xterm, no COLORTERM, and COLUMNS=80, so local and CI builds give the same colours and width.
  • Site: docs/site is rebuilt.

Tests

Built locally: no escape codes are left in the HTML, and in a headless Chromium screenshot the brei --help output keeps its colours, with the box-drawing characters aligned.

🤖 Generated with Claude Code

The eval filter turns ANSI escape codes into spans with classes, styled
in dark.css, instead of showing the raw codes. Commands run with forced
colours at a width of 80, so local and CI builds look the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jhidding
jhidding merged commit 6be0afc into main Nov 15, 2026
9 checks passed
@jhidding
jhidding deleted the docs/ansi-output branch November 15, 2026 23:10
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.

1 participant