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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

format_inline() doesn't preserve newlines in interpolated strings #626

Open
davidchall opened this issue Aug 26, 2023 · 0 comments
Open
Labels
bug an unexpected problem or unintended behavior

Comments

@davidchall
Copy link
Contributor

cli 3.6.0 changed the behavior of format_inline() so it now preserves newlines. Firstly, thanks for this change! 馃憦

Unfortunately, this new behavior doesn't apply to interpolated strings (find examples from cli unit tests below). Is this a bug or should we document the behavior depends on whether interpolation is used? Note: form feed characters are preserved in both cases.

library(cli)

x <- "foo\nbar"
format_inline(x)
#> [1] "foo\nbar"
format_inline("{x}")
#> [1] "foo bar"

x <- "\nfoo\n\nbar\n"
format_inline(x)
#> [1] "\nfoo\n\nbar\n"
format_inline("{x}")
#> [1] " foo  bar "

x <- "foo\fbar"
format_inline(x)
#> [1] "foo\fbar"
format_inline("{x}")
#> [1] "foo\fbar"

x <- "\ffoo\f\fbar\f"
format_inline(x)
#> [1] "\ffoo\f\fbar\f"
format_inline("{x}")
#> [1] "\ffoo\f\fbar\f"

Created on 2023-08-26 with reprex v2.0.2

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants