docs: Fix ANSI escape sequences in pack CLI leaking into documentation#940
Merged
Merged
Conversation
buildpacks#891) The get_pack_commands.go generator uses cobra/doc.GenMarkdownTreeCustom to produce markdown from the pack command tree. Some pack commands include ANSI color codes in their description strings (e.g. \x1b[94m...\x1b[0m) to improve terminal --help readability. These codes were passing through the generator unmodified and appearing as noise in the rendered documentation. Added a post-generation step that walks the output directory and strips SGR ANSI escape sequences (\x1b\[[0-9;]*m) from all generated .md files. This is the appropriate place to handle the conversion — the generator is the boundary between terminal output and markdown, and stripping color codes there keeps the fix localized without affecting the upstream CLI's terminal experience. Three files were affected: pack_config_pull-policy.md, pack_config_lifecycle-image.md, and pack_config_registries_default.md. Signed-off-by: Lorenzo Campanella <enzocampanella98@gmail.com>
ThusharaSampath
approved these changes
May 28, 2026
AidanDelaney
approved these changes
Jun 7, 2026
Member
AidanDelaney
left a comment
There was a problem hiding this comment.
This is great thank you!
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 7, 2026
#891) (#940) The get_pack_commands.go generator uses cobra/doc.GenMarkdownTreeCustom to produce markdown from the pack command tree. Some pack commands include ANSI color codes in their description strings (e.g. \x1b[94m...\x1b[0m) to improve terminal --help readability. These codes were passing through the generator unmodified and appearing as noise in the rendered documentation. Added a post-generation step that walks the output directory and strips SGR ANSI escape sequences (\x1b\[[0-9;]*m) from all generated .md files. This is the appropriate place to handle the conversion — the generator is the boundary between terminal output and markdown, and stripping color codes there keeps the fix localized without affecting the upstream CLI's terminal experience. Signed-off-by: Lorenzo Campanella <enzocampanella98@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue
which is [94malways[0m#891Problem
The
get_pack_commands.gogenerator usescobra/doc.GenMarkdownTreeCustomto produce markdown from the pack command tree. Some pack commands include ANSI color codes in their description strings (e.g.\x1b[94m...\x1b[0m) to improve terminal --help readability. These codes were passing through the generator unmodified and appearing as noise in the rendered documentation. See #891 for screenshots of the three affected places in the documentation. Which are:https://buildpacks.io/docs/for-platform-operators/how-to/integrate-ci/pack/cli/pack_config_pull-policy/
https://buildpacks.io/docs/for-platform-operators/how-to/integrate-ci/pack/cli/pack_config_lifecycle-image/
https://buildpacks.io/docs/for-platform-operators/how-to/integrate-ci/pack/cli/pack_config_registries_default/
Solution
Added a post-generation step that walks the output directory and strips ANSI escape sequences
(\x1b\[[0-9;]*m)from all generated .md files. This is the appropriate place to handle the conversion (rather than changing the pack CLI output) — the generator is the boundary between terminal output and markdown, and stripping color codes there keeps the fix localized without affecting the upstream CLI's terminal experience. The fix also future-proofs the documentation against newly added CLI ANSI escape codes.Three generated markdown files were affected:
pack_config_pull-policy.md,pack_config_lifecycle-image.md, andpack_config_registries_default.md.Testing
make serve