Add the class name before the extension of knitr images

set_extension(options, prefix = ".", suffix = ".", sep = ".")

Arguments

options

List. Options as passed by knitr.

prefix

Character. See details.

suffix

Character. See details.

sep

Character. See details.

Value

Options to be passed back to knitr.

Details

When class.output is set, this function can add that class before the file extension. From there, pre-process.js picks it up by regex and adds the class to the plot.

set_extension handles multiple classes separated by spaces. Periods are stripped out and spaces are replaced with sep. The full filename looks like this: (filepath)/(filename).(prefix)(classes)(suffix).(extension)

pre-process.js watches for this pattern, but set_extension offers parameters to override them.

Examples

# NOT RUN {
knitr::opts_hooks$set(
  class.output = surprisinglytidy::set_extension,
  dev = surprisinglytidy::set_extension
)
# }