Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@davidchall

Description

@davidchall

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions