Some filler text.
Some filler text.
Some random code
<- function(pkg, input, output, ..., copy_images = TRUE,
render_rmarkdown quiet = TRUE) {
<- path_abs(input, pkg$src_path)
input_path <- path_abs(output, pkg$dst_path)
output_path
if (!file_exists(input_path)) {
stop("Can't find ", src_path(input), call. = FALSE)
}
cat_line("Reading ", src_path(input))
<- file_digest(output_path)
digest
<- list(
args input = input_path,
output_file = path_file(output_path),
output_dir = path_dir(output_path),
intermediates_dir = tempdir(),
encoding = "UTF-8",
envir = globalenv(),
...,quiet = quiet
)
<- tryCatch(
path ::r_safe(
rmarkdownfunction(...) rmarkdown::render(...),
args = args,
show = !quiet,
env = c(
::rcmd_safe_env(),
rmarkdownBSTINPUTS = bst_paths(input_path),
TEXINPUTS = tex_paths(input_path),
BIBINPUTS = bib_paths(input_path),
R_CLI_NUM_COLORS = 256
)
),error = function(cnd) {
rule("RMarkdown error")
cat(gsub("\r", "", cnd$stderr, fixed = TRUE))
rule()
abort("Failed to render RMarkdown", parent = cnd)
}
)
if (identical(path_ext(path)[[1]], "html")) {
update_html(
path,
tweak_rmarkdown_html,input_path = path_dir(input_path),
pkg = pkg
)
}if (digest != file_digest(output_path)) {
cat_line("Writing ", dst_path(output))
}
# Copy over images needed by the document
if (copy_images) {
<- rmarkdown::find_external_resources(input_path)
ext
# copy web + explicit files beneath vignettes/
<- path_has_parent(ext$path, ".")
is_child <- ext$path[(ext$web | ext$explicit) & is_child]
ext_path
<- path(path_dir(input_path), ext_path)
src <- path(path_dir(output_path), ext_path)
dst # Make sure destination paths exist before copying files there
dir_create(unique(path_dir(dst)))
file_copy(src, dst, overwrite = TRUE)
}check_missing_images(pkg, input, output)
invisible(path)
}