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