a <- function(text, href) {
ifelse(is.na(href), text, paste0("<a href='", href, "'>", text, "</a>"))
}
link_url <- function(text, href) {
# Needs to handle NA for desc::desc_get()
if (is.null(href) || identical(href, NA)) {
return()
}
# insert zero-width spaces to allow for nicer line breaks
label <- gsub("(/+)", "\\1​", href)
paste0(text, " at <br /><a href='", href, "'>", label, "</a>")
}
linkify <- function(text) {
text <- escape_html(text)
text <- gsub(
"<doi:([^&]+)>", # DOIs with < > & are not supported
"<<a href='https://doi.org/\\1'>doi:\\1</a>>",
text, ignore.case = TRUE
)
text <- gsub(
"<arXiv:([^&]+)>",
"<<a href='https://arxiv.org/abs/\\1'>arXiv:\\1</a>>",
text, ignore.case = TRUE
)
text <- gsub(
"<((http|ftp)[^&]+)>", # URIs with & are not supported
"<<a href='\\1'>\\1</a>>",
text
)
text
}
dont_index <- function(x) {
paste0("<div class='dont-index'>", x, "</div>")
}
escape_html <- function(x) {
x <- gsub("&", "&", x)
x <- gsub("<", "<", x)
x <- gsub(">", ">", x)
# x <- gsub("'", "'", x)
# x <- gsub("\"", """, x)
x
}
unescape_html <- function(x) {
x <- gsub("<", "<", x)
x <- gsub(">", ">", x)
x <- gsub("&", "&", x)
x
}
strip_html_tags <- function(x) gsub("<.*?>", "", x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.