cli icon indicating copy to clipboard operation
cli copied to clipboard

link text for files does not display properly with `fs_path` objects

Open zkamvar opened this issue 1 year ago • 1 comments

If I pass output from {fs} into link text, the actual link still shows up in the output:

path <- fs::path("a/b")
# with fs_path object
cli::cli_text("go to {.href [c](file://{path})}")
#> go to a/bc
#
# with character
cli::cli_text("go to {.href [c](file://{unclass(path)})}")
#> go to c

FWIW, this is what the output of reprex looks like:

path <- fs::path("a/b")
# with fs_path object
cli::cli_text("go to {.href [c](file://{path})}")
#> go to c (<file://'a/b'>)
cli::cli_text("go to {.href [c](file://{unclass(path)})}")
#
# with character
#> go to c (<file://a/b>)

Created on 2024-08-09 with reprex v2.1.1

zkamvar avatar Aug 09 '24 17:08 zkamvar

I'm poking around file hyperlinks and came through here. Here's another view of what has gone wrong:

path <- fs::path("a/b")
cli::format_inline("go to {.href [c](file://{path})}")
#> [1] "go to \033]8;;file://'\033]8;;file:///Users/jenny/rrr/cli/a/b\aa/b\033]8;;\a'\ac"

cli::format_inline("go to {.href [c](file://{unclass(path)})}")
#> [1] "go to \033]8;;file://a/b\ac\033]8;;\a"

jennybc avatar Dec 11 '24 18:12 jennybc