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

Feature Request: Collapse a character vector like glue::glue_collapse() #637

Closed
jesadrperez opened this issue Oct 3, 2023 · 2 comments
Closed

Comments

@jesadrperez
Copy link

Hello,

When a character vector is collapsed, I would like an argument to pass along a string to use to separate the last two items (when they are at least two elements in the character vector). At this moment "and" is used and I cannot find a way to change it. The expected behavior would be similar to glue::glue_collapse().

For example:

cli::cli_inform("Choose either: {.code {LETTERS[1:4]}}")
#> Choose either: `A`, `B`, `C`, and `D`

changed to:

cli::cli_inform("Choose either: {.code {LETTERS[1:4]}}", .last = " or ")
#> Choose either: `A`, `B`, `C`, or `D`

The current work around is, which works but isn't elegant:

cli::cli_inform('Choose either: {.code {glue::glue_collapse(LETTERS[1:4], sep = ", ", last = " or ")}}')
#> Choose either: `A, B, C or D`

Thank you.

@gaborcsardi
Copy link
Member

❯ cli::cli_inform("Choose either: {.or {.code {LETTERS[1:4]}}}")
Choose either: `A`, `B`, `C`, or `D`

@jesadrperez
Copy link
Author

Thank you @gaborcsardi ! I see now that it is mentioned in the inline markup vignette. I will be closing this issue. Thank you again.

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