@@ -68,9 +68,12 @@ get_title <- function(url) {
68
68
# ' @export
69
69
to_pkg <- function (pkg , type = c(" tooltip" , " plain" ), keep_braces = TRUE , ... ) {
70
70
type <- rlang :: arg_match(type )
71
+ link_text <- glue :: glue(if (keep_braces ) " {{{pkg}}}" else " {pkg}" )
71
72
72
73
url <- downlit :: href_package(pkg )
73
- link_text <- glue :: glue(if (keep_braces ) " {{{pkg}}}" else " {pkg}" )
74
+ if (is.na(url )) {
75
+ return (tags $ span(link_text , class = " r-link-pkg-error" ))
76
+ }
74
77
link <- tags $ a(link_text , href = url , class = " r-link-pkg" , target = " _blank" )
75
78
76
79
switch (
@@ -85,12 +88,16 @@ to_pkg <- function(pkg, type = c("tooltip", "plain"), keep_braces = TRUE, ...) {
85
88
to_call <- function (call , type = c(" tooltip" , " plain" ), keep_pkg_prefix = TRUE , ... ) {
86
89
type <- rlang :: arg_match(type )
87
90
88
- url <- downlit :: autolink_url(call )
89
91
link_text <- if (keep_pkg_prefix ) {
90
92
call
91
93
} else {
92
94
glue :: glue(" {fun}()" , fun = stringr :: str_extract(call , rx_call , group = 2 ))
93
95
}
96
+
97
+ url <- downlit :: autolink_url(call )
98
+ if (is.na(url )) {
99
+ return (tags $ span(link_text , class = " r-link-pkg-error" ))
100
+ }
94
101
link <- tags $ a(link_text , href = url , class = " r-link-call" , target = " _blank" )
95
102
96
103
switch (
0 commit comments