Skip to content

Bad interaction with fs_path default formatting and hyperlink generation #683

Description

@DavisVaughan

See also r-lib/pkgdown#2436

In pkgdown we accidentally tried to interpolate fs paths into cli strings and that caused some bad link generation. I think it has something to do with the fs_path default theming? Notice how the blue output below isn't right.

Screenshot 2024-04-10 at 9 37 48 AM
library(cli)
library(fs)

testthat::local_reproducible_output(hyperlinks = TRUE)

path <- "~/Desktop/foo.R"
cli::cli_inform("{.run ['hi mom']({path})}")
#> �]8;;x-r-run:~/Desktop/foo.R�'hi mom'�]8;;�

path <- fs::path("~/Desktop/foo.R")
cli::cli_inform("{.run ['hi mom']({path})}")
#> �]8;;x-r-run:'�]8;;file:///Users/davis/Desktop/foo.R�~/Desktop/foo.R�]8;;�'�'hi mom'

# real example was more like this
# clicking the link should run `pkgdown::preview_page('~/Desktop/foo.R')`
path <- "~/Desktop/foo.R"
cli::cli_inform("{.run ['file.R'](pkgdown::preview_page('{path}'))}")
#> �]8;;x-r-run:pkgdown::preview_page('~/Desktop/foo.R')�'file.R'�]8;;�

# weirdness
path <- fs::path("~/Desktop/foo.R")
cli::cli_inform("{.run ['file.R'](pkgdown::preview_page('{path}'))}")
#> �]8;;x-r-run:pkgdown::preview_page(''�]8;;file:///Users/davis/Desktop/foo.R�~/Desktop/foo.R�]8;;�'')�'file.R'

Created on 2024-04-10 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviortidy-dev-day 🤓Tidyverse Developer Day rstd.io/tidy-dev-day

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions