If I have a regular function name, this works fine:
fn_name <- "foo"
cli::cli_li("My fuction is {.fn {fn_name}}")
#> • My fuction is `foo()`
But, if I have a function name with a .
as a prefix, this produces undesired output:
cli::cli_li("My fuction is {.fn .{fn_name}}")
#> • My fuction is `` .`foo()` ()``
Desired output:
#> • My fuction is `.foo()`
EDIT:
The more general problem I am trying to solve is to produce the following message:
fn_name <- "foo"
cli::cli_li("Fuction name changed from {.fn {fn_name}} to {.fn .{fn_name}}")
#> • Fuction name changed from `foo()` to `` .`foo()` ()``
Desired output:
#> • Fuction name changed from `foo()` to `.foo()`
CodePudding user response:
Why not use the real function name as the function name?
fn_name <- ".foo"
cli::cli_li("My function is {.fn {fn_name}}")
#> • My function is `.foo()`
CodePudding user response:
Using paste0
you could do:
fn_name <- "foo"
cli::cli_li("Fuction name changed from {.fn {fn_name}} to {.fn {paste0('.', fn_name)}}")
#> • Fuction name changed from `foo()` to `.foo()`