blob: 7251cff9e71c3b0f38b89fc19542b3f8dc8f139e [file] [log] [blame]
christophe dervieux92fa4692021-09-21 16:15:17 +02001# function to lookup reveal resource
2reveal_resources <- function(...) {
3 system.file("rmarkdown/templates/revealjs_presentation/resources",
4 ...,
5 package = "revealjs")
christophe dervieux24418a82021-09-21 16:17:18 +02006}
7
8# Convert boolean from R to JS boolean
Christophe Dervieux2f01dc92021-09-22 09:37:18 +02009jsbool <- function(value) ifelse(value, "true", "false")
10
11# transfrom reveal option as pandoc variable
12process_reveal_option <- function(option, value) {
13 if (is.logical(value)) {
14 value <- jsbool(value)
15 } else if (is.character(value)) {
16 # Special handling for some chalkboard plugin options
17 # e.g: color: [ 'rgba(0,0,255,1)', 'rgba(255,255,255,0.5)' ]
18 if (grepl("chalkboard-(background|color|draw|pen)", option)) {
19 value <- sprintf("[%s]", paste(paste0("'", value, "'"), collapse = ", "))
20 }
21 # Add quotes around some config that can be several type
22 # like number or percent unit or slideNumber = true or slideNumber = 'c/t'
23 if (
24 option %in% c("slideNumber") ||
25 (option %in% c("width", "height") && grepl("%$", value))) {
26 value <- paste0("'", value, "'")
27 }
28 }
29 pandoc_variable_arg(option, value)
Christophe Dervieuxaa008e42021-09-23 16:52:37 +020030}