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

Underscores are being stripped out incorrectly in table cells #10

Closed
darrenburns opened this issue Feb 24, 2020 · 3 comments
Closed

Underscores are being stripped out incorrectly in table cells #10

darrenburns opened this issue Feb 24, 2020 · 3 comments

Comments

@darrenburns
Copy link
Member

darrenburns commented Feb 24, 2020

I've got a table which I created like so:

    table = Table(show_header=False, padding=0, show_edge=False, box=0)
    table.add_column("outcome", style=theme, width=6, justify="center")
    table.add_column("location", style="test-location")
    table.add_column("description", style="none")

    table.add_row(outcome, location, f"{description} {reason}")

If the description contains two underscores, such as in many Python function names, the underscores are removed.

For example, in the following screenshot, the top line is the description string. The bottom line is the description as displayed in the table.

Screenshot 2020-02-24 at 19 33 08

This doesn't happen if the description contains a single _. I was guessing it was trying to render it as Markdown or something, but I get the same issue when setting markup=False when initialising the Console. 😄

@willmcgugan
Copy link
Collaborator

If you pass in a string to the table class, it will render it as console markup -- which is similar in some ways to markdown. I think the way you constructed the styles has disabled the italics.

If you want to stop Table from rendering console markup, you can use Text instances rather than plain strings.

The markup=False in the Console constructor will disable markup when you call console.print with a string. But on reflection, I think your instinct should be correct. It should disable it everywhere. I'll do that in the next release.

@darrenburns
Copy link
Member Author

I think the way you constructed the styles has disabled the italics.

Yeah, that's correct. I changed to using push_styles and it now renders like:
Screenshot 2020-02-24 at 20 48 01

If you want to stop Table from rendering console markup, you can use Text instances rather than plain strings.

Thanks! That works.

The markup=False in the Console constructor will disable markup when you call console.print with a string. But on reflection, I think your instinct should be correct. It should disable it everywhere. I'll do that in the next release.

Cool, thanks. 😄

Kudos on this project by the way. I've started shifting some things over and am really enjoying using the API.

@willmcgugan
Copy link
Collaborator

Kudos on this project by the way. I've started shifting some things over and am really enjoying using the API.

Cheers. It's been at the back of my mind for years, every time I tried to do anything fancy in the console. Finally got round to it.

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

No branches or pull requests

2 participants