Explorar el Código

Use rmarkdown::output_format() instead of rmarkdown::html_document_base()

master
Garrick Aden-Buie hace 7 años
padre
commit
7f4dba3f7e
Se han modificado 2 ficheros con 64 adiciones y 12 borrados
  1. +61
    -11
      R/bulma_document.R
  2. +3
    -1
      man/bulma_document.Rd

+ 61
- 11
R/bulma_document.R Ver fichero

@@ -2,22 +2,72 @@
#'
#' @inheritDotParams rmarkdown::html_document_base
#' @export
bulma_document <- function(..., css = NULL, pandoc_args = NULL) {
bulma_document <- function(
...,
css = NULL,
fig_width = 10,
fig_height = 7,
fig_retina = 2,
keep_md = FALSE,
dev = "png",
pandoc_args = NULL,
extra_dependencies = NULL
) {
css_files <- c(
"--css", system.file("bulma", "bulma.0.7.2.min.css", package="bulma"))
"--css", bulma_file("bulma", "bulma.0.7.2.min.css"))

if (!is.null(css)) {
for (file in css) {
css_files <- c(css_files, "--css", file)
for (css_file in css) {
css_files <- c(css_files, "--css", css_file)
}
}
rmarkdown::html_document_base(
pandoc_args = c(
css_files,
pandoc_args,
"--template",
system.file("bulma", "bulma.html", package="bulma")
# rmarkdown::html_document_base(
# pandoc_args = c(
# css_files,
# pandoc_args,
# "--template",
# system.file("bulma", "bulma.html", package="bulma")
# ),
# ...
# )
deps <- htmltools::htmlDependency(
name = "bulma",
version = "0.7.2",
src = bulma_file("bulma"),
stylesheet = "bulma.0.7.2.min.css"
)
extra_dependencies <- append(extra_dependencies, list(deps))

# preprocessor ----
pre_processor <- function(metadata, input_file, runtime, knit_meta, files_dir, output_dir) {
# browser()
}

rmarkdown::output_format(
knitr = rmarkdown::knitr_options_html(
fig_width, fig_height, fig_retina, keep_md, dev
),
pandoc = rmarkdown::pandoc_options(
to = "html",
from = "markdown+ascii_identifiers+tex_math_single_backslash",
args = c(
css_files,
pandoc_args,
"--template",
bulma_file("bulma", "bulma.html")
),
),
...
pre_processor = pre_processor,
clean_supporting = TRUE,
base_format = rmarkdown::html_document_base(
self_contained = TRUE, template = NULL,
pandoc_args = pandoc_args,
extra_dependencies = extra_dependencies
)
)
}


bulma_file <- function(...) {
system.file(..., package = "bulma")
}

+ 3
- 1
man/bulma_document.Rd Ver fichero

@@ -4,7 +4,9 @@
\alias{bulma_document}
\title{Bulma Document Renderer}
\usage{
bulma_document(..., css = NULL, pandoc_args = NULL)
bulma_document(..., css = NULL, fig_width = 10, fig_height = 7,
fig_retina = 2, keep_md = FALSE, dev = "png", pandoc_args = NULL,
extra_dependencies = NULL)
}
\arguments{
\item{...}{Arguments passed on to \code{rmarkdown::html_document_base}

Cargando…
Cancelar
Guardar