【问题标题】:Including git code in the rmarkdown documents while using bookdown使用 bookdown 时在 rmarkdown 文档中包含 git 代码
【发布时间】:2017-08-20 18:22:57
【问题描述】:

在使用bookdown 包创作书籍时,是否可以在Rmarkdown 文档中包含不同语言的代码?我查看了knitr 选项,例如engine,可能的值有python、awk/gawk,并且可以使用engine.path 设置可执行路径。

```{r, engine='python'}
print "Will this code chunk be hidden?"
```

但是,我只想在 Rmarkdown 文档中插入代码(例如:git)而不执行它。

例如,像在markdown文档中包含

```git
git init
```

【问题讨论】:

    标签: r r-markdown bookdown


    【解决方案1】:

    如果你不希望代码被执行,你可以像这样嵌入它:

    ```
    code not executed
    ```
    

    您还可以使用特定语言突出显示代码:

    ```css
    my_css{}
    
    ```
    

    对于您的 git 命令,这是从终端执行的,因此您可以使用以下命令突出显示它:

    ```sh
    git init
    ```
    

    【讨论】:

    • 感谢您指出我的问题本身存在的答案。
    • 好吧,最后,我不确定您真正在寻找什么,因为您在我回答问题时编辑了您的问题。但我想这就是答案……
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 1970-01-01
    • 2018-12-10
    • 2016-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多