support for zoom, search, and notes reveal.js plugins
diff --git a/R/revealjs_presentation.R b/R/revealjs_presentation.R
index e970326..3778568 100644
--- a/R/revealjs_presentation.R
+++ b/R/revealjs_presentation.R
@@ -21,6 +21,9 @@
#' @param reveal_options Additional options to specify for reveal.js (see
#' \href{https://github.com/hakimel/reveal.js#configuration}{https://github.com/hakimel/reveal.js#configuration}
#' for details).
+#' @param reveal_plugins Reveal plugins to include. Available plugins include "notes",
+#' "search", and "zoom". Note that \code{self_contained} must be set to
+#' \code{FALSE} in order to use Reveal plugins.
#' @param template Pandoc template to use for rendering. Pass "default" to use
#' the rmarkdown package default template; pass \code{NULL} to use pandoc's
#' built-in template; pass a path to use a custom template that you've
@@ -69,6 +72,7 @@
transition = "default",
background_transition = "default",
reveal_options = NULL,
+ reveal_plugins = NULL,
highlight = "default",
mathjax = "default",
template = "default",
@@ -142,6 +146,26 @@
}
}
+ # reveal plugins
+ if (is.character(reveal_plugins)) {
+
+ # validate that we need to use self_contained for plugins
+ if (self_contained)
+ stop("Using reveal_plugins requires self_contained: false")
+
+ # validate specified plugins are supported
+ supported_plugins <- c("notes", "search", "zoom")
+ invalid_plugins <- setdiff(reveal_plugins, supported_plugins)
+ if (length(invalid_plugins) > 0)
+ stop("The following plugin(s) are not supported: ",
+ paste(invalid_plugins, collapse = ", "), call. = FALSE)
+
+ # add plugins
+ sapply(reveal_plugins, function(plugin) {
+ args <<- c(args, pandoc_variable_arg(paste0("plugin-", plugin), "1"))
+ })
+ }
+
# content includes
args <- c(args, includes_to_pandoc_args(includes))
diff --git a/README.Rmd b/README.Rmd
index da4e86a..ea976f9 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -299,6 +299,26 @@
lib_dir: libs
---
+## Reveal.js Plugins
+
+You can enable various reveal.js plugins using the `reveal_plugins` option. Plugins currently supported include:
+
+| Plugin | Description |
+|----------------------------|---------------------------------------------|
+| [notes](https://github.com/hakimel/reveal.js/#speaker-notes) | Present per-slide notes in a separate browser window. |
+| [zoom](http://lab.hakim.se/zoom-js/) | Zoom in and out of selected content with Alt+Click. |
+| [search](https://github.com/hakimel/reveal.js/blob/master/plugin/search/search.js) | Find a text string anywhere in the slides and show the next occurrence to the user. |
+
+Note that the use of plugins requires that the `self_contained` option be set to false. For example, this presentation includes both the "notes" and "search" plugins:
+
+ ---
+ title: "Habits"
+ output:
+ revealjs::revealjs_presentation:
+ self_contained: false
+ reveal_plugins: ["notes", "search"]
+ ---
+
## Advanced Customization
### Includes
diff --git a/README.md b/README.md
index 163fd23..69ef645 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@
- [Figure Options](#figure-options)
- [MathJax Equations](#mathjax-equations)
- [Document Dependencies](#document-dependencies)
+- [Reveal.js Plugins](#reveal.js-plugins)
- [Advanced Customization](#advanced-customization)
- [Shared Options](#shared-options)
@@ -306,6 +307,48 @@
lib_dir: libs
---
+Reveal.js Plugins
+-----------------
+
+You can enable various reveal.js plugins using the `reveal_plugins` option. Plugins currently supported include:
+
+<table>
+<colgroup>
+<col width="38%" />
+<col width="61%" />
+</colgroup>
+<thead>
+<tr class="header">
+<th>Plugin</th>
+<th>Description</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td><a href="https://github.com/hakimel/reveal.js/#speaker-notes">notes</a></td>
+<td>Present per-slide notes in a separate browser window.</td>
+</tr>
+<tr class="even">
+<td><a href="http://lab.hakim.se/zoom-js/">zoom</a></td>
+<td>Zoom in and out of selected content with Alt+Click</td>
+</tr>
+<tr class="odd">
+<td><a href="https://github.com/hakimel/reveal.js/blob/master/plugin/search/search.js">search</a></td>
+<td>Find a text string anywhere in the slides and show the next occurrence to the user.</td>
+</tr>
+</tbody>
+</table>
+
+Note that the use of plugins requires that the `self_contained` option be set to false. For example, this presentation includes both the "notes" and "search" plugins:
+
+ ---
+ title: "Habits"
+ output:
+ revealjs::revealjs_presentation:
+ self_contained: false
+ reveal_plugins: ["notes", "search"]
+ ---
+
Advanced Customization
----------------------
diff --git a/examples/simple.Rmd b/examples/simple.Rmd
index 8a8b485..f868d42 100644
--- a/examples/simple.Rmd
+++ b/examples/simple.Rmd
@@ -2,7 +2,8 @@
title: "Untitled"
output:
revealjs::revealjs_presentation:
- self_contained: true
+ self_contained: false
+ reveal_plugins: ["search", "zoom", "notes"]
---
```{r setup, include=FALSE}
@@ -21,6 +22,10 @@
- Bullet 2
- Bullet 3
+<aside class="notes">
+Here are some notes.
+</aside>
+
## Slide with R Output
```{r cars, echo = TRUE}
diff --git a/inst/NEWS b/inst/NEWS
index 9c5ff24..8f2c072 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -5,6 +5,8 @@
- Respect slide_level option
+- Support for zoom, search, and notes reveal.js plugins
+
Version 0.6
-----------------------------------------------------------------------
@@ -16,4 +18,4 @@
Version 0.5
-----------------------------------------------------------------------
-- Initial relase to CRAN
\ No newline at end of file
+- Initial relase to CRAN
diff --git a/inst/rmarkdown/templates/revealjs_presentation/resources/default.html b/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
index ef9c50e..49bd060 100644
--- a/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
+++ b/inst/rmarkdown/templates/revealjs_presentation/resources/default.html
@@ -284,7 +284,17 @@
$endif$
// Optional reveal.js plugins
- dependencies: []
+ dependencies: [
+$if(plugin-notes)$
+ { src: '$revealjs-url$/plugin/notes/notes.js', async: true },
+$endif$
+$if(plugin-search)$
+ { src: '$revealjs-url$/plugin/search/search.js', async: true },
+$endif$
+$if(plugin-zoom)$
+ { src: '$revealjs-url$/plugin/zoom-js/zoom.js', async: true },
+$endif$
+ ]
});
</script>
$if(mathjax-url)$
diff --git a/man/revealjs_presentation.Rd b/man/revealjs_presentation.Rd
index 2120856..d29c7b1 100644
--- a/man/revealjs_presentation.Rd
+++ b/man/revealjs_presentation.Rd
@@ -8,8 +8,8 @@
slide_level = 2, fig_width = 8, fig_height = 6, fig_retina = if
(!fig_caption) 2, fig_caption = FALSE, smart = TRUE,
self_contained = TRUE, theme = "simple", transition = "default",
- background_transition = "default", history = TRUE,
- reveal_options = NULL, highlight = "default", mathjax = "default",
+ background_transition = "default", reveal_options = NULL,
+ reveal_plugins = NULL, highlight = "default", mathjax = "default",
template = "default", css = NULL, includes = NULL, keep_md = FALSE,
lib_dir = NULL, pandoc_args = NULL, ...)
}
@@ -31,12 +31,11 @@
\item{fig_height}{Default width (in inches) for figures}
-\item{fig_retina}{Scaling to perform for retina displays (defaults to 2 when
-\code{fig_caption} is \code{FALSE}, which currently works for all widely
-used retina displays). Set to \code{NULL} to prevent retina scaling. Note
-that this will always be \code{NULL} when \code{keep_md} is specified (this
-is because \code{fig_retina} relies on outputting HTML directly into the
-markdown document).}
+\item{fig_retina}{Scaling to perform for retina displays (defaults to 2, which
+currently works for all widely used retina displays). Set to \code{NULL} to
+prevent retina scaling. Note that this will always be \code{NULL} when
+\code{keep_md} is specified (this is because \code{fig_retina} relies on
+outputting HTML directly into the markdown document).}
\item{fig_caption}{\code{TRUE} to render figures with captions}
@@ -59,12 +58,14 @@
\item{background_transition}{Slide background-transition ("default", "none",
"fade", "slide", "convex", "concave" or "zoom")}
-\item{history}{\code{TRUE} to push each slide change to the browser history.}
-
\item{reveal_options}{Additional options to specify for reveal.js (see
\href{https://github.com/hakimel/reveal.js#configuration}{https://github.com/hakimel/reveal.js#configuration}
for details).}
+\item{reveal_plugins}{Reveal plugins to include. Available plugins include "notes",
+"search", and "zoom". Note that \code{self_contained} must be set to
+\code{FALSE} in order to use Reveal plugins.}
+
\item{highlight}{Syntax highlighting style. Supported styles include
"default", "tango", "pygments", "kate", "monochrome", "espresso",
"zenburn", and "haddock". Pass \code{NULL} to prevent syntax highlighting.}