| 1 |
#' Convert to an HTML fragment. |
| 2 |
#' |
| 3 |
#' An html fragment is suitable for inclusion into an external html page. See |
| 4 |
#' \code{\link{html_document}} for full details - this is a minor variation that |
| 5 |
#' assumes you will include the output into an existing document (e.g. a blog |
| 6 |
#' post). |
| 7 |
#' |
| 8 |
#' See the \href{https://yihui.org/rmarkdown/html-document.html}{online |
| 9 |
#' documentation} for additional details on using the \code{html_fragment} |
| 10 |
#' format. |
| 11 |
#' @param mathjax \code{TRUE} to convert $ and $$ math blocks into MathJax |
| 12 |
#' compatible output. Note that you'll still need to ensure that the page |
| 13 |
#' where the fragment is included loads the required MathJax scripts. |
| 14 |
#' @inheritParams html_document |
| 15 |
#' @param ... Additional arguments passed to \code{\link{html_document}} |
| 16 |
#' @return R Markdown output format to pass to \code{\link{render}} |
| 17 |
#' @export |
| 18 |
html_fragment <- function(number_sections = FALSE, |
| 19 |
section_divs = TRUE, |
| 20 |
fig_width = 7, |
| 21 |
fig_height = 5, |
| 22 |
fig_retina = 2, |
| 23 |
fig_caption = TRUE, |
| 24 |
dev = 'png', |
| 25 |
df_print = "default", |
| 26 |
mathjax = TRUE, |
| 27 |
includes = NULL, |
| 28 |
keep_md = FALSE, |
| 29 |
md_extensions = NULL, |
| 30 |
pandoc_args = NULL, |
| 31 |
...) { |
| 32 |
|
| 33 |
if (mathjax) |
| 34 |
pandoc_args <- c(pandoc_args, "--mathjax") |
| 35 |
|
| 36 |
html_document( |
| 37 |
number_sections = number_sections, fig_width = fig_width, |
| 38 |
fig_height = fig_height, fig_retina = fig_retina, fig_caption = fig_caption, |
| 39 |
dev = dev, df_print = df_print, keep_md = keep_md, |
| 40 |
md_extensions = md_extensions, pandoc_args = pandoc_args, includes = includes, |
| 41 |
mathjax = NULL, section_divs = section_divs, highlight = NULL, theme = NULL, ..., |
| 42 |
template = pkg_file("rmd/fragment/default.html") |
| 43 |
) |
| 44 |
} |