diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7332fee..ef07ec06a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ## [13.9.4] - 2024-11-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d8985ca13..96259dac8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -5,6 +5,7 @@ The following people have contributed to the development of Rich: - [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) diff --git a/rich/console.py b/rich/console.py index 3ec9a8aab..69b129e9d 100644 --- a/rich/console.py +++ b/rich/console.py @@ -534,6 +534,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, @@ -790,7 +800,7 @@ def _theme_stack(self) -> ThemeStack: 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