Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

82 lines
2.0KB

  1. #' Bulma Document Renderer
  2. #'
  3. #' @section YAML options:
  4. #' You can pass additional options to the underlying template via the `bulma`
  5. #' YAML item. The following options can be specified there.
  6. #' \itemize{
  7. #' \item{`hero`: Classes applied to the hero containing the title}
  8. #' \item{`hero_button`: Classes applied to the `header_links` buttons}
  9. #' }
  10. #'
  11. #' @inheritDotParams rmarkdown::html_document_base
  12. #' @export
  13. bulma_document <- function(
  14. ...,
  15. css = NULL,
  16. fig_width = 10,
  17. fig_height = 7,
  18. fig_retina = 2,
  19. keep_md = FALSE,
  20. dev = "png",
  21. pandoc_args = NULL,
  22. extra_dependencies = NULL
  23. ) {
  24. css_files <- c(
  25. "--css", bulma_file("bulma", "bulma.0.7.2.min.css"))
  26. if (!is.null(css)) {
  27. for (css_file in css) {
  28. css_files <- c(css_files, "--css", css_file)
  29. }
  30. }
  31. # rmarkdown::html_document_base(
  32. # pandoc_args = c(
  33. # css_files,
  34. # pandoc_args,
  35. # "--template",
  36. # system.file("bulma", "bulma.html", package="bulma")
  37. # ),
  38. # ...
  39. # )
  40. deps <- htmltools::htmlDependency(
  41. name = "bulma",
  42. version = "0.7.2",
  43. src = bulma_file("bulma"),
  44. stylesheet = "bulma.0.7.2.min.css"
  45. )
  46. extra_dependencies <- append(extra_dependencies, list(deps))
  47. # preprocessor ----
  48. pre_processor <- function(metadata, input_file, runtime, knit_meta, files_dir, output_dir) {
  49. # browser()
  50. }
  51. rmarkdown::output_format(
  52. knitr = rmarkdown::knitr_options_html(
  53. fig_width, fig_height, fig_retina, keep_md, dev
  54. ),
  55. pandoc = rmarkdown::pandoc_options(
  56. to = "html",
  57. from = "markdown+ascii_identifiers+tex_math_single_backslash",
  58. args = c(
  59. css_files,
  60. pandoc_args,
  61. "--template",
  62. bulma_file("bulma", "bulma.html")
  63. ),
  64. ),
  65. pre_processor = pre_processor,
  66. clean_supporting = TRUE,
  67. base_format = rmarkdown::html_document_base(
  68. self_contained = TRUE, template = NULL,
  69. pandoc_args = pandoc_args,
  70. extra_dependencies = extra_dependencies
  71. )
  72. )
  73. }
  74. bulma_file <- function(...) {
  75. system.file(..., package = "bulma")
  76. }