Is there a way to inject R code output into the generated document without the sourounding format tags <pre><code class="r"> or <pre><code>? I ask this because I want to use .Rmd not .Rhmtl but at the same time inject some extra HTML lines. Doing so using e.g. cat("HTML code") will fail as the output is sourrounded by <pre><code>.
The example I try to run the follwing .Rmd file (with additional HTML lines) which file not work out right:
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}
//-->
</script>
```{r}
1:10
```
<a onclick="toggle_visibility('answer_1');"><b><u>Antwort anzeigen</b></u></a>
<div id="answer_1" style=display:none>
```{r}
1:10
```
</div>
What I did now was following darozcig’s advice and I used JS. This solution seems tedious though. Something easier neatly fitting knitr would be nicer! Below my complete .Rmd script.