在 Rmarkdown 文档中有一个代码折叠选项- code_folding: hide
。此选项不适用于使用blogdown
包生成的 Hugo 网站(请参阅此最近打开的功能请求)。有没有人想出解决这个问题的方法?甚至一些可以逐个添加的 JavaScript 和 HTML 代码?
例如,当您在新目录中运行以下命令时,blogdown 会生成一个带有 Hugo-lithium 主题的默认 Hugo 站点:
blogdown::new_site().
为此默认生成的帖子之一如下。我有兴趣在此示例中添加代码折叠,即每个 R 代码块上方的网页的隐藏/显示按钮。
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
)