Learn R Programming

rmarkdown (version 2.24)

output_format_dependency: Define an R Markdown's output format dependency

Description

Define the dependency such as and pre/post-processors dynamically from within chunks. This function shares some arguments with output_format, but lacks the others because dependency is resolved after post_knit and before pre_processor.

Usage

output_format_dependency(
  name,
  pandoc = list(),
  pre_processor = NULL,
  post_processor = NULL,
  file_scope = NULL,
  on_exit = NULL
)

Value

An list of arguments with the "rmd_dependency" class.

Arguments

name

A dependency name. If some dependencies share the same name, then only the first one will be attached.

pandoc

Pandoc options for an output format (see pandoc_options)

pre_processor

An optional pre-processor function that receives the metadata, input_file, runtime, knit_meta, files_dir, and output_dir and can return additional arguments to pass to pandoc.

post_processor

An optional post-processor function that receives the metadata, input_file, output_file, clean, and verbose parameters, and can return an alternative output_file.

file_scope

A function that will split markdown input to pandoc into multiple named files. This is useful when the caller has concatenated a set of Rmd files together (as bookdown does), and those files may need to processed by pandoc using the --file-scope option. The first argument is input file paths and the second is NULL or current file scope which is a named list of files w/ name and content for each file. The return is the new file scope. Also, the arguments should include ... for the future extensions.

on_exit

A function to call when rmarkdown::render() finishes execution (as registered with a on.exit handler).

Examples

Run this code
# Add lua filters from within a chunk
output_format_dependency("lua_filter", pre_processor = function(...) {
  pandoc_lua_filter_args(c("example1.lua", "example2.lua"))
})

Run the code above in your browser using DataLab