权威指南谈到将 HTML 片段添加到其他文档https://bookdown.org/yihui/rmarkdown/html-document.html#html-fragments
它还将“包含”称为高级定制https://bookdown.org/yihui/rmarkdown/html-document.html#advanced-customization
---
title: "Habits"
output:
html_document:
includes:
in_header: header.html
before_body: doc_prefix.html
after_body: doc_suffix.html
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
这允许在模板引擎中包含“标题”和正文之前/之后的 HTML 子元素。
在 RNotebook 的中间,我怎么说“insert-html-file-here”(类似于 Latex \input{} 表示法)?
高级内联“包含”的文档在哪里?
所以,我得到了初步回应,并想报告它。
我添加了[封装问题,因此使用<pre>
它来获取它的本质]:
{r, child="testme.html", eval=TRUE} # 空块内容,这里只插入testme.html的所有内容
我创建了一个文件“testme.html”
<BR />
<TABLE border=1>
<TR>
<TH>Hello there</TH>
<TH rowspan=2>How is it going?</TH>
</TR>
<TR>
<TD>I am doing fine</TD>
</TR>
<TR bgcolor="red">
<TD valign="top" align="center" colspan=2>
<DIV style="border: 2px solid black">
<IMG src="2020-08-24_13-15-36.png" />
<DIV>Here is my Caption</DIV>
</DIV>
</TD>
</TR>
</TABLE>
<BR />
我必须添加它,<BR />
这样它才能在模板中播放得很好。
这就是浏览器呈现的样子。
这是 Knit-HTML 呈现的内容:
它不允许 child=testme.html 的 URL... 所以它不能通过 http:// 远程运行???
这是渲染的输出。它可能不喜欢嵌套的 DIV?第二个<BR />
被包装在<p>
标签中,第一个没有。
<BR />
<TABLE border="1">
<TR>
<TH>
Hello there
</TH>
<TH rowspan="2">
How is it going?
</TH>
</TR>
<TR>
<TD>
I am doing fine
</TD>
</TR>
<TR bgcolor="red">
<TD valign="top" align="center" colspan="2">
<DIV style="border: 2px solid black;">
<pre><code> <IMG src="2020-08-24_13-15-36.png" />
<DIV>Here is my Caption</DIV>
</DIV>
</TD></code></pre>
</TR>
</TABLE>
<p><BR /></p>