set_extension: Prepend class name to image extension

Description Usage Arguments Details Value Examples

Description

Add the class name before the extension of knitr images

Usage

1
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.

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.

Value

Options to be passed back to knitr.

Examples

1
2
3
4
5
6
7
## Not run: 
knitr::opts_hooks$set(
  class.output = surprisinglytidy::set_extension,
  dev = surprisinglytidy::set_extension
)

## End(Not run)

BenjaminWolfe/surprisinglytidy documentation built on Nov. 22, 2019, 11:37 a.m.