In my Rmarkdown file, there are some special characters I don't want to escape in the chunks (e.g. <
and >
).
This is a minimum example to show my problem.
title: "test-special-character"
output: md_document
date: "2022-12-02"
---
```{r test-special-character, results='asis'}
cat("<$htmlwidgets />")
```
The output in the md file is
<$htmlwidgets />
What I expect is
<$htmlwidgets />
So my question is how I should not escape the special character in the Rmarkdown file.
I am using R 4.2.0 in Windows 10 with knitr 1.39 and rmarkdown 2.14.
CodePudding user response:
If you do not have to use cat
, you could try this
```{r, results='asis'}
knitr::raw_html(glue::glue("<$htmlwidgets />"))
```