Highlight Bash/shell code in Markdown files

后端 未结 7 2054
猫巷女王i
猫巷女王i 2021-01-29 17:35

How can I highlight the Bash/shell commands in Markdown files?


For example, to highlight js, I write:



        
7条回答
  •  死守一世寂寞
    2021-01-29 17:45

    Using the knitr package:

    ```{r, engine='bash', code_block_name} ...
    

    E.g.:

    ```{r, engine='bash', count_lines}
    wc -l en_US.twitter.txt
    ```
    

    You can also use:

    • engine='sh' for shell
    • engine='python' for Python
    • engine='perl', engine='haskell' and a bunch of other C-like languages and even gawk, AWK, etc.

提交回复
热议问题