This commit is contained in:
banteg 2025-06-25 15:09:39 +08:00 committed by GitHub
commit caa958e1b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View file

@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Upcoming
### Changed
- Enabled color support in marimo notebooks. https://github.com/Textualize/rich/pull/3651
## [Unreleased]

View file

@ -5,6 +5,7 @@ The following people have contributed to the development of Rich:
<!-- Add your name below, sort alphabetically by surname. Link to GitHub profile / your home page. -->
- [Patrick Arminio](https://github.com/patrick91)
- [banteg](https://github.com/banteg)
- [Gregory Beauregard](https://github.com/GBeauregard/pyffstream)
- [Artur Borecki](https://github.com/pufereq)
- [Pedro Aaron](https://github.com/paaaron)

View file

@ -528,6 +528,16 @@ def _is_jupyter() -> bool: # pragma: no cover
return False # Other type (?)
def _is_marimo() -> bool: # pragma: no cover
"""Check if we're running in a marimo notebook."""
try:
import marimo
return marimo.running_in_notebook() is True
except (ImportError, AttributeError):
return False
COLOR_SYSTEMS = {
"standard": ColorSystem.STANDARD,
"256": ColorSystem.EIGHT_BIT,
@ -794,7 +804,7 @@ class Console:
def _detect_color_system(self) -> Optional[ColorSystem]:
"""Detect color system from env vars."""
if self.is_jupyter:
if self.is_jupyter or _is_marimo():
return ColorSystem.TRUECOLOR
if not self.is_terminal or self.is_dumb_terminal:
return None