Code folding for distinct code chunks?


I would like to have the option to code_folding: hide within distinct code chunks in an R Markdown file and not in others. There is some code that I want displayed without the ability to hide it, but other code that I want to give the reader an opportunity to look at if they wish. Is there a way to do this? I've searched the webs high and low and am not seeing a straightforward solution, and that may be because there isn't one. But if anyone knows of one, that would be super helpful.

Thanks so much!

Does this not do what you want? Namely:

title: "Untitled"

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

Some text

<details><summary>Click here</summary>
This is folded

```{r code}
# hidden code
print("Hello world!")

This is outside

# not hidden