JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 1 | #' Convert to a reveal.js presentation |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 2 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 3 | #' Format for converting from R Markdown to a reveal.js presentation. |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 4 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 5 | #' @inheritParams rmarkdown::beamer_presentation |
| 6 | #' @inheritParams rmarkdown::pdf_document |
| 7 | #' @inheritParams rmarkdown::html_document |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 8 | #' |
Christophe Dervieux | 21239cf | 2021-09-15 15:34:01 +0200 | [diff] [blame] | 9 | #' @param smart Produce typographically correct output, converting straight |
| 10 | #' quotes to curly quotes, \code{---} to em-dashes, \code{--} to en-dashes, and |
| 11 | #' \code{...} to ellipses. |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 12 | #' @param center \code{TRUE} to vertically center content on slides |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 13 | #' @param slide_level Level of heading to denote individual slides. If |
| 14 | #' \code{slide_level} is 2 (the default), a two-dimensional layout will be |
| 15 | #' produced, with level 1 headers building horizontally and level 2 headers |
| 16 | #' building vertically. It is not recommended that you use deeper nesting of |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 17 | #' section levels with reveal.js. |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 18 | #' @param theme Visual theme ("simple", "sky", "beige", "serif", "solarized", |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 19 | #' "blood", "moon", "night", "black", "league" or "white"). |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 20 | #' @param transition Slide transition ("default", "none", "fade", "slide", |
junkka | d4b3a16 | 2015-03-16 07:49:11 +0100 | [diff] [blame] | 21 | #' "convex", "concave" or "zoom") |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 22 | #' @param background_transition Slide background-transition ("default", "none", |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 23 | #' "fade", "slide", "convex", "concave" or "zoom") |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 24 | #' @param reveal_options Additional options to specify for reveal.js (see |
Atsushi Yasumoto | 66c5585 | 2020-08-10 21:50:04 +0900 | [diff] [blame] | 25 | #' \href{https://revealjs.com/config/}{https://revealjs.com/config/} |
JJ Allaire | 35c0b49 | 2017-02-10 09:30:24 -0500 | [diff] [blame] | 26 | #' for details). |
| 27 | #' @param reveal_plugins Reveal plugins to include. Available plugins include |
JJ Allaire | 064552c | 2017-02-10 10:28:41 -0500 | [diff] [blame] | 28 | #' "notes", "search", "zoom", "chalkboard", and "menu". Note that |
JJ Allaire | 35c0b49 | 2017-02-10 09:30:24 -0500 | [diff] [blame] | 29 | #' \code{self_contained} must be set to \code{FALSE} in order to use Reveal |
| 30 | #' plugins. |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 31 | #' @param template Pandoc template to use for rendering. Pass "default" to use |
| 32 | #' the rmarkdown package default template; pass \code{NULL} to use pandoc's |
| 33 | #' built-in template; pass a path to use a custom template that you've |
| 34 | #' created. Note that if you don't use the "default" template then some |
| 35 | #' features of \code{revealjs_presentation} won't be available (see the |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 36 | #' Templates section below for more details). |
JJ Allaire | 35c0b49 | 2017-02-10 09:30:24 -0500 | [diff] [blame] | 37 | #' @param extra_dependencies Additional function arguments to pass to the base R |
| 38 | #' Markdown HTML output formatter [rmarkdown::html_document_base()]. |
JJ Allaire | 8d1c2f4 | 2016-01-30 14:56:45 -0500 | [diff] [blame] | 39 | #' @param ... Ignored |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 40 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 41 | #' @return R Markdown output format to pass to \code{\link{render}} |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 42 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 43 | #' @details |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 44 | #' |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 45 | #' In reveal.js presentations you can use level 1 or level 2 headers for slides. |
| 46 | #' If you use a mix of level 1 and level 2 headers then a two-dimensional layout |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 47 | #' will be produced, with level 1 headers building horizontally and level 2 |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 48 | #' headers building vertically. |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 49 | #' |
| 50 | #' For additional documentation on using revealjs presentations see |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 51 | #' \href{https://github.com/rstudio/revealjs}{https://github.com/rstudio/revealjs}. |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 52 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 53 | #' @examples |
| 54 | #' \dontrun{ |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 55 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 56 | #' library(rmarkdown) |
| 57 | #' library(revealjs) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 58 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 59 | #' # simple invocation |
| 60 | #' render("pres.Rmd", revealjs_presentation()) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 61 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 62 | #' # specify an option for incremental rendering |
| 63 | #' render("pres.Rmd", revealjs_presentation(incremental = TRUE)) |
| 64 | #' } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 65 | #' |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 66 | #' @export |
| 67 | revealjs_presentation <- function(incremental = FALSE, |
| 68 | center = FALSE, |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 69 | slide_level = 2, |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 70 | fig_width = 8, |
| 71 | fig_height = 6, |
| 72 | fig_retina = if (!fig_caption) 2, |
| 73 | fig_caption = FALSE, |
| 74 | smart = TRUE, |
| 75 | self_contained = TRUE, |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 76 | theme = "simple", |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 77 | transition = "default", |
junkka | d55cff0 | 2015-03-15 22:27:03 +0100 | [diff] [blame] | 78 | background_transition = "default", |
JJ Allaire | 37f45b7 | 2016-01-30 18:17:45 -0500 | [diff] [blame] | 79 | reveal_options = NULL, |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 80 | reveal_plugins = NULL, |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 81 | highlight = "default", |
| 82 | mathjax = "default", |
| 83 | template = "default", |
JJ Allaire | fad5523 | 2015-10-19 07:47:26 -0400 | [diff] [blame] | 84 | css = NULL, |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 85 | includes = NULL, |
| 86 | keep_md = FALSE, |
| 87 | lib_dir = NULL, |
| 88 | pandoc_args = NULL, |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 89 | extra_dependencies = NULL, |
Atsushi Yasumoto | 0bf4444 | 2020-02-15 00:08:30 +0900 | [diff] [blame] | 90 | md_extensions = NULL, |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 91 | ...) { |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 92 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 93 | # base pandoc options for all reveal.js output |
| 94 | args <- c() |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 95 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 96 | # template path and assets |
JJ Allaire | a8c414b | 2016-01-30 14:36:53 -0500 | [diff] [blame] | 97 | if (identical(template, "default")) { |
christophe dervieux | 92fa469 | 2021-09-21 16:15:17 +0200 | [diff] [blame] | 98 | default_template <- reveal_resources("default.html") |
JJ Allaire | a8c414b | 2016-01-30 14:36:53 -0500 | [diff] [blame] | 99 | args <- c(args, "--template", pandoc_path_arg(default_template)) |
| 100 | } else if (!is.null(template)) { |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 101 | args <- c(args, "--template", pandoc_path_arg(template)) |
JJ Allaire | a8c414b | 2016-01-30 14:36:53 -0500 | [diff] [blame] | 102 | } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 103 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 104 | # incremental |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 105 | if (incremental) args <- c(args, "--incremental") |
| 106 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 107 | # centering |
JJ Allaire | 40fec33 | 2016-01-30 16:54:51 -0500 | [diff] [blame] | 108 | args <- c(args, pandoc_variable_arg("center", jsbool(center))) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 109 | |
JJ Allaire | 4c17805 | 2016-01-30 19:35:39 -0500 | [diff] [blame] | 110 | # slide level |
JJ Allaire | c58a6c4 | 2016-03-30 23:45:21 -0400 | [diff] [blame] | 111 | args <- c(args, "--slide-level", as.character(slide_level)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 112 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 113 | # theme |
| 114 | theme <- match.arg(theme, revealjs_themes()) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 115 | if (identical(theme, "default")) { |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 116 | theme <- "simple" |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 117 | } else if (identical(theme, "dark")) { |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 118 | theme <- "black" |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 119 | } |
| 120 | if (theme %in% c("blood", "moon", "night", "black")) { |
christophe dervieux | 062940d | 2021-09-21 16:26:14 +0200 | [diff] [blame] | 121 | args <- c(args, pandoc_variable_arg("theme-dark")) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 122 | } |
christophe dervieux | 1ebd513 | 2021-09-22 08:47:21 +0200 | [diff] [blame] | 123 | args <- c(args, pandoc_variable_arg("theme", theme)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 124 | |
| 125 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 126 | # transition |
| 127 | transition <- match.arg(transition, revealjs_transitions()) |
christophe dervieux | 062940d | 2021-09-21 16:26:14 +0200 | [diff] [blame] | 128 | args <- c(args, pandoc_variable_arg("transition", transition)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 129 | |
junkka | d55cff0 | 2015-03-15 22:27:03 +0100 | [diff] [blame] | 130 | # background_transition |
| 131 | background_transition <- match.arg(background_transition, revealjs_transitions()) |
christophe dervieux | 062940d | 2021-09-21 16:26:14 +0200 | [diff] [blame] | 132 | args <- c(args, pandoc_variable_arg("backgroundTransition", background_transition)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 133 | |
JJ Allaire | 4ae486f | 2016-03-23 06:08:42 -0400 | [diff] [blame] | 134 | # use history |
| 135 | args <- c(args, pandoc_variable_arg("history", "true")) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 136 | |
JJ Allaire | 37f45b7 | 2016-01-30 18:17:45 -0500 | [diff] [blame] | 137 | # additional reveal options |
| 138 | if (is.list(reveal_options)) { |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 139 | for (option in names(reveal_options)) { |
JJ Allaire | 064552c | 2017-02-10 10:28:41 -0500 | [diff] [blame] | 140 | # special handling for nested options |
| 141 | if (option %in% c("chalkboard", "menu")) { |
| 142 | nested_options <- reveal_options[[option]] |
| 143 | for (nested_option in names(nested_options)) { |
Christophe Dervieux | 2f01dc9 | 2021-09-22 09:37:18 +0200 | [diff] [blame] | 144 | args <- c(args, |
| 145 | process_reveal_option( |
| 146 | paste0(option, "-", nested_option), |
| 147 | nested_options[[nested_option]] |
| 148 | ) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 149 | ) |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 150 | } |
Christophe Dervieux | 2f01dc9 | 2021-09-22 09:37:18 +0200 | [diff] [blame] | 151 | } else { |
| 152 | # standard top-level options |
| 153 | args <- c(args, process_reveal_option(option, reveal_options[[option]])) |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 154 | } |
JJ Allaire | 37f45b7 | 2016-01-30 18:17:45 -0500 | [diff] [blame] | 155 | } |
| 156 | } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 157 | |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 158 | # reveal plugins |
| 159 | if (is.character(reveal_plugins)) { |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 160 | |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 161 | # validate that we need to use self_contained for plugins |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 162 | if (self_contained) { |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 163 | stop("Using reveal_plugins requires self_contained: false") |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 164 | } |
| 165 | |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 166 | # validate specified plugins are supported |
JJ Allaire | 064552c | 2017-02-10 10:28:41 -0500 | [diff] [blame] | 167 | supported_plugins <- c("notes", "search", "zoom", "chalkboard", "menu") |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 168 | invalid_plugins <- setdiff(reveal_plugins, supported_plugins) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 169 | if (length(invalid_plugins) > 0) { |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 170 | stop("The following plugin(s) are not supported: ", |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 171 | paste(invalid_plugins, collapse = ", "), |
| 172 | call. = FALSE |
| 173 | ) |
| 174 | } |
| 175 | |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 176 | # add plugins |
| 177 | sapply(reveal_plugins, function(plugin) { |
| 178 | args <<- c(args, pandoc_variable_arg(paste0("plugin-", plugin), "1")) |
JJ Allaire | 064552c | 2017-02-10 10:28:41 -0500 | [diff] [blame] | 179 | if (plugin %in% c("chalkboard", "menu")) { |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 180 | extra_dependencies <<- append( |
| 181 | extra_dependencies, |
| 182 | list(rmarkdown::html_dependency_font_awesome()) |
| 183 | ) |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 184 | } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 185 | }) |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 186 | } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 187 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 188 | # content includes |
| 189 | args <- c(args, includes_to_pandoc_args(includes)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 190 | |
JJ Allaire | fad5523 | 2015-10-19 07:47:26 -0400 | [diff] [blame] | 191 | # additional css |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 192 | for (css_file in css) { |
JJ Allaire | fad5523 | 2015-10-19 07:47:26 -0400 | [diff] [blame] | 193 | args <- c(args, "--css", pandoc_path_arg(css_file)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 194 | } |
| 195 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 196 | # pre-processor for arguments that may depend on the name of the |
| 197 | # the input file (e.g. ones that need to copy supporting files) |
| 198 | pre_processor <- function(metadata, input_file, runtime, knit_meta, files_dir, |
| 199 | output_dir) { |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 200 | |
JJ Allaire | e60feb2 | 2016-01-30 18:28:47 -0500 | [diff] [blame] | 201 | # we don't work with runtime shiny |
| 202 | if (identical(runtime, "shiny")) { |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 203 | stop("revealjs_presentation is not compatible with runtime 'shiny'", |
| 204 | call. = FALSE |
| 205 | ) |
JJ Allaire | e60feb2 | 2016-01-30 18:28:47 -0500 | [diff] [blame] | 206 | } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 207 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 208 | # use files_dir as lib_dir if not explicitly specified |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 209 | if (is.null(lib_dir)) { |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 210 | lib_dir <- files_dir |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 211 | } |
| 212 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 213 | # extra args |
| 214 | args <- c() |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 215 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 216 | # reveal.js |
JJ Allaire | 01541a2 | 2017-02-10 10:32:28 -0500 | [diff] [blame] | 217 | revealjs_path <- system.file("reveal.js-3.3.0.1", package = "revealjs") |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 218 | if (!self_contained || identical(.Platform$OS.type, "windows")) { |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 219 | revealjs_path <- relative_to( |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 220 | output_dir, render_supporting_files(revealjs_path, lib_dir) |
| 221 | ) |
| 222 | } else { |
JJ Allaire | eea3bca | 2016-07-13 12:42:01 -0400 | [diff] [blame] | 223 | revealjs_path <- pandoc_path_arg(revealjs_path) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 224 | } |
christophe dervieux | 062940d | 2021-09-21 16:26:14 +0200 | [diff] [blame] | 225 | args <- c(args, pandoc_variable_arg("revealjs-url", revealjs_path)) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 226 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 227 | # highlight |
| 228 | args <- c(args, pandoc_highlight_args(highlight, default = "pygments")) |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 229 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 230 | # return additional args |
| 231 | args |
| 232 | } |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 233 | |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 234 | # return format |
| 235 | output_format( |
| 236 | knitr = knitr_options_html(fig_width, fig_height, fig_retina, keep_md), |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 237 | pandoc = pandoc_options( |
| 238 | to = "revealjs", |
christophe dervieux | ad3a575 | 2021-09-23 10:24:09 +0200 | [diff] [blame^] | 239 | from = from_rmarkdown(fig_caption, md_extensions), |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 240 | args = args |
| 241 | ), |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 242 | keep_md = keep_md, |
| 243 | clean_supporting = self_contained, |
| 244 | pre_processor = pre_processor, |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 245 | base_format = html_document_base( |
| 246 | smart = smart, lib_dir = lib_dir, |
| 247 | self_contained = self_contained, |
| 248 | mathjax = mathjax, |
| 249 | pandoc_args = pandoc_args, |
| 250 | extra_dependencies = extra_dependencies, |
| 251 | ... |
| 252 | ) |
| 253 | ) |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | revealjs_themes <- function() { |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 257 | c( |
| 258 | "default", |
JJ Allaire | 6da1bb6 | 2016-01-30 14:28:39 -0500 | [diff] [blame] | 259 | "dark", |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 260 | "simple", |
| 261 | "sky", |
| 262 | "beige", |
| 263 | "serif", |
| 264 | "solarized", |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 265 | "blood", |
| 266 | "moon", |
junkka | 77fbf08 | 2015-03-15 22:25:47 +0100 | [diff] [blame] | 267 | "night", |
| 268 | "black", |
| 269 | "league", |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 270 | "white" |
| 271 | ) |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | |
| 275 | revealjs_transitions <- function() { |
junkka | 77fbf08 | 2015-03-15 22:25:47 +0100 | [diff] [blame] | 276 | c( |
| 277 | "default", |
| 278 | "none", |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 279 | "fade", |
junkka | 77fbf08 | 2015-03-15 22:25:47 +0100 | [diff] [blame] | 280 | "slide", |
| 281 | "convex", |
| 282 | "concave", |
| 283 | "zoom" |
christophe dervieux | f9bae67 | 2021-09-21 16:20:24 +0200 | [diff] [blame] | 284 | ) |
JJ Allaire | 2ec4024 | 2014-09-15 09:18:39 -0400 | [diff] [blame] | 285 | } |