| 1 |
## ----setup, include = FALSE--------------------------------------------------- |
| 2 |
knitr::opts_chunk$set( |
| 3 |
collapse = TRUE, |
| 4 |
comment = "#>" |
| 5 |
) |
| 6 |
|
| 7 |
## ----modifying-format--------------------------------------------------------- |
| 8 |
custom_format <- function(...) { |
| 9 |
base_format <- rmarkdown::html_document(...) |
| 10 |
# prepending a new Lua filter to html_document() ones |
| 11 |
base_format$pandoc$lua_filters <- c( |
| 12 |
rmarkdown::pandoc_path_arg("new.lua"), |
| 13 |
base_format$pandoc$lua_filters) |
| 14 |
base_format |
| 15 |
} |
| 16 |
|
| 17 |
basename(custom_format()$pandoc$lua_filters) |
| 18 |
|
| 19 |
## ----creating-format---------------------------------------------------------- |
| 20 |
custom_format <- function(toc = TRUE, ...) { |
| 21 |
rmarkdown::output_format( |
| 22 |
knitr = rmarkdown::knitr_options(), |
| 23 |
# a new filter will be appended to base_format ones |
| 24 |
pandoc = rmarkdown::pandoc_options(to = "html", lua_filters = "new.lua"), |
| 25 |
base_format = rmarkdown::html_document(toc = toc, ...) |
| 26 |
) |
| 27 |
} |
| 28 |
|
| 29 |
basename(custom_format()$pandoc$lua_filters) |
| 30 |
|