In my document, I want to show some info, using ``` block, such as:
```
bruin@c7 ~ $ cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
bruin@c7 ~ $
```
For large output chunks, I want to fold them. How to do that? Searching the web it seems all related topics are about code folding, but what I want to fold is not any type of code, just simple text...
Thanks!
Here is a very easy way to implement the following yourself:
You can find all the code you need in the following reproducible RMD document:
In the JS part we simply add a button to every chunk that is marked with the class
fold
. Afterwards we add theonClick
event to all those buttons. When a button is clicked, its text should toggle between Fold and Unfold. And the corresponding code container should toggle its visibility state as well. Every chunk marked withfold
is folded when the document is opened. How you style the button using CSS is up to you.