Highlighting bash code with knitr / rmarkdown

前端 未结 2 1772
春和景丽
春和景丽 2020-12-31 14:20

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

2条回答
  •  臣服心动
    2020-12-31 14:41

    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
    ```
    

提交回复
热议问题