I\'m trying to generate an HTML report using RStudio, R Markdown and knitr. In the report I would like to display some bash
code. I do not want to run the code
The default syntax highlighting theme does not work well for non-R code chunks, and you can use other themes, e.g. pygments
---
title: "Bash Highlighting"
output:
html_document:
highlight: pygments
---
```{r, engine = 'bash', eval = FALSE}
for foo in (ls bar)
do
echo $foo
done
```
OK, figured it out thanks to the comments. It seems it's RStudio
which is not playing nice with the highlighting. When I keep the intermediate markdown file as in.md
:
---
title: "Bash Highlighting"
output:
html_document:
keep_md: true
---
```{r, engine = 'bash', eval = FALSE}
for foo in (ls bar)
do
echo $foo
done
```
then convert to html with pandoc
using e.g. the CSS from BioConductor:
pandoc -s in.md \
-c https://hedgehog.fhcrc.org/bioconductor/branches/RELEASE_3_1/madman/Rpacks/BiocStyle/inst/resources/html/bioconductor.css \
-t html -o out.html
I get nice code highlighting for R
and bash
.
Thanks!