Debian Codegraph @

R/html_extras.R

raw
1
2 # resolve the html extras for a document (dependencies and arbitrary html to
3 # inject into the document)
4 html_extras_for_document <- function(knit_meta, runtime, dependency_resolver,
5 format_deps = NULL) {
6
7 extras <- list()
8
9 # merge the dependencies discovered with the dependencies of this format and
10 # dependencies discovered in knit_meta
11 all_dependencies <- if (is.null(format_deps)) list() else format_deps
12 all_dependencies <- append(all_dependencies, flatten_html_dependencies(knit_meta))
13 extras$dependencies <- dependency_resolver(all_dependencies)
14
15 # return extras
16 extras
17 }
18
19 # convert html extras to the pandoc args required to include them
20 pandoc_html_extras_args <- function(extras, self_contained, lib_dir,
21 output_dir) {
22
23 args <- c()
24
25 # dependencies
26 dependencies <- extras$dependencies
27 if (length(dependencies) > 0) {
28 if (self_contained)
29 file <- as_tmpfile(html_dependencies_as_string(dependencies, NULL, NULL))
30 else
31 file <- as_tmpfile(html_dependencies_as_string(dependencies, lib_dir,
32 output_dir))
33 args <- c(args, pandoc_include_args(in_header = file))
34 }
35
36 # extras
37 args <- c(args, pandoc_include_args(
38 in_header = as_tmpfile(extras$in_header),
39 before_body = as_tmpfile(extras$before_body),
40 after_body = as_tmpfile(extras$after_body)))
41
42 args
43 }