In Rmarkdown
, how can I implement/evaluate some HTML
code stored in an R
character object?
If I explicitly paste the code as plain text, it works as expected e.g. <details><summary>Show/hide.</summary>SomeText</details>
.
However, I need to evaluate this from an R object; e.g. how to evaluate the content of the Text
object: Text <- '<details><summary>Show/hide.</summary>SomeText</details>'
?
Below is a reprex.
Thanks, Ahmed
---
title: "Literature notes"
output:
html_document:
#code_folding: hide
---
<details><summary>Show/hide.</summary>SomeText</details> # This works
```{r, eval=TRUE, echo=F}
Text <- '<details><summary>Show/hide.</summary>SomeText</details>'
Text
## how to do the same using info stored in 'Text' object
```
CodePudding user response:
You can use results='asis'
in the code chunk:
---
title: "Literature notes"
output:
html_document:
#code_folding: hide
---
```{r, eval=TRUE, echo=F, results='asis'}
Text <- '<details><summary>Show/hide.</summary>SomeText</details>'
cat(Text)
``