简体   繁体   中英

How to display ``` in knitr chunks?

I'm generating a knitr (focusing on .Rmd files) manual for a project and wanted to embed a code chunk that actually displays the " ``` " marks as well as the internal chunk syntax. Eg

``` {r sample, eval= FALSE}

Code example

```

So basically the exact visual you see above. Any thoughts on how to do this?

You can do this by using four spaces before your code as follows:

So this:

在此输入图像描述

Becomes this:

在此输入图像描述

There also is this SO-meta discussion on how to escape this backtick in Markdown

如果你的意思是如何显示三个反引号,答案是“缩进4个空格”(参见Pandoc的四空间规则 )“。如果你的意思是如何显示一个文字编织代码块,答案是由knitr FAQ给出的# 8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM