`%?%` <- function(x, y) if (length(x) > 0) y
`%||%` <- function(x, y) if (length(x) > 0) x else y
md_to_html <- function(input) {
tmp_in <- tempfile()
tmp_out <- tempfile()
on.exit(unlink(c(tmp_in, tmp_out), force = TRUE))
writeLines(input, tmp_in)
rmarkdown::pandoc_convert(tmp_in, to = "html", from = "markdown", output = tmp_out)
readr::read_file(tmp_out)
}
mkdir <- function(x, recursive = FALSE) {
walk(x, dir.create, showWarnings = FALSE, recursive = recursive)
}
slug <- function(x) {
x %>%
tolower() %>%
stringr::str_replace_all("'", "") %>%
stringr::str_replace_all("[^a-z0-9]+", "-") %>%
stringr::str_replace_all("-+", "-") %>%
stringr::str_replace_all("^-|-$", "")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.