Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Possible missing end keyword argument in Text.from_markup #2054

Closed
cadojo opened this issue Mar 14, 2022 · 6 comments · Fixed by #2095
Closed

[BUG] Possible missing end keyword argument in Text.from_markup #2054

cadojo opened this issue Mar 14, 2022 · 6 comments · Fixed by #2095

Comments

@cadojo
Copy link

cadojo commented Mar 14, 2022

Is Text.from_markup missing an end keyword-argument?

I use Text("Hello, world!", end="") to create Text object without a newline. If I want to use console markup, I'd want to use Text.from_markup(":rocket: Hello, world!", end=""), but this throws an argument error.

@willmcgugan
Copy link
Collaborator

You may be right! In the meantime, you can set end after you have created the Text object with text.end=''

@wasi-master
Copy link
Contributor

@willmcgugan need a PR?

@willmcgugan
Copy link
Collaborator

If you wouldn't mind! :)

@wasi-master
Copy link
Contributor

@willmcgugan while testing my changes, I noticed one thing (same happened with my from_markup implementation)

import rich
from rich.text import Text

rich.print(Text("hello", end=" ") +  Text("hi"))

shouldn't this print hello hi and not hellohi? If not, how could I test if the end parameter is actually working?

@willmcgugan
Copy link
Collaborator

I don't think that would be desirable, although I can see the logic. The default is "\n", but you wouldn't want adding text to have new lines.

console.print will join text objects together and override end. The end will work in different contexts, the easiest way to test would be to put one or more Text instances within a rich.console.Group. Then print and capture the output. See the docs for capturing.

@github-actions
Copy link

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants