|
1 | 1 | #' An R Markdown output format for remark.js slides |
2 | 2 | #' |
3 | 3 | #' This output format produces an HTML file that contains the Markdown source |
4 | | -#' (knitted from R Markdown) and JavaScript code to render slides. |
5 | | -#' \code{tsukuyomi()} is an alias of \code{moon_reader()}. |
| 4 | +#' (knitted from R Markdown) and JavaScript code to render slides. `tsukuyomi()` |
| 5 | +#' is an alias of `moon_reader()`. |
6 | 6 | #' |
7 | 7 | #' Tsukuyomi is a genjutsu to trap the target in an illusion on eye contact. |
8 | 8 | #' |
9 | | -#' If you are unfamiliar with CSS, please see the |
10 | | -#' \href{https://github.com/yihui/xaringan/wiki}{xaringan wiki on Github} |
11 | | -#' providing CSS slide modification examples. |
| 9 | +#' If you are unfamiliar with CSS, please see the [xaringan wiki on |
| 10 | +#' Github](https://github.com/yihui/xaringan/wiki) providing CSS slide |
| 11 | +#' modification examples. |
12 | 12 | #' @param css A vector of CSS file paths. Two default CSS files |
13 | 13 | #' (\file{default.css} and \file{default-fonts.css}) are provided in this |
14 | | -#' package, which was borrowed from \url{https://remarkjs.com}. If the |
15 | | -#' character vector \code{css} contains a value that does not end with |
16 | | -#' \code{.css}, it is supposed to be a built-in CSS file in this package, |
17 | | -#' e.g., for \code{css = c('default', 'extra.css')}), it means |
18 | | -#' \code{default.css} in this package and a user-provided \code{extra.css}. To |
19 | | -#' find out all built-in CSS files, use \code{xaringan:::list_css()}. With |
20 | | -#' \pkg{rmarkdown} >= 2.8, Sass files (filenames ending with \file{.scss} or |
21 | | -#' \file{.sass}) can also be used, and they will be processed by the |
22 | | -#' \pkg{sass} package, which needs to be installed. |
| 14 | +#' package, which was borrowed from <https://remarkjs.com>. If the character |
| 15 | +#' vector `css` contains a value that does not end with `.css`, it is supposed |
| 16 | +#' to be a built-in CSS file in this package, e.g., for `css = c('default', |
| 17 | +#' 'extra.css')`), it means `default.css` in this package and a user-provided |
| 18 | +#' `extra.css`. To find out all built-in CSS files, use |
| 19 | +#' `xaringan:::list_css()`. With \pkg{rmarkdown} >= 2.8, Sass files (filenames |
| 20 | +#' ending with \file{.scss} or \file{.sass}) can also be used, and they will |
| 21 | +#' be processed by the \pkg{sass} package, which needs to be installed. |
23 | 22 | #' @param self_contained Whether to produce a self-contained HTML file by |
24 | 23 | #' embedding all external resources into the HTML file. See the \sQuote{Note} |
25 | 24 | #' section below. |
26 | 25 | #' @param seal Whether to generate a title slide automatically using the YAML |
27 | | -#' metadata of the R Markdown document (if \code{FALSE}, you should write the |
28 | | -#' title slide by yourself). |
29 | | -#' @param yolo Whether to insert the |
30 | | -#' \href{https://kbroman.wordpress.com/2014/08/28/the-mustache-photo/}{Mustache |
31 | | -#' Karl (TM)} randomly in the slides. \code{TRUE} means insert his picture on |
32 | | -#' one slide, and if you want him to be on multiple slides, set \code{yolo} to |
33 | | -#' a positive integer or a percentage (e.g. 0.3 means 30\% of your slides will |
34 | | -#' be the Mustache Karl). Alternatively, \code{yolo} can also be a list of the |
35 | | -#' form \code{list(times = n, img = path)}: \code{n} is the number of times to |
36 | | -#' show an image, and \code{path} is the path to an image (by default, it is |
37 | | -#' Karl). |
| 26 | +#' metadata of the R Markdown document (if `FALSE`, you should write the title |
| 27 | +#' slide by yourself). |
| 28 | +#' @param yolo Whether to insert the [Mustache Karl |
| 29 | +#' (TM)](https://kbroman.wordpress.com/2014/08/28/the-mustache-photo/) |
| 30 | +#' randomly in the slides. `TRUE` means insert his picture on one slide, and |
| 31 | +#' if you want him to be on multiple slides, set `yolo` to a positive integer |
| 32 | +#' or a percentage (e.g. 0.3 means 30\% of your slides will be the Mustache |
| 33 | +#' Karl). Alternatively, `yolo` can also be a list of the form `list(times = |
| 34 | +#' n, img = path)`: `n` is the number of times to show an image, and `path` is |
| 35 | +#' the path to an image (by default, it is Karl). |
38 | 36 | #' @param chakra A path to the remark.js library (can be either local or |
39 | 37 | #' remote). Please note that if you use the default remote latest version of |
40 | 38 | #' remark.js, your slides will not work when you do not have Internet access. |
41 | 39 | #' They might also be broken after a newer version of remark.js is released. |
42 | 40 | #' If these issues concern you, you should download remark.js locally (e.g., |
43 | | -#' via \code{\link{summon_remark}()}), and use the local version instead. |
| 41 | +#' via [summon_remark()]), and use the local version instead. |
44 | 42 | #' @param nature (Nature transformation) A list of configurations to be passed |
45 | | -#' to \code{remark.create()}, e.g. \code{list(ratio = '16:9', navigation = |
46 | | -#' list(click = TRUE))}; see |
47 | | -#' \url{https://github.com/gnab/remark/wiki/Configuration}. Besides the |
48 | | -#' options provided by remark.js, you can also set \code{autoplay} to a number |
49 | | -#' (the number of milliseconds) so the slides will be played every |
50 | | -#' \code{autoplay} milliseconds; alternatively, \code{autoplay} can be a list |
51 | | -#' of the form \code{list(interval = N, loop = TRUE)}, so the slides will go |
52 | | -#' to the next page every \code{N} milliseconds, and optionally go back to the |
53 | | -#' first page to restart the play when \code{loop = TRUE}. You can also set |
54 | | -#' \code{countdown} to a number (the number of milliseconds) to include a |
55 | | -#' countdown timer on each slide. If using \code{autoplay}, you can optionally |
56 | | -#' set \code{countdown} to \code{TRUE} to include a countdown equal to |
57 | | -#' \code{autoplay}. To alter the set of classes applied to the title slide, |
58 | | -#' you can optionally set \code{titleSlideClass} to a vector of classes; the |
59 | | -#' default is \code{c("center", "middle", "inverse")}. |
60 | | -#' @param anchor_sections,... For \code{tsukuyomi()}, arguments passed to |
61 | | -#' \code{moon_reader()}; for \code{moon_reader()}, arguments passed to |
62 | | -#' \code{rmarkdown::\link{html_document}()}. |
| 43 | +#' to `remark.create()`, e.g. `list(ratio = '16:9', navigation = list(click = |
| 44 | +#' TRUE))`; see <https://github.com/gnab/remark/wiki/Configuration>. Besides |
| 45 | +#' the options provided by remark.js, you can also set `autoplay` to a number |
| 46 | +#' (the number of milliseconds) so the slides will be played every `autoplay` |
| 47 | +#' milliseconds; alternatively, `autoplay` can be a list of the form |
| 48 | +#' `list(interval = N, loop = TRUE)`, so the slides will go to the next page |
| 49 | +#' every `N` milliseconds, and optionally go back to the first page to restart |
| 50 | +#' the play when `loop = TRUE`. You can also set `countdown` to a number (the |
| 51 | +#' number of milliseconds) to include a countdown timer on each slide. If |
| 52 | +#' using `autoplay`, you can optionally set `countdown` to `TRUE` to include a |
| 53 | +#' countdown equal to `autoplay`. To alter the set of classes applied to the |
| 54 | +#' title slide, you can optionally set `titleSlideClass` to a vector of |
| 55 | +#' classes; the default is `c("center", "middle", "inverse")`. |
| 56 | +#' @param anchor_sections,... For `tsukuyomi()`, arguments passed to |
| 57 | +#' `moon_reader()`; for `moon_reader()`, arguments passed to |
| 58 | +#' [rmarkdown::html_document()]. |
63 | 59 | #' @note Do not stare at Karl's picture for too long after you turn on the |
64 | | -#' \code{yolo} mode. I believe he has Sharingan. |
| 60 | +#' `yolo` mode. I believe he has Sharingan. |
65 | 61 | #' |
66 | | -#' For the option \code{self_contained = TRUE}, it encodes images as base64 |
67 | | -#' data in the HTML output file. The image path should not contain the string |
68 | | -#' \code{")"} when the image is written with the syntax \verb{} or |
69 | | -#' \verb{background-image: url(PATH)}, and should not contain the string |
70 | | -#' \code{"/>"} when it is written with the syntax \verb{<img src="PATH" />}. |
71 | | -#' Rendering slides in the self-contained mode can be time-consuming when you |
72 | | -#' have remote resources (such as images or JS libraries) in your slides |
73 | | -#' because these resources need to be downloaded first. We strongly recommend |
74 | | -#' that you download remark.js (via \code{\link{summon_remark}()}) and use a |
75 | | -#' local copy instead of the default \code{chakra} argument when |
76 | | -#' \code{self_contained = TRUE}, so remark.js does not need to be downloaded |
77 | | -#' each time you compile your slides. |
| 62 | +#' For the option `self_contained = TRUE`, it encodes images as base64 data in |
| 63 | +#' the HTML output file. The image path should not contain the string `")"` |
| 64 | +#' when the image is written with the syntax `` or `background-image: |
| 65 | +#' url(PATH)`, and should not contain the string `"/>"` when it is written |
| 66 | +#' with the syntax `<img src="PATH" />`. Rendering slides in the |
| 67 | +#' self-contained mode can be time-consuming when you have remote resources |
| 68 | +#' (such as images or JS libraries) in your slides because these resources |
| 69 | +#' need to be downloaded first. We strongly recommend that you download |
| 70 | +#' remark.js (via [summon_remark()]) and use a local copy instead of the |
| 71 | +#' default `chakra` argument when `self_contained = TRUE`, so remark.js does |
| 72 | +#' not need to be downloaded each time you compile your slides. |
78 | 73 | #' |
79 | | -#' When the slides are previewed via \code{xaringan::\link{inf_mr}()}, |
80 | | -#' \code{self_contained} will be temporarily changed to \code{FALSE} even if |
81 | | -#' the author of the slides set it to \code{TRUE}. This will make it faster to |
82 | | -#' preview slides locally (by avoiding downloading remote resources explicitly |
83 | | -#' and base64 encoding them). You can always click the Knit button in RStudio |
84 | | -#' or call \code{rmarkdown::render()} to render the slides in the |
85 | | -#' self-contained mode (these approaches will respect the |
86 | | -#' \code{self_contained} setting). |
| 74 | +#' When the slides are previewed via [xaringan::inf_mr()], `self_contained` |
| 75 | +#' will be temporarily changed to `FALSE` even if the author of the slides set |
| 76 | +#' it to `TRUE`. This will make it faster to preview slides locally (by |
| 77 | +#' avoiding downloading remote resources explicitly and base64 encoding them). |
| 78 | +#' You can always click the Knit button in RStudio or call |
| 79 | +#' `rmarkdown::render()` to render the slides in the self-contained mode |
| 80 | +#' (these approaches will respect the `self_contained` setting). |
87 | 81 | #' |
88 | | -#' Each page has its own countdown timer (when the option \code{countdown} is |
89 | | -#' set in \code{nature}), and the timer is (re)initialized whenever you |
90 | | -#' navigate to a new page. If you need a global timer, you can use the |
91 | | -#' presenter's mode (press \kbd{P}). |
92 | | -#' @references \url{https://naruto.fandom.com/wiki/Tsukuyomi} |
| 82 | +#' Each page has its own countdown timer (when the option `countdown` is set |
| 83 | +#' in `nature`), and the timer is (re)initialized whenever you navigate to a |
| 84 | +#' new page. If you need a global timer, you can use the presenter's mode |
| 85 | +#' (press \kbd{P}). |
| 86 | +#' @references <https://naruto.fandom.com/wiki/Tsukuyomi> |
93 | 87 | #' @importFrom htmltools tagList tags htmlEscape HTML |
94 | 88 | #' @export |
95 | 89 | #' @examples |
@@ -257,23 +251,23 @@ tsukuyomi = function(...) moon_reader(...) |
257 | 251 | #' Serve and live reload slides |
258 | 252 | #' |
259 | 253 | #' Use the \pkg{servr} package to serve and reload slides on change. |
260 | | -#' \code{inf_mr()} and \code{mugen_tsukuyomi()} are aliases of |
261 | | -#' \code{infinite_moon_reader()}. |
| 254 | +#' `inf_mr()` and `mugen_tsukuyomi()` are aliases of |
| 255 | +#' `infinite_moon_reader()`. |
262 | 256 | #' |
263 | 257 | #' The Rmd document is compiled continuously to trap the world in the Infinite |
264 | 258 | #' Tsukuyomi. The genjutsu is cast from the directory specified by |
265 | | -#' \code{cast_from}, and the Rinne Sharingan will be reflected off of the |
266 | | -#' \code{moon}. Use \code{servr::daemon_stop()} to perform a genjutsu Kai and |
| 259 | +#' `cast_from`, and the Rinne Sharingan will be reflected off of the |
| 260 | +#' `moon`. Use `servr::daemon_stop()` to perform a genjutsu Kai and |
267 | 261 | #' break the spell. |
268 | 262 | #' @param moon The input Rmd file path (if missing and in RStudio, the current |
269 | 263 | #' active document is used). |
270 | 264 | #' @param cast_from The root directory of the server. |
271 | | -#' @param ... Passed to \code{rmarkdown::\link[rmarkdown]{render}()}. |
272 | | -#' @references \url{https://naruto.fandom.com/wiki/Infinite_Tsukuyomi} |
| 265 | +#' @param ... Passed to [rmarkdown::render()]. |
| 266 | +#' @references <https://naruto.fandom.com/wiki/Infinite_Tsukuyomi> |
273 | 267 | #' @note This function is not really tied to the output format |
274 | | -#' \code{\link{moon_reader}()}. You can use it to serve any single-HTML-file R |
| 268 | +#' [moon_reader()]. You can use it to serve any single-HTML-file R |
275 | 269 | #' Markdown output. |
276 | | -#' @seealso \code{servr::\link{httw}} |
| 270 | +#' @seealso [servr::httw()] |
277 | 271 | #' @export |
278 | 272 | #' @rdname inf_mr |
279 | 273 | infinite_moon_reader = function(moon, cast_from = '.', ...) { |
@@ -383,24 +377,24 @@ mugen_tsukuyomi = infinite_moon_reader |
383 | 377 | #' This function can use either the \command{decktape} command or the hosted |
384 | 378 | #' docker image of the \pkg{decktape} library to convert HTML slides to PDF |
385 | 379 | #' (including slides produced by \pkg{xaringan}). |
386 | | -#' @param file The path to the HTML presentation file. When \code{docker = |
387 | | -#' FALSE}, this path could be a URL to online slides. |
| 380 | +#' @param file The path to the HTML presentation file. When `docker = FALSE`, |
| 381 | +#' this path could be a URL to online slides. |
388 | 382 | #' @param output The desired output path of the PDF file. |
389 | | -#' @param args Command-line arguments to be passed to \code{decktape}. |
390 | | -#' @param docker Whether to use Docker (\code{TRUE}) or use the |
391 | | -#' \command{decktape} command directly (\code{FALSE}). By default, if |
392 | | -#' \pkg{decktape} has been installed in your system and can be found via |
393 | | -#' \code{Sys.which('decktape')}, it will be uesd directly. |
| 383 | +#' @param args Command-line arguments to be passed to `decktape`. |
| 384 | +#' @param docker Whether to use Docker (`TRUE`) or use the \command{decktape} |
| 385 | +#' command directly (`FALSE`). By default, if \pkg{decktape} has been |
| 386 | +#' installed in your system and can be found via `Sys.which('decktape')`, it |
| 387 | +#' will be uesd directly. |
394 | 388 | #' @param version The \pkg{decktape} version when you use Docker. |
395 | 389 | #' @param open Whether to open the resulting PDF with your system PDF viewer. |
396 | 390 | #' @note For some operating systems you may need to |
397 | 391 | #' \href{https://stackoverflow.com/questions/48957195}{add yourself to the |
398 | 392 | #' \command{docker} group} and restart your machine if you use DeckTape via |
399 | 393 | #' Docker. By default, the latest version of the \pkg{decktape} Docker image |
400 | 394 | #' is used. In case of errors, you may want to try older versions (e.g., |
401 | | -#' \code{version = '2.8.0'}). |
402 | | -#' @references DeckTape: \url{https://github.com/astefanutti/decktape}. Docker: |
403 | | -#' \url{https://www.docker.com}. |
| 395 | +#' `version = '2.8.0'`). |
| 396 | +#' @references DeckTape: <https://github.com/astefanutti/decktape>. Docker: |
| 397 | +#' <https://www.docker.com>. |
404 | 398 | #' @return The output file path (invisibly). |
405 | 399 | #' @export |
406 | 400 | #' @examplesIf interactive() |
|
0 commit comments