huh icon indicating copy to clipboard operation
huh copied to clipboard

Can't seem to escape `_` in string literals

Open gwenwindflower opened this issue 10 months ago • 2 comments

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.

gwenwindflower avatar Apr 14 '24 12:04 gwenwindflower

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

maaslalani avatar Apr 25 '24 18:04 maaslalani

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!

mikesart avatar Apr 28 '24 22:04 mikesart

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 avatar May 25 '24 17:05 maaslalani

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 avatar May 25 '24 17:05 maaslalani

Closing for now since this particular issue is solved.

maaslalani avatar May 25 '24 17:05 maaslalani