Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

74 lines
1.7KB

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