How do I add javascript code to a Rmd?
I'm using the following chunk options:
```{r engine = 'js', results='asis', echo = T, highlight = T}
var i = 1 + 1;
```
And this produces a .md with:
<script type="text/javascript">
var i = 1 + 1;
</script>
I would like to have something like:
```js
var i = 1 + 1;
```
<script type="text/javascript">
var i = 1 + 1;
</script>
In other words, I don't need the code to be evaluated when knitting, I just need that highlighted code appears in the output.
As of knitr v1.16.5, this is the default behavior, i.e. the JS code will be echoed by default. This will work out of the box:
```{js}
var i = 1 + 1;
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With