Skip to content

Commit da5e659

Browse files
committed
clarify that the chunk option strip.white is for individual expressions in a code chunk (not only removing leading/trailing blank lines of a code chunk)
1 parent 7846749 commit da5e659

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
matrix:
1818
config:
1919
- {os: ubuntu-latest, r: 'release'}
20+
- {os: ubuntu-latest, r: '4.4'}
2021
- {os: ubuntu-latest, r: '4.3'}
2122
- {os: ubuntu-latest, r: '4.2'}
2223
- {os: ubuntu-latest, r: '4.1'}

docs/02-fuse.Rmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,9 @@ as is. The behavior is controlled by the option `results`, with possible values:
10481048

10491049
### `strip.white`: trim blank lines in code {#sec:option-strip-white}
10501050

1051-
By default, blank lines at the beginning and end of a source code block are
1052-
removed. To keep them, you can use the chunk option `strip.white = FALSE`.
1051+
By default, the leading and trailing blank lines of individual code expressions
1052+
in a code chunk are removed. To keep them, you can use the chunk option
1053+
`strip.white = FALSE`.
10531054

10541055
`{r} c(.ex(17), .ex(17, '.md'))`
10551056

examples/017-option-strip-white.Rmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ Keep blank lines at the beginning/end:
88

99
```{r, strip.white = FALSE}
1010
11-
# a blank line above
11+
# a blank line before this expression
1212
1 + 1
13-
# and a blank line below
13+
14+
# blank lines before and after this expression
15+
for (i in 1:10) {
16+
}
1417
1518
```

examples/017-option-strip-white.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Keep blank lines at the beginning/end:
88

99
``` {.r}
1010
11-
# a blank line above
11+
# a blank line before this expression
1212
1 + 1
1313
```
1414

@@ -17,6 +17,9 @@ Keep blank lines at the beginning/end:
1717
```
1818

1919
``` {.r}
20-
# and a blank line below
20+
21+
# blank lines before and after this expression
22+
for (i in 1:10) {
23+
}
2124
2225
```

examples/test-results-hide.Rmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
`results = 'hide'` should try to collapse output, e.g., merge the source blocks below:
22

3-
```{r, results = 'hide'}
3+
```{r, chunk-a, results = 'hide'}
44
nrow(iris)
55
ncol(iris)
6+
67
iris
78
```
89

10+
Keep the blank line:
11+
12+
```{r, chunk-a, results = 'hide', strip.white = FALSE}
13+
```
14+
915
Other types of output (such as messages) will interrupt the collapsed block:
1016

1117
```{r, results = 'hide'}

examples/test-results-hide.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ ncol(iris)
66
iris
77
```
88

9+
Keep the blank line:
10+
11+
``` {.r}
12+
nrow(iris)
13+
ncol(iris)
14+
15+
iris
16+
```
17+
918
Other types of output (such as messages) will interrupt the collapsed block:
1019

1120
``` {.r}

0 commit comments

Comments
 (0)