Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

76 rindas
1.8KB

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