Skip to content

Commit ef7162c

Browse files
extend vignette according to extended functionality
1 parent 093c6a1 commit ef7162c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

vignettes/introducing_styler.Rmd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ more examples of code before and after styling.
121121
1++1-1-1/2
122122
```
123123

124+
This is tidyverse style. However, styler offers very granular control for
125+
math token spacing. Assuming you like spacing around `+` and `-`, but not
126+
around `/` and `*` and `^`, do the following:
127+
```{r}
128+
style_text(
129+
"1++1/2*2^2",
130+
math_token_spacing = specify_math_token_spacing(zero = c("'/'", "'*'", "'^'"))
131+
)
132+
```
133+
124134
It can also format complicated expressions that involve line breaking and
125135
indention based on both brace expressions and operators:
126136

@@ -176,3 +186,20 @@ z) {
176186
mtcars %>%
177187
group_by( !!my_vars )
178188
```
189+
190+
If you, say, don't want comments starting with `###` to be indented, you can
191+
formulate an unindention rule:
192+
```{r}
193+
style_text(
194+
c(
195+
"a <- function() {",
196+
"### not to be indented",
197+
"# indent normally",
198+
"33",
199+
"}"
200+
),
201+
reindention = specify_reindention(regex_pattern = "###", indention = 0)
202+
203+
)
204+
```
205+

0 commit comments

Comments
 (0)