Skip to content

feat: render --print output as styled markdown with --markdown - #292

Merged
Patel230 merged 1 commit into
mainfrom
feat/print-markdown
Sep 7, 2026
Merged

feat: render --print output as styled markdown with --markdown#292
Patel230 merged 1 commit into
mainfrom
feat/print-markdown

Conversation

@Patel230

@Patel230 Patel230 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a --markdown root flag that renders --print text-mode output through the existing markdown renderer (teal headers, bold, inline code, fenced code blocks, lists) instead of dumping raw **bold**/# header text.

Rendering is gated on ShouldColor() (TTY or FORCE_COLOR, not NO_COLOR/--quiet), so piped/scripted output stays raw and machine-parseable. When --markdown is set the response is buffered and rendered at the end (partial markdown cannot be styled); default streaming behavior is unchanged, and json/stream-json output is untouched.

Verification

  • go build ./..., go vet ./cmd/, gofumpt -l clean.
  • go test ./... exit 0 (incl. regenerated root-help golden file).
  • New TestRenderPrintResponse covers raw-when-color-off, raw-when-markdown-off, and styled-ANSI-when-both.
  • Flag registered and parses (graycode --help shows --markdown).

Add a --markdown root flag that renders the --print text-mode response
through the existing markdown renderer (teal headers, bold, inline code,
fenced code blocks, lists). Rendering only happens when color is enabled
(ShouldColor), so piped/NO_COLOR output stays raw and machine-parseable.

When --markdown is set, the response is buffered and rendered at the end
instead of streamed raw, since partial markdown cannot be styled. Default
streaming behavior is unchanged; json/stream-json output is untouched.

Extract renderPrintResponse for testability; unit-test the raw/render and
color gating. Update the root-help golden file for the new flag.
@Patel230
Patel230 merged commit 666ad9e into main Sep 7, 2026
25 of 26 checks passed
@Patel230
Patel230 deleted the feat/print-markdown branch September 7, 2026 07:53
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