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

Can't seem to escape _ in string literals #190

Closed
gwenwindflower opened this issue Apr 14, 2024 · 5 comments
Closed

Can't seem to escape _ in string literals #190

gwenwindflower opened this issue Apr 14, 2024 · 5 comments

Comments

@gwenwindflower
Copy link

Describe the bug
I have the need to get a literal _ in a Form element's Description, not italics. I've tried several methods for escaping and searched for an answer but can't seem to find the right way to do this.

Use case is displaying the name of an env var in my TUI that the user needs to set.

To Reproduce
Steps to reproduce the behavior:

huh.NewGroup(
huh.NewNote().
Title("🤖 Experimental: LLM Generation 🦙✨").
Description(`*_Optional_* LLM-powered alpha features.

Currently generates: 
- column _descriptions_
- relevant _tests_
via the Groq API.

You'll need:
✴︎ A Groq API key
✴︎ Key stored in env var GROQ\_API\_KEY`),
...

Expected behavior
I would expect escaping with a backslash or something similar (doubling the character, etc) to allow an actual underscore in the string instead of triggering formatting.

Screenshots
Screenshot 2024-04-14 at 7 30 15 AM

Desktop (please complete the following information):

  • OS: MacOS Sonoma 14.1.1
  • Version: v0.3.1

Additional context:
Thanks for making such a great library! I love it so much.

@maaslalani
Copy link
Member

Hey @gwenwindflower, thanks so much for opening this issue. We should probably have a "Raw" mode for non-markdown based notes.

@mikesart
Copy link

This is throwing me off with the Note as well. I'm adding this filename:
user-stats_2024-04-28_15-55-21.csv
And the _ chars are italicizing/removing parts even if I put the filename in a codeblock with ticks. And agree, love this library. Thank you!

@maaslalani
Copy link
Member

Hey, thanks all for the feedback.

As a quick fix, we've allowed escaping characters with a backslash.

image
How may we take your order?

`CHARM\\_BURGER`

@maaslalani
Copy link
Member

What we may want to do in the future is add support for a Transform(s string) string or Render(s string) string function so you can use whichever rendering you want and by default have a simple markdown parser but that would enable you to use glamour or your own custom string transformation.

@maaslalani
Copy link
Member

Closing for now since this particular issue is solved.

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

3 participants