Bad interaction with `fs_path` default formatting and hyperlink generation

Open
#683 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
cli

Research direction

Start by running the reproducible examples using cli::cli_inform(), fs::path(), and hyperlinks enabled, comparing character paths with fs paths. Trace the fs_path default theming and hyperlink generation involved in the rendered output; done means fs paths produce the same valid run hyperlink structure as equivalent character paths, including nested pkgdown::preview_page() calls.

Written by the indexing model from the issue text.

Description

bug tidy-dev-day :nerd_face:

See also https://github.com/r-lib/pkgdown/pull/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

Dominant language
R
Stars
726
Forks
94
Avg merge
3h 35m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/cli

All issues in r-lib/cli

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.