ソースを参照

Remove stringr dependency

tags/v0.3.0
コミット
a1f275a638
6個のファイルの変更11行の追加12行の削除
  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 ファイルの表示

@@ -19,7 +19,6 @@ Imports:
colorspace,
glue,
purrr,
stringr,
tibble,
utils,
whisker

+ 3
- 3
R/coolors.R ファイルの表示

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

@@ -18,8 +18,8 @@ xaringan_coolors_accent <- function(coolors_url, order = "12345", ...) {
}

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("#", .))
if (length(colors) == 1) colors[[1]]
else colors

+ 1
- 1
R/style_xaringan.R ファイルの表示

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

+ 4
- 4
R/utils.R ファイルの表示

@@ -104,7 +104,7 @@ google_font <- function(family, ..., languages = NULL) {
weights = weights,
languages = languages,
url = paste0(
base, stringr::str_replace_all(family, " ", "+"),
base, gsub(" ", "+", family),
if (!is.null(weights)) paste0(":", weights),
if (!is.null(languages)) paste0("&subset=", languages)
)
@@ -136,9 +136,9 @@ print.google_font <- 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], "'")
paste(x, collapse = ", ")
}

+ 2
- 2
inst/scripts/generate_theme_functions.R ファイルの表示

@@ -20,7 +20,7 @@ setup_theme_function <- function(
glue::glue_data(
tv,
"#' @param {variable} {description}. ",
"Defaults to {stringr::str_replace_all(default, '[{{}}]', '`')}. ",
"Defaults to {gsub('[{{}}]', '`', default)}. ",
"{element_description(element)}")
),
"#' @template extra_css",
@@ -31,7 +31,7 @@ setup_theme_function <- function(
as.character(
glue::glue_data(
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_fonts = NULL,",

+ 1
- 1
inst/scripts/style_xaringan_body.R ファイルの表示

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

読み込み中…
キャンセル
保存