These transformers provide additional automatic formatting for the template strings. They are designed to be used with the .transformer chunk option of in epoxy chunks. You can use epoxy_style() to chain several transformers together. epoxy_style() and individual epoxy style functions can be used in epoxy, epoxy_html and epoxy_latex chunks and will choose the correct syntax for each.

## Usage

epoxy_style(..., syntax = NULL)

epoxy_style_wrap(
before = "**",
after = before,
syntax = NULL,
transformer = glue::identity_transformer
)

epoxy_style_bold(syntax = NULL, transformer = glue::identity_transformer)

epoxy_style_italic(syntax = NULL, transformer = glue::identity_transformer)

epoxy_style_apply(.f = identity, ..., transformer = glue::identity_transformer)

epoxy_style_code(syntax = NULL, transformer = glue::identity_transformer)

epoxy_style_collapse(
sep = ", ",
last = sep,
language = NULL,
...,
transformer = glue::identity_transformer
)

## Arguments

...

A list of style functions, e.g. epoxy_style_bold or the name of a style function, e.g. "bold", or a call to a style function, e.g. epoxy_style_bold(). epoxy_style() chains the style functions together, applying the styles from left to right.

For example, epoxy_style("bold", "collapse") results in replaced strings that are emboldened and then collapsed, e.g. **a** and **b**. On the other hand, epoxy_style("collapse", "bold") will collapse the vector and then embolden the entire string.

In epoxy_style_apply(), the ... are passed to the underlying call the underlying function call.

In epoxy_style_collapse(), the ... are ignored.

syntax

One of "markdown" (or "md"), "html", or "latex". The default is chosen based on the engine of the chunk where the style function is called, or according to the option epoxy.engine. Caution: invalid options are silently ignored, falling back to markdown syntax.

before, after

In epoxy_style_wrap(), the characters to be added before and after variables in the template string.

transformer

The transformer to apply to the replacement string. This argument is used for chaining the transformer functions. By providing a function to this argument you can apply an additional transformation after the current transformation. In nearly all cases, you can let epoxy_style() handle this for you. The chain ends when glue::identity_transformer() is used as the transformer.

.f

A function, function name or purrr::map()-style inline function.

sep, last

The separator to use when joining the vector elements when the expression ends with a *. Elements are separated by sep, except for the last two elements, which use last.

language

In epoxy_style_collapse(), language is passed to and::and() or and::or() to choose the correct and/or phrase and spacing for the language. By default, will follow the system language. See and::and_languages for supported languages.

## Value

A function of text and envir suitable for the .transformer

argument of glue::glue().

## Functions

• epoxy_style_wrap: Wrap variables

• epoxy_style_bold: Embolden variables using ** in markdown, <strong> in HTML, or \textbf{} in LaTeX

• epoxy_style_italic: Italicize variables using _ in markdown, <em> in HTML, or \emph{} in LaTeX

• epoxy_style_apply: Apply a function to all replacement expressions

• epoxy_style_code: Code format variables using  in markdown, <code> in HTML, or \texttt{} in LaTeX

• epoxy_style_collapse: Collapse vector variables

## Output-specific styling

The epoxy_style_ functions will attempt to use the correct syntax for styling the replacement text for markdown, HTML and LaTeX. This choice is driven by the chunk engine where the styling function is used. The epoxy engine corresponds to markdown, epoxy_html to HTML, and epoxy_latex to LaTeX.

Automatic syntax selection only works when the epoxy style functions are used with epoxy knitr engines and during the knitr rendering process. When used outside of this context, you can choose the desired syntax by setting the syntax to one of "markdown", "html" or "latex".

Other epoxy-style glue transformers: epoxy_style_format(), epoxy_style_html()

## Examples

glue::glue("{letters[1:3]&}", .transformer = epoxy_style("bold", "collapse"))
#> **a**, **b** and **c**
glue::glue("{letters[1:3]&}", .transformer = epoxy_style("collapse", "bold"))
#> **a, b and c**

# In an epoxy_html chunk...
# Note that you don't have to set syntax = "html", it just knows
glue::glue(
"{letters[1:3]&}",
.transformer = epoxy_style("bold", "collapse", syntax = "html")
)
#> <strong>a</strong>, <strong>b</strong> and <strong>c</strong>

# Or in an epoxy_latex chunk...
glue::glue(
"{letters[1:3]&}",
.transformer = epoxy_style("bold", "collapse", syntax = "latex")
)
#> \textbf{a}, \textbf{b} and \textbf{c}

# Other Transfomers ----

# Apply format() to all replacements