blogdown
blogdown copied to clipboard
Request for support for code_folding?
Hi Yihui and Team
Just a cheeky request for support for code_folding. The documentation suggests its in the pipeline, but I'd like to upvote it.
For my use case I'm trying to use my blog both for demonstration/training for my students (view code), but also to make my science accessible to the public (hide code). Most of the feedback I've had from non-scientists/non-R-coders is that the code chunks seriously detract from the readability of the blog so it would be handy to be able to interactively hide/view.
Thanks and all the best Jasper
Heard you! Thanks for the vote! 😄
Update: (for the record) https://stackoverflow.com/q/45360998/559676
I just released an article on my website on how to enable code_folding in blogdown. You can see the associated modifications of my hugo template in this pull request https://github.com/statnmap/hugo-statnmap-theme/pull/1
@statnmap Thanks for sharing the solution! It seems you just changed the date of your post, and now the URL has become https://statnmap.com/2017-11-13-enable-code-folding-in-bookdown-and-blogdown/ Always use 301 redirects when you change URLs, so there will never be dead links (if you use Netlify, here is the doc https://www.netlify.com/docs/redirects/).
You're welcome. I corrected the link above. Thanks for the tip.
Hi there! I just want to vote for the feature. Would be great to have it. Thanks.
I also would like to vote for this feature, particularly in blogdown to avoid having to scroll through huge amounts of code when writing tutorial blog posts. It would be nice to be able to see the results and then investigate the code as needed by unfolding it as required.
An implementation of code folding for Academic is detailed in the blog post of @jepusto : https://www.jepusto.com/code-folding-update/ This adds some new ideas to my first blog post on the subject presented above.
I used the above notes to set-up code-folding for my lithium themed site, see commit https://github.com/brshallo/brshallo/commit/9b499db474c132859a5eeb1169be35b069b65eda. (Though currently I am unable to set codefolding_nobutton which just defaults to true / false depending on if there is code in the post.)
Another lithium, blogdown example can be found at mark-druffle/mark-druffle.com.
Six years later, I have finally published my own solution: https://yihui.org/en/2023/09/code-folding/ Even if you don't use blogdown, this solution will still work.