The Definitive guide speaks of adding HTML fragments to other documents https://bookdown.org/yihui/rmarkdown/html-document.html#html-fragments
It also speaks of "includes" as advanced customization 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.
This allows one to include a "header" and before/after body HTML subelements in the templating engine.
In the middle of the RNotebook, how do I say "insert-html-file-here" (similar to the Latex \input{} notation)?
Where is the documentation on advanced, inline "includes"?
So, I got an initial response, and wanted to report on it.
I added [encapsulation issue so using <pre>
to get essence of it]:
{r, child="testme.html", eval=TRUE} # empty chunk content, only inserting all content of testme.html here
I created a file "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 />
I had to add the <BR />
so it would play nice back in the template.
This is what a browser renders it as.
This is what Knit-HTML renders:
It does not allow URLS for the child=testme.html ... so it cannot be run remotely over http:// ???
This is the output rendered. It may not like nested DIVs? The second <BR />
gets wrapped in a <p>
tag, the first does not.
<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>
Here you go