From fc767f11a8ab96a8394995425160660b72037125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Camargo?= Date: Thu, 14 Apr 2022 19:14:24 -0300 Subject: [PATCH 1/3] Make `_make_rich_rext` remove text indentations with `inspect.cleandoc` --- src/rich_click/rich_click.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rich_click/rich_click.py b/src/rich_click/rich_click.py index 3823f548..098e609a 100644 --- a/src/rich_click/rich_click.py +++ b/src/rich_click/rich_click.py @@ -1,3 +1,4 @@ +import inspect import re from typing import Dict, List, Optional, Union @@ -114,7 +115,7 @@ def _get_rich_console() -> Console: def _make_rich_rext(text: str, style: str = "") -> Union[rich.markdown.Markdown, rich.text.Text]: - """Take a string and return styled text. + """Take a string, remove indentations, and return styled text. By default, return the text as a Rich Text with the request style. If USE_RICH_MARKUP is True, also parse the text for Rich markup strings. @@ -130,6 +131,8 @@ def _make_rich_rext(text: str, style: str = "") -> Union[rich.markdown.Markdown, Returns: MarkdownElement or Text: Styled text object """ + # Remove indentations from input text + text = inspect.cleandoc(text) if USE_MARKDOWN: if USE_MARKDOWN_EMOJI: text = Emoji.replace(text) From 21410d8c00bcdb7fbde9d2513dc71274618ca8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Camargo?= Date: Thu, 14 Apr 2022 19:22:05 -0300 Subject: [PATCH 2/3] Add indentation removal to CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4b2468..12e7a17f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Bumped minimum version of `rich` from `10` to `10.7.0` (when `Group` was introduced) - Refactored CLI's patching functionality to support `from rich_click.cli import patch`. +- Make `_make_rich_rext` remove text indentations using `inspect.cleandoc`. ## Version 1.3.0 (2022-03-29) From 03a0031d184af206f7cd9ceafa48ee448dec1987 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Wed, 27 Apr 2022 11:01:02 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e7a17f..1db69a5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Bumped minimum version of `rich` from `10` to `10.7.0` (when `Group` was introduced) - Refactored CLI's patching functionality to support `from rich_click.cli import patch`. -- Make `_make_rich_rext` remove text indentations using `inspect.cleandoc`. +- Make `_make_rich_rext` remove text indentations using `inspect.cleandoc` [[#55](https://github.com/ewels/rich-click/issues/55)] ## Version 1.3.0 (2022-03-29)