Nothing
#' Replace HTML Markup
#'
#' Replaces HTML markup. The angle braces are removed and the HTML symbol
#' markup is replaced with equivalent symbols.
#'
#' @details Replacements for symbols are as follows:
#'
#' \tabular{lr}{
#' \bold{html} \tab \bold{symbol} \cr
#' © \tab (c) \cr
#' ® \tab (r) \cr
#' ™ \tab tm \cr
#' “ \tab " \cr
#' ” \tab " \cr
#' ‘ \tab ' \cr
#' ’ \tab ' \cr
#' • \tab - \cr
#' · \tab - \cr
#' ⋅ \tab [] \cr
#' – \tab - \cr
#' — \tab - \cr
#' ¢ \tab cents \cr
#' £ \tab pounds \cr
#' € \tab euro \cr
#' ≠ \tab != \cr
#' ½ \tab half \cr
#' ¼ \tab quarter \cr
#' ¾ \tab three fourths \cr
#' ° \tab degrees \cr
#' ← \tab <- \cr
#' → \tab -> \cr
#' … \tab ... \cr
#' \tab \cr
#' < \tab < \cr
#' > \tab > \cr
#' & \tab & \cr
#' " \tab " \cr
#' ' \tab ' \cr
#' ¥ \tab yen \cr
#' }
#'
#' @param x The text variable.
#' @param symbol logical. If code{TRUE} the symbols are retained with appropriate
#' replacements. If \code{FALSE} they are removed.
#' @param \ldots Ignored.
#' @return Returns a vector with HTML markup replaced.
#' @keywords html
#' @export
#' @examples
#' x <- c(
#' "<bold>Random</bold> text with symbols: < > & " '",
#' "<p>More text</p> ¢ £ ¥ € © ®"
#' )
#'
#' replace_html(x)
#' replace_html(x, FALSE)
#' replace_white(replace_html(x, FALSE))
replace_html <- function(x, symbol = TRUE, ...){
if (isTRUE(symbol)) {
reps <- html_symbols[['symbol']]
} else {
reps <- " "
}
mgsub(gsub('<[^>]+>', ' ', x), html_symbols[['html']],reps)
}
html_symbols <- data.frame(
html = c("©", "®", "™", "“",
"”", "‘", "’", "•", "·", "⋅",
"–", "—", "¢", "£", "€", "≠",
"½", "¼", "¾", "°", "←", "→",
"…", " ", "<", ">", "&", """, "'",
"¥"
),
symbol = c("(c)", "(r)", "tm", "\"", "\"", "'",
"'", "-", "-", "[]", "-", "-", "cents", "pounds", "euro", "!=",
"half", "quarter", "three fourths", "degrees", "<-", "->", "...",
" ", "<", ">", "&", '"', "'", "yen"
),
stringsAsFactors = FALSE
)
## clipr::write_clip(textclean::glue("#' {html} \\tab {symb} \\cr\n", html = html_table[[1]], symb = html_table[[2]]))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.