#' Bulma Document Renderer #' #' @section YAML options: #' You can pass additional options to the underlying template via the `bulma` #' YAML item. The following options can be specified there. #' \itemize{ #' \item{`hero`: Classes applied to the hero containing the title.} #' \item{`hero_body`: Classes applied to the hero body container.} #' \item{`hero_button`: Classes applied to the `header_links` buttons} #' \item{`hero_links`: Links that will be displayed under title as buttons. #' Formatted as a list, each element having entries for `name`, `url`, #' and `icon`. Icons use [Font Awesome](https://fontawesome.com/icons); #' see [fa_icon()] for help constructing the Font Awesome class. The #' full Font Awesome class name is required.} #' } #' #' ``` #' --- #' bulma: #' hero: ["info"] #' hero_button: ["is-secondary", "is-outlined"] #' hero_links: #' - name: Github #' url: https://github.com/ #' icon: '`r bulma::fa_icon("github")`' #' - name: Twitter #' url: https://twitter.com #' icon: "fab fa-twitter" #' --- #' ``` #' #' @inheritDotParams rmarkdown::html_document_base #' @export 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", bulma_file("bulma", "bulma.0.7.2.min.css")) if (!is.null(css)) { 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") # ), # ... # ) 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, rmarkdown::html_dependency_font_awesome())) # 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") }