在 R markdown 中创建括号内的文本(在项目符号列表中)

Create bracketed text in R markdown (in a bulleted list)

在普通的 Markdown 中,我可以通过简单地在单词周围放置方括号来将单词 "purple" 括起来,就像这样 [purple]。这也适用于 R Markdown。

但是我有一个独特的 R Markdown 情况。让我们描述一下:

  1. 我已将 "Purple" 一词括在项目符号列表中。
  2. 我还有标题为 "Purple" 的标题。
---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

<!-- Line 10 is directly below this. This is line 9. -->
* [Purple] blue red  

* \[Purple\] blue red  

** \[Purple\] blue red  

### Purple

Purple blue red.

因此:

  1. R Markdown 将我方括号中的 [紫色] 链接到文档中更下方的标题。

不是将单词 "purple" 链接到下面的标题,而是如何在 R Markdown 文档的第 10 行获取以下内容(根本没有任何链接):

  • [Purple] blue red

我的转义尝试似乎生成了 LaTeX 输出,我还假设这一切都可能是普通 Markdown 中的问题,而不仅仅是 R Markdown(只是猜测)。

您可以使用 HTML 括号。 &#91;&#93; 对于 []

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

<!-- Line 10 is directly below this. This is line 9. -->
* [Purple] blue red  

* \[Purple\] blue red  
* Purple blue red  
* Purple blue red  
* Purple blue red  

<!-- SOLUTION LINE BELOW -->

* &#91;Purple&#93; blue red

### Purple

Purple blue red.

产量

转义 [],但不能同时转义两者,因为如果同时转义,它恰好是内联数学表达式的语法,如果两者都不转义,则恰好是链接到章节标题的语法。

---
title: "Untitled"
output: html_document
---

* [Purple\] blue red  

* \[Purple] blue red  

### Purple

Purple blue red.