Comments (3)
Oh, that's super weird! Took me a moment to understand what you mean, but I get the same too by changing window width..
One line, default stays inline:
Two lines, default moves onto its own line:
This has got to be something weird with the way I'm using Rich to join these elements together. I'm using a list of renderables (can be different types, eg. Markdown
and Text
) within a rich Columns
object currently:
rich-click/src/rich_click/rich_click.py
Lines 230 to 232 in 66b584c
@willmcgugan - any ideas why this behaviour happens? Is there a way to get around this / a better way to join these?
from rich-click.
Minimal example with pure rich code:
from rich import print
from rich.console import Console
from rich.columns import Columns
from rich.markdown import Markdown
from rich.text import Text
shortext = Text("Short text")
longtext = Text("Some long text. See there how easy that is. It's amazing what you can do with a little love in your heart. Some long text. See there how easy that is. It's amazing what you can do with a little love in your heart.")
appended = Text.from_markup("[red]APPENDED RED TEXT[/]")
print(Columns([shortext, appended]))
print("-----")
print(Columns([longtext, appended]))
$ python minimal_example.py
Short text APPENDED RED TEXT
-----
Some long text. See there how easy that is. It's amazing what you can do with a little love in your
heart. Some long text. See there how easy that is. It's amazing what you can do with a little love
in your heart.
APPENDED RED TEXT
from rich-click.
Sorry, stream of consciousness here. I guess what rich is doing makes sense - they're called columns and you can't split a vertical column if the text wraps over a line.
So to get around this we need a different approach. The columns was suggested here: Textualize/rich#1951 (reply in thread) because using Group
always introduces newlines between elements.
We can't just concatenate the string and then format that, because the help text can be one of: raw text, rich markup text, markdown. The default should always be a rich Text
because we want consistent styling (and can't easily do [dim]
in markdown for example). We can't append Text
objects because they could be Markdown.
My best idea currently is to do mytext.append()
on purely Text
objects if we're not using Markdown (will be the majority of users) and fall back to using a Column
if markdown is enabled, with the caveat that we get this edge case ☝🏻
from rich-click.
Related Issues (20)
- Test help output in `rich-click` CLI is robust to lazy loading of modules. HOT 3
- Add `pytest-snapshot` or `syrupy` or similar HOT 1
- Expose a way to send usage information to stderr HOT 9
- Rich-Click does not translate the ascii codes into colors on windows 64 cmd.exe anymore HOT 3
- support providing a default/global `option_groups` config to apply to all commands HOT 7
- Unit tests should assert output to stderr on errors
- Either update or deprecate MacPorts install HOT 1
- `text_markup: Literal["rich", "markdown", "rst", None]` config option HOT 1
- Additional style options HOT 1
- `rich-click` CLI for version `1.8.0dev1` breaks backwards compatibility in edge case
- 1.9 wishlist
- 2.0 roadmap
- 'RichGroup' object has no attribute 'isolation' HOT 2
- Bugs (a) generating svg/html with decorator. (b) with root directory scripts HOT 1
- Interim blog post - "5 cool pre-made styles for your CLI" (title tentative)
- Color part of the help massage HOT 8
- OptionHighlighter is deprecated and will be removed in a future version. HOT 6
- Invalid MRO when importing rich_click HOT 4
- Continuting to receive "DeprecationWarning: OptionHighlighter is deprecated" as of 1.8.1 HOT 1
- Fix warning (again)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rich-click.