close
Skip to content

Fix ConsoleOptions propagation#4084

Open
kmvanbrunt wants to merge 5 commits intoTextualize:masterfrom
kmvanbrunt:propagate_console_options
Open

Fix ConsoleOptions propagation#4084
kmvanbrunt wants to merge 5 commits intoTextualize:masterfrom
kmvanbrunt:propagate_console_options

Conversation

@kmvanbrunt
Copy link
Copy Markdown

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

AI?

  • AI was used to generate this PR

AI generated PRs may be accepted, but only if @willmcgugan has responded on an issue or discussion.

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate (see note about typos above).
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Fixes #4028

  1. Added the emoji field to ConsoleOptions, allowing emoji overrides passed to console.print() to be propagated down the rendering stack.

  2. Fixed several instances (Table, Rule, Columns, and Measure) where the renderables were calling console.render_str() but failing to pass the some or all of emoji, markup, and highlight settings from the active ConsoleOptions.

@kmvanbrunt kmvanbrunt changed the title Propagate console options Fix ConsoleOptions propagation Apr 19, 2026
Copy link
Copy Markdown

@alokshukla631 alokshukla631 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still incomplete on the highlight side.

Columns, Rule, Table, and Measurement.get() still call render_str(..., highlight=False), so console.print(..., highlight=True) appears to remain ignored for nested strings even after this patch. For example, on this branch:

from rich.console import Console
from rich.columns import Columns

console = Console(force_terminal=True, color_system="truecolor", _environ={})
console.print(Columns(["123"]), highlight=True)

still emits plain 123, while console.print("123", highlight=True) highlights it.

Could we propagate options.highlight through these calls as well, and add coverage for that path alongside the new emoji / markup tests?

@kmvanbrunt
Copy link
Copy Markdown
Author

@alokshukla631

I honestly don't know the correct answer concerning highlight. Table and Measure were already setting it to False so I left those alone to preserve existing behavior.

For Columns and Rule I had to guess, so I based it on what I saw in Table and Measure.
If they are intended to support highlighting, then I of course need to pass along options.highlight.

@willmcgugan Can you provide some insight into this? Are any of these four Renderables supposed to support highlighting?

@alokshukla631
Copy link
Copy Markdown

I took a quick look on current master: console.print(Columns(["123"]), highlight=True) and console.print(Rule("123"), highlight=True) both highlight the embedded string there, so I don't think matching the older Table / Measure behavior is the right baseline for those two.

The part that still seems ambiguous to me is whether Table / Measurement should also honor options.highlight, but at least Columns and Rule already do in current Rich.

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.

[BUG] Failure to propagate formatting overrides via ConsoleOptions

2 participants