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

New {.bullets } style #363

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

New {.bullets } style #363

wants to merge 2 commits into from

Conversation

gaborcsardi
Copy link
Member

New {.bullets } style

To collapse vectors into bullets:

❯ cli_text("Some values {.bullets {letters[1:5]}} blah blah")
Some values • a
• b
• c
• d
• e blah blah

Right now you need to add newlines explicitly at the beginning and at the end:

❯ cli_text("Some values\f{.bullets {letters[1:5]}}\f blah blah")
Some values
• a
• b
• c
• d
• e
blah blah

It can be combined with markup, but the markup has to be nested inside:

❯ cli_text("Some values\f {.bullets {.val {letters[1:5]}}}\f blah blah")
Some values
• "a"
• "b"
• "c"
• "d"
• "e"
blah blah

@jennybc Should we always add line breaks at the beginning and the end?

Closes #265.

To collapse vectors into bullets:

```
❯ cli_text("Some values {.bullets {letters[1:5]}} blah blah")
Some values • a
• b
• c
• d
• e blah blah
```

Closes #265.
Copy link
Member

@lionel- lionel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

I agree that introducing newlines automatically around bullet lists would be more user friendly since that's the desired formatting 99% of the time.

@gaborcsardi
Copy link
Member Author

gaborcsardi commented Dec 7, 2021

I agree that introducing newlines automatically around bullet lists would be more user friendly since that's the desired formatting 99% of the time.

True, but it is easy to add newlines with \f, and if we make them the default, then there is currently no way to remove them.

@gaborcsardi
Copy link
Member Author

True, but it is easy to add newlines with \f, and if we make them the default, then there is currently no way to remove them.

OTOH we can always make a different class for that later, if it turns out to be needed.

@lionel-
Copy link
Member

lionel- commented Dec 7, 2021

Or maybe we could add newlines like this? It seems more readable:

cli::cli_text("
  Some values
  {.bullets {letters[1:5]}}
  blah blah
")

(sorry if that doesn't make sense in the cli DSL with which I'm not familiar yet)

@gaborcsardi
Copy link
Member Author

gaborcsardi commented Dec 7, 2021

Or maybe we could add newlines like this? It seems more readable:

Yeah, \n is just space in cli_text(), so you can wrap text in your editor and it will be re-wrapped to the screen width when printing. Hence the \f.

@lionel-
Copy link
Member

lionel- commented Dec 7, 2021

Is the leading space in the block of text ignored or is it taken literally?

If blocks of text are the default way of using cli, then having to use \f for the inline cases seem fine. It requires knowing the difference between \n and \f in the context of cli but that's not too bad.

@gaborcsardi
Copy link
Member Author

Leading space is ignored, yeah:

cli::cli_text("    foo bar")
foo bar

@gaborcsardi
Copy link
Member Author

But I really don't mind putting in the newlines by default, I think we both agree that that's most common.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally format collapsed vectors as a bullet list
2 participants