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

Updating a label with text containing square brackets hides those brackets and the word behind it #4830

Closed
michaelochs opened this issue Aug 1, 2024 · 4 comments

Comments

@michaelochs
Copy link

I am trying to present a block of text which is actually Objective-C source code. However if I do that in a Label, the text gets completely scrambled with all the text missing that follows a [.

So for example this text:

- (void)myFunction {
    [[self someView] doSomething:[self someMethod]]
}

Will render as this:

- (void)myFunction {
    [ doSomething:]
}

I would expect this level of interpretation from some rich text view but not from a standard label and I do not see anything in the API to disable this kind of parsing?

Is this a bug or am I holding it wrong? My code for updating is fairly simple:

def compose(self) -> ComposeResult:
    yield Label()

def watch_context(self, context):
    self.query_one(Label).update(context.details)  # context.details returns the above code as a single str
Copy link

github-actions bot commented Aug 1, 2024

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

Try yield Label(markup=False).

Label can also "contain more complex Rich renderables" and inherits from Static per the docs.

@michaelochs
Copy link
Author

Try yield Label(markup=False)

Oh amazing, that did the trick. Sorry for the noise, should have spotted that!

Copy link

github-actions bot commented Aug 1, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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