Skip to content

Commit

Permalink
Switch vignette links over
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Nov 5, 2024
1 parent 74abfb7 commit 1c2a4ff
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions R/ansi-hyperlink.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,16 @@ make_link_url <- function(txt) {
make_link_vignette <- function(txt) {
mch <- re_match(txt, "^\\[(?<text>.*)\\]\\((?<url>.*)\\)$")
text <- ifelse(is.na(mch$text), txt, mch$text)
url <- ifelse(is.na(mch$url), txt, mch$url)
vignette <- ifelse(is.na(mch$url), txt, mch$url)

sprt <- ansi_hyperlink_types()$vignette
if (sprt) {
scheme <- if (identical(attr(sprt, "type"), "rstudio")) {
"ide:vignette"
} else {
"x-r-vignette"
}
style_hyperlink(text = text, url = paste0(scheme, ":", url))

} else {
url2 <- vcapply(url, function(url1) format_inline("{.code vignette({url1})}"))
ifelse(text == url, url2, paste0(text, " (", url2, ")"))
if (!sprt) {
vignette2 <- vcapply(vignette, function(x) format_inline("{.code vignette({x})}"))
return(ifelse(text == vignette, vignette2, paste0(text, " (", vignette2, ")")))
}

fmt <- get_hyperlink_format("vignette")
style_hyperlink(text = text, url = glue(fmt))
}

#' Terminal Hyperlinks
Expand Down

0 comments on commit 1c2a4ff

Please sign in to comment.