✨ feat(color): add color output support and configuration options#1242
Merged
✨ feat(color): add color output support and configuration options#1242
Conversation
Add jq-like -C flag to colorize markdown output with ANSI escape codes. Each markdown element type gets a distinct color (headings=bold+cyan, code=green, links=underline+blue, emphasis=italic+yellow, etc.). Implemented using a ColorTheme struct with PLAIN and COLORED constants to share rendering logic between to_string_with() and to_colored_string_with() without code duplication. Uses raw ANSI escape codes behind a "color" feature flag to avoid additional dependencies.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds opt-in ANSI colorized Markdown output to mq, with configuration via CLI flag and environment variables.
Changes:
- Introduces
-C/--color-outputinmq-runand documents it in the CLI reference + README. - Adds
mq-markdowncolor rendering viaColorTheme, including env-based customization (MQ_COLORS) andNO_COLORsupport. - Adds unit tests for colored rendering and a basic CLI smoke test.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/books/src/reference/env.md | Documents NO_COLOR and MQ_COLORS configuration and available theme keys. |
| docs/books/src/reference/cli.md | Adds -C/--color-output to CLI reference. |
| crates/mq-run/src/cli.rs | Implements -C flag behavior and NO_COLOR override; adds a CLI test. |
| crates/mq-run/Cargo.toml | Enables mq-markdown’s new color feature. |
| crates/mq-markdown/src/node.rs | Introduces ColorTheme and theme-aware rendering for nodes. |
| crates/mq-markdown/src/markdown.rs | Adds theme-aware Markdown rendering APIs + color tests. |
| crates/mq-markdown/src/lib.rs | Re-exports ColorTheme. |
| crates/mq-markdown/Cargo.toml | Adds the color feature flag. |
| README.md | Documents -C, MQ_COLORS, and NO_COLOR. |
a2e1225 to
877be05
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
crates/mq-markdown/src/markdown.rs:1
Markdown::render_with_themespecial-casesTableAlignand bypassesnode.render_with_theme(..., theme), so colored output won't applytheme.table_separator(or any future theming) to the table alignment row. To keep behavior consistent, incorporate the theme into this branch (or remove the special-case and rely on the node renderer while preserving the buffering logic).
#[cfg(feature = "html-to-markdown")]
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
crates/mq-markdown/src/markdown.rs:1
Markdown::render_with_themespecial-casesTableAlignbut ignores the passedtheme, soto_colored_string()won’t color table separators/alignment lines even when a colored theme is used. Applytheme.table_separator(or otherwise route this through themed rendering) in this special-case so tables are consistently colored.
#[cfg(feature = "html-to-markdown")]
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.
No description provided.