Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

set_line_break_around_curly_curly

Styling around \{\{


Description

With {rlang} version 0.4, a new syntactic sugar is introduced, the curly-curly operator. It interprets this code in a special way: call(\{\{ x \}\}). See this blog post on the topic. Here, the curly-curly sugar is understood as two opening curly braces, followed by an expression followed by two closing curly braces, e.g. \{\{1\}\}. \{\{1\} + 1\} does not contain the curly-curly syntactic sugar according to the above definition. On the other hand \{\{ x + y \}\} is recognized by styler as containing it (and is parsable code) but will most likely give an error at runtime because the way the syntactic sugar is defined in rlang is to use a single token within curly-curly. In addition, because rlang parses \{\{ in a special way (just as !!), the expression \{\{ x \}\} will give a runtime error when used outside of a context that is capable of handling it, e.g. on the top level (that is, not within function call like rlang_fun(\{\{ x \}\})) or within a base R function such as c(). However, these differences are assumed to be irrelevant for styling curly-curly, as much as they were for styling !!. curly-curly affects styling of line break and spaces, namely:

Usage

set_line_break_around_curly_curly(pd)

set_space_in_curly_curly(pd)

Arguments

pd

A parse table.

Details

  • No line break after first or second \{, before third and fourth \{.

  • No space after first and third \{, one space after second and before third \}.

  • No line breaks within curly-curly, e.g. \{\{ x \}\} can only contain line breaks after the last brace or before the first brace. But these are not dependent on curly-curly specifically.

See Also

style_text_without_curly_curly


styler

Non-Invasive Pretty Printing of R Code

v1.4.1
MIT + file LICENSE
Authors
Kirill Müller [aut], Lorenz Walthert [cre, aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.