From cd6d0fc0f1fe9ba246ffdd20ce84e35a549261ae Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Thu, 15 Feb 2024 08:58:25 -0500 Subject: [PATCH 1/2] Add advice for text + line + col + file hyperlink --- R/cliapp-docs.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index 70ae69fd6..64de1f6c4 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -567,7 +567,20 @@ NULL #' ```{asciicast links-file-3} #' cli_text("... see line 5 in {.file ~/.Rprofile:5}.") #' ``` +#' +#' There is also support for displaying text and line numbers but the syntax +#' is a bit different. You have to use `style_hyperlink()` with `params`. +#' Make sure that `line` and `col` are numeric as they will be ignored otherwise. #' +#' ```{asciicast links-file-4} +#' link <- style_hyperlink( +#' text = "R profile at line 5", +#' url = "file://~/.Rprofile", +#' params = list(line = 5, col = 1) +#' ) +#' cli_text("... see {link}") +#' ``` +#' #' ## Default handler #' #' In RStudio `file:` URLs open within RStudio. If you click on a file @@ -579,7 +592,7 @@ NULL #' One issue with using `.href` file files is that it does not look great #' if hyperlinks are not available. This will be improved in the future: #' -#' ```{asciicast links-file-4} +#' ```{asciicast links-file-5} #' local({ #' withr::local_options(cli.hyperlink = FALSE) #' prof <- path.expand("~/.Rprofile") From 94fb8e80696e28d9ca1e2013dbf2a4729e7b060b Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Thu, 10 Oct 2024 08:48:03 -0400 Subject: [PATCH 2/2] Suggest `c()` instead of `list()` --- R/cliapp-docs.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cliapp-docs.R b/R/cliapp-docs.R index 64de1f6c4..d486aa650 100644 --- a/R/cliapp-docs.R +++ b/R/cliapp-docs.R @@ -576,7 +576,7 @@ NULL #' link <- style_hyperlink( #' text = "R profile at line 5", #' url = "file://~/.Rprofile", -#' params = list(line = 5, col = 1) +#' params = c(line = 5, col = 1) #' ) #' cli_text("... see {link}") #' ```