在每章 header 上方添加一个 HTML 块

Add a HTML block above each chapter header

我看到我们可以使用

自定义 bookdown HTML 的外观
---
output:
  bookdown::html_book:
    includes:
      in_header: style.css
---

还有 before_bodyafter_body,如下所述:https://bookdown.org/yihui/bookdown/yaml-options.html

但我不确定如何在我的 HTML 输出中插入一些文本或直接显示在每个章节标题上方的 div。例如,我想要一个警告框,上面写着 "Warning: Early Draft",带有警告符号和 link 到另一页。

同样,如何在每个部分(即html页)正文底部的正下方插入一个div?

我可以使用 includes: 还是需要修改某种模板?我在 bookdown pkg (https://bookdown.org/yihui/bookdown/html.html#bootstrap-style) 中看到模板的提及,但如果这是我需要编辑的内容,那么我想要一个与我的 bookdown Rmd 文件一起使用的模板

为了跟进,我 discussed this with the package author, who confirmed that the template was hard-coded. He kindly advised me on how this might be changed , so I submitted a pull request 到 bookdown 包。现在我们可以使用 _output.yml 在每个 chapter/section 标题上方插入文本和 HTML,如下所示:

bookdown::gitbook:
  includes:
    before_body: xxxx.html

其中 xxx.html 是一个 HTML 文件,其中包含要插入到标题上方的内容。