From 98d890b2ead5fa73fae292248a6472c3788f44a6 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 16 Aug 2022 16:31:16 +0100 Subject: [PATCH] Add CHANGELOG entry for parsing escape codes in Pretty reprs --- CHANGELOG.md | 4 ++++ rich/pretty.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b2800e89..72c18cfe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Parse ANSI escape sequences in pretty repr https://github.com/Textualize/rich/pull/2470 + ### Fixed - Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458 diff --git a/rich/pretty.py b/rich/pretty.py index 1c43aa4d1..002508f7a 100644 --- a/rich/pretty.py +++ b/rich/pretty.py @@ -1007,4 +1007,10 @@ class StockKeepingUnit(NamedTuple): from rich import print - print(Pretty(data, indent_guides=True, max_string=20)) + # print(Pretty(data, indent_guides=True, max_string=20)) + + class Thing: + def __repr__(self) -> str: + return "Hello\x1b[38;5;239m World!" + + print(Pretty(Thing()))