Hi,
I think the question is relatively straightforward; I want to be able to write an R function that can be included in a code chunk in a R Markdown document; and the function should be able to return code in another language (e.g. HTML, LaTeX, markdown) which is then rendered as that code, and not just returned as R output.
For example, if rendering an html_document:
---
output: html_document
---
```{r}
foo <- function(text){
x <- glue::glue('<strong>{text}</strong>')
x
}
```
```{r}
foo('Here is my text')
htmltools::tag('strong', 'Here is my text')
```
When executed, the output from function foo() is returned as verbatim output
## <strong>Here is my text</strong>
While the htmltools function returns Here is my text
I have tried looking through the source code of htmltools to determine why its output gets rendered as HTML and my toy function simply treated as console output. Any insights?