1919# ' @param transition Speed of slide transitions. This can be "default",
2020# ' "slower", "faster", or a numeric value with a number of seconds (e.g. 0.5).
2121# ' @param analytics A Google analytics property ID.
22- # '@param smart Produce typographically correct output, converting straight
23- # ' quotes to curly quotes, \code{---} to em-dashes, \code{--} to en-dashes, and
24- # ' \code{...} to ellipses.
22+ # ' @param smart Produce typographically correct output, converting straight
23+ # ' quotes to curly quotes, \code{---} to em-dashes, \code{--} to en-dashes, and
24+ # ' \code{...} to ellipses.
25+ # ' @param theme a list of theming arguments (currently `bg`, `fg`, `primary`,
26+ # ' `success`, `warning`, `danger`, `base_font`, and `code_font` are supported,
27+ # ' see [bslib::bs_theme()] for more about these options)
2528# ' @return R Markdown output format to pass to \code{\link{render}}.
2629# ' @details
2730# ' See the \href{https://bookdown.org/yihui/rmarkdown/ioslides-presentation.html}{
@@ -248,6 +251,7 @@ ioslides_presentation <- function(number_sections = FALSE,
248251 md_extensions = NULL ,
249252 pandoc_args = NULL ,
250253 extra_dependencies = NULL ,
254+ theme = NULL ,
251255 ... ) {
252256
253257 # base pandoc options for all output
@@ -291,7 +295,7 @@ ioslides_presentation <- function(number_sections = FALSE,
291295
292296 # html dependency for ioslides
293297 extra_dependencies <- append(extra_dependencies ,
294- list ( html_dependency_ioslides() ))
298+ html_dependency_ioslides(theme ))
295299
296300 # analytics
297301 if (! is.null(analytics ))
@@ -453,14 +457,16 @@ ioslides_presentation <- function(number_sections = FALSE,
453457 mathjax = mathjax ,
454458 pandoc_args = pandoc_args ,
455459 extra_dependencies = extra_dependencies ,
456- bootstrap_compatible = TRUE , ... ))
460+ bootstrap_compatible = TRUE , theme = theme , ... ))
457461}
458462
459463
460- html_dependency_ioslides <- function () {
461- htmlDependency(
462- name = " ioslides" ,
463- version = " 13.5.1" ,
464+ html_dependency_ioslides <- function (theme ) {
465+ name <- " ioslides"
466+ version <- " 13.5.1"
467+ js <- htmlDependency(
468+ name = paste0(name , " -js" ),
469+ version = version ,
464470 src = pkg_file(" rmd/ioslides/ioslides-13.5.1" ),
465471 script = c(
466472 " js/modernizr.custom.45394.js" ,
@@ -470,10 +476,46 @@ html_dependency_ioslides <- function() {
470476 " js/hammer.js" ,
471477 " js/slide-controller.js" ,
472478 " js/slide-deck.js"
473- ),
474- stylesheet = c(
475- " fonts/fonts.css" ,
476- " theme/css/default.css" ,
477- " theme/css/phone.css" )
478479 )
480+ )
481+
482+ if (is.null(theme )) {
483+ css <- htmlDependency(
484+ name = paste0(name , " -css" ),
485+ version = version ,
486+ src = pkg_file(" rmd/ioslides/ioslides-13.5.1" ),
487+ stylesheet = c(
488+ " fonts/fonts.css" ,
489+ " theme/css/default.css" ,
490+ " theme/css/phone.css"
491+ )
492+ )
493+ return (list (js , css ))
494+ }
495+
496+ theme <- as_bs_theme(theme )
497+ if (! is_bs_theme(theme )) {
498+ stop(" `theme` must be a `bslib::bs_theme()` object or a list of arguments to it" )
499+ }
500+ if (" 3" %in% theme_version(theme )) {
501+ stop(" `ioslides_presentation()` is not compatible with Bootstrap 3 (use version = 4 or higher)" )
502+ }
503+ io_file <- function (... ) {
504+ sass :: sass_file(pkg_file(" rmd/ioslides/ioslides-13.5.1" , ... ))
505+ }
506+ css <- bslib :: bs_dependency(
507+ input = sass :: sass_layer(
508+ rules = list (
509+ io_file(" fonts/fonts.css" ),
510+ io_file(" theme/css/default.scss" ),
511+ io_file(" theme/css/phone.css" )
512+ ),
513+ file_attachments = c(fonts = pkg_file(" rmd/ioslides/ioslides-13.5.1/fonts" ))
514+ ),
515+ theme = theme ,
516+ name = paste0(name , " -css" ),
517+ version = version ,
518+ cache_key_extra = packageVersion(" rmarkdown" )
519+ )
520+ list (js , css )
479521}
0 commit comments