Przeglądaj źródła

requires_xaringanthemer_env() doesn't have to check for theme elements

tags/v0.3.0
Garrick Aden-Buie 6 lat temu
rodzic
commit
8392cf653f
1 zmienionych plików z 9 dodań i 3 usunięć
  1. +9
    -3
      R/ggplot2.R

+ 9
- 3
R/ggplot2.R Wyświetl plik

@@ -373,7 +373,7 @@ theme_xaringan_set_defaults <- function(
#' @export
theme_xaringan_restore_defaults <- function() {
requires_package("ggplot2")
requires_xaringanthemer_env()
requires_xaringanthemer_env(try_css = FALSE, requires_theme = FALSE)

if (is.null(xaringanthemer_env$old_ggplot_defaults)) {
return(invisible())
@@ -726,9 +726,15 @@ requires_package <- function(pkg = "ggplot2", fn = "", required = TRUE) {
invisible(TRUE)
}

requires_xaringanthemer_env <- function(css_file = NULL, try_css = TRUE) {
requires_xaringanthemer_env <- function(
css_file = NULL,
try_css = TRUE,
requires_theme = TRUE
) {
reload <- !is.null(css_file) && isTRUE(try_css)
if (reload || !exists("xaringanthemer_env") || is.null(xaringanthemer_env$header_color)) {
pkg_env_exists <- exists("xaringanthemer_env")
missing_theme <- requires_theme && pkg_env_exists && is.null(xaringanthemer_env$header_color)
if (reload || !pkg_env_exists || missing_theme) {
if (try_css) {
css_vars <- read_css_vars(css_file)
for (css_var in names(css_vars)) {

Ładowanie…
Anuluj
Zapisz