7.5 Fold all code blocks but show some initially

If code blocks in the output document are potentially distracting to readers, you may choose to fold them initially. Readers can then choose to display them by clicking the fold buttons:

output:
  html_document:
    code_folding: hide

You can also choose to unfold all code blocks initially (so readers can choose to fold them later):

output:
  html_document:
    code_folding: show

If you fold all code blocks initially, you can specify certain blocks to be unfolded initially with the chunk option class.source = "fold-show", e.g.,

---
title: Hide all code blocks and show some initially
output:
  html_document:
    code_folding: hide
---

```{r}
1  # code is hidden initially
```

```{r class.source = 'fold-show'}
2  # code is shown initially
```

```{r}
3  # also hidden
```

You can also do it the other way around, i.e., show all code blocks but hide some of them initially. For example:

---
output:
  html_document:
    code_folding: show
---

```{r}
1  # code is shown initially
```

```{r class.source = 'fold-hide'}
2  # code is hidden initially
```