You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
869 B

#' Slugify a string
#'
#' @param x string
#' @param replacement replace spaces with replacement character, defaults to `-`
#' @param remove remove characters that match this regex, defaults to `NULL` (no deleting)
#' @param lower convert to lower case, defaults to `TRUE`
#' @param strict strip special characters except replacement, defaults to `TRUE`
#' @export
#' @examples
#' slugify("R is great!")
slugify <- function(x, replacement = "-", remove = NULL, lower = TRUE, strict = TRUE) {
if (!is.null(remove)) {
.pkgenv$ctx$call(
"slugify", x[1],
list(
replacement = "-",
remove = remove[1],
lower = lower[1],
strict = strict[1]
)
)
} else {
.pkgenv$ctx$call(
"slugify", x[1],
list(
replacement = "-",
lower = lower[1],
strict = strict[1]
)
)
}
}