In Rmarkdown documents there is a code folding option--code_folding: hide
. This option is not available for Hugo websites generated with the blogdown
package (see this recently opened feature request). Has anyone come up with a work-around for this? Even some JavaScript and HTML code that can be added on a post-by-post basis?
As an example, blogdown generates a default Hugo site with the Hugo-lithium theme when you run the following command in an new directory:
blogdown::new_site().
One of the posts generated for this default is below. I'd be interested in adding code folding to this example, that is, a hide/show button that the webpage above each R code block.
title: "Hello R Markdown"
author: "Frida Gomam"
date: 2015-07-23T21:13:14-05:00
categories: ["R"]
tags: ["R Markdown", "plot", "regression"]
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE)
```
# R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
You can embed an R code chunk like this:
```{r cars}
summary(cars)
fit <- lm(dist ~ speed, data = cars)
fit
```
# Including Plots
You can also embed plots. See Figure \@ref(fig:pie) for example:
```{r pie, fig.cap='A fancy pie chart.', tidy=FALSE}
par(mar = c(0, 1, 0, 1))
pie(
c(280, 60, 20),
c('Sky', 'Sunny side of pyramid', 'Shady side of pyramid'),
col = c('#0292D8', '#F7EA39', '#C4B632'),
init.angle = -50, border = NA
)