Explorar el Código

Remove stringr dependency

tags/v0.3.0
Garrick Aden-Buie hace 7 años
padre
commit
a1f275a638
Se han modificado 6 ficheros con 11 adiciones y 12 borrados
  1. +0
    -1
      DESCRIPTION
  2. +3
    -3
      R/coolors.R
  3. +1
    -1
      R/style_xaringan.R
  4. +4
    -4
      R/utils.R
  5. +2
    -2
      inst/scripts/generate_theme_functions.R
  6. +1
    -1
      inst/scripts/style_xaringan_body.R

+ 0
- 1
DESCRIPTION Ver fichero

colorspace, colorspace,
glue, glue,
purrr, purrr,
stringr,
tibble, tibble,
utils, utils,
whisker whisker

+ 3
- 3
R/coolors.R Ver fichero

xaringan_coolors_accent <- function(coolors_url, order = "12345", ...) { xaringan_coolors_accent <- function(coolors_url, order = "12345", ...) {
stopifnot(length(coolors_url) == 1) stopifnot(length(coolors_url) == 1)
colors <- coolors2colors(coolors_url) colors <- coolors2colors(coolors_url)
order <- stringr::str_split(order, "")[1]
order <- strplit(order, "")[1]
order <- unlist(purrr::map(order, as.integer)) order <- unlist(purrr::map(order, as.integer))
colors <- colors[order] colors <- colors[order]


} }


coolors2colors <- function(url) { coolors2colors <- function(url) {
colors <- stringr::str_extract(url, "([a-f0-9]{6}-?){5}")
colors <- stringr::str_split(colors, "-")
colors <- sub(".*(([a-f0-9]{6}-?){5}).*", "\\1", url)
colors <- strsplit(colors, "-")
colors <- purrr::map(colors, ~ paste0("#", .)) colors <- purrr::map(colors, ~ paste0("#", .))
if (length(colors) == 1) colors[[1]] if (length(colors) == 1) colors[[1]]
else colors else colors

+ 1
- 1
R/style_xaringan.R Ver fichero

if (!inherits(gf, "google_font")) stop( if (!inherits(gf, "google_font")) stop(
"`", var, "` must be set using `google_font()`." "`", var, "` must be set using `google_font()`."
) )
group <- stringr::str_split(var, "_")[[1]][1]
group <- strsplit(var, "_")[[1]][1]
if (group == "text") { if (group == "text") {
text_font_family <- gf$family text_font_family <- gf$family
text_font_weight <- gf$weights %||% "normal" text_font_weight <- gf$weights %||% "normal"

+ 4
- 4
R/utils.R Ver fichero

weights = weights, weights = weights,
languages = languages, languages = languages,
url = paste0( url = paste0(
base, stringr::str_replace_all(family, " ", "+"),
base, gsub(" ", "+", family),
if (!is.null(weights)) paste0(":", weights), if (!is.null(weights)) paste0(":", weights),
if (!is.null(languages)) paste0("&subset=", languages) if (!is.null(languages)) paste0("&subset=", languages)
) )
} }


quote_elements_w_spaces <- function(x) { quote_elements_w_spaces <- function(x) {
x <- stringr::str_split(x, ", ?")[[1]]
has_space <- stringr::str_detect(x, "\\w \\w")
not_quoted <- stringr::str_detect(x, "^\\w.+\\w$")
x <- strsplit(x, ", ?")[[1]]
has_space <- grepl("\\w \\w", x)
not_quoted <- grepl("^\\w.+\\w$", x)
x[has_space & not_quoted] <- paste0("'", x[has_space & not_quoted], "'") x[has_space & not_quoted] <- paste0("'", x[has_space & not_quoted], "'")
paste(x, collapse = ", ") paste(x, collapse = ", ")
} }

+ 2
- 2
inst/scripts/generate_theme_functions.R Ver fichero

glue::glue_data( glue::glue_data(
tv, tv,
"#' @param {variable} {description}. ", "#' @param {variable} {description}. ",
"Defaults to {stringr::str_replace_all(default, '[{{}}]', '`')}. ",
"Defaults to {gsub('[{{}}]', '`', default)}. ",
"{element_description(element)}") "{element_description(element)}")
), ),
"#' @template extra_css", "#' @template extra_css",
as.character( as.character(
glue::glue_data( glue::glue_data(
tv, tv,
" {variable} = {ifelse(!stringr::str_detect(default, '^[{].+[}]$'), paste0('\"', default, '\"'), stringr::str_replace_all(default, '[{}]', ''))},")
" {variable} = {ifelse(!grepl('^[{].+[}]$', default), paste0('\"', default, '\"'), gsub('[{}]', '', default))},")
), ),
" extra_css = NULL,", " extra_css = NULL,",
" extra_fonts = NULL,", " extra_fonts = NULL,",

+ 1
- 1
inst/scripts/style_xaringan_body.R Ver fichero

if (!inherits(gf, "google_font")) stop( if (!inherits(gf, "google_font")) stop(
"`", var, "` must be set using `google_font()`." "`", var, "` must be set using `google_font()`."
) )
group <- stringr::str_split(var, "_")[[1]][1]
group <- strsplit(var, "_")[[1]][1]
if (group == "text") { if (group == "text") {
text_font_family <- gf$family text_font_family <- gf$family
text_font_weight <- gf$weights %||% "normal" text_font_weight <- gf$weights %||% "normal"

Cargando…
Cancelar
Guardar