How to render backticks in HTML inside a code chunk in rmarkdown?

Viewed 171

In a .rmd file (output type = html document), I'm trying to render a HTML string containing a backtick (``) in a r code block, like in the following example:

```{r}
htmltools::HTML('<b>LEFT`RIGHT</b>')
```

When I try to knit this, I get the following output: The HTML string is not rendered correctly

Instead, I want to display LEFT`RIGHT. How do I do it?

I am aware that in this simple case I could just include the HTML in the .rmd instead of passing it to htmltools::HTML inside a code block, but for my actual use case, the HTML is inside a parameter, i.e. instead of HTML('<b>LEFT``RIGHT</b>') I have the parameter params$query, which i pass to the .rmd file via rmarkdown::render. Therefore it has to be included in a r code block to be parsed.

0 Answers
Related