christophe dervieux | 92fa469 | 2021-09-21 16:15:17 +0200 | [diff] [blame] | 1 | # function to lookup reveal resource |
| 2 | reveal_resources <- function(...) { |
| 3 | system.file("rmarkdown/templates/revealjs_presentation/resources", |
| 4 | ..., |
| 5 | package = "revealjs") |
christophe dervieux | 24418a8 | 2021-09-21 16:17:18 +0200 | [diff] [blame] | 6 | } |
| 7 | |
| 8 | # Convert boolean from R to JS boolean |
Christophe Dervieux | 2f01dc9 | 2021-09-22 09:37:18 +0200 | [diff] [blame] | 9 | jsbool <- function(value) ifelse(value, "true", "false") |
| 10 | |
| 11 | # transfrom reveal option as pandoc variable |
| 12 | process_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 Dervieux | aa008e4 | 2021-09-23 16:52:37 +0200 | [diff] [blame] | 30 | } |