在下面的降价代码中,我希望项目3从列表3开始。但由于markdown之间的代码块将此列表项作为一个新列表启动。有没有办法防止这种行为?

期望的输出:

1. item 1
2. item 2

```
Code block
```

3. item 3

产生的输出:

第一项 第二项

代码块

项目3


当前回答

您可以尝试在句点(1\)之前添加反斜杠(\)。Item 1),它禁用列表自动编号。注意:这将消除左侧缩进。

1. 第一项

def call_of_duty()
   return press_f()

3.项目3

print("fus ro dah")

7. 项目7

print("Omae Wa Mou Shindeiru")

10. 10项


链接来源:

3\. Put on shoes
2\. Open door
1\. Step outside

renders

3. Put on shoes
2. Open door
1. Step outside

其他回答

我的解决办法很简单:不要用点空格。

e.g.

1.apple

2.banana

3.cherry

4.drone

生产:

1.苹果

2.香蕉

3.樱桃

4.无人机

在项目符号之间使用四个空格缩进内容

1. item 1
2. item 2

    ```
    Code block
    ```
3. item 3

生产:

第一项 第二项 代码块 项目3

您可以尝试在句点(1\)之前添加反斜杠(\)。Item 1),它禁用列表自动编号。注意:这将消除左侧缩进。

1. 第一项

def call_of_duty()
   return press_f()

3.项目3

print("fus ro dah")

7. 项目7

print("Omae Wa Mou Shindeiru")

10. 10项


链接来源:

3\. Put on shoes
2\. Open door
1\. Step outside

renders

3. Put on shoes
2. Open door
1. Step outside

注意在Macmade的解决方案中,你可以在“代码块”上方看到额外的一行代码。

这里有两个更好的解决方案:

Indent the code block by an extra 4 spaces (so usually 8, in this nested list example, 12). This will put the code in a <pre> element. On SO, you can even specify syntax highlight with a <!-- language: lang-js --> indented by 4 spaces (+1 here due to the nested list). item 1 item 2 Code.block('JavaScript', maybe)? item 3 Or, just put the Code block within backticks and indent by 4 spaces (here, 1 extra because of the nested list). You'll get a regular indented text paragraph, with a <code> element inside it. This one you can't syntax-highlight: item 1 item 2 Code block item 3

注意:你可以在这个答案上点击“编辑”来查看底层Markdown代码。不需要保存;)

将列表数字放在括号中,而不是后面跟着句号。

(一)第一项 (二)第二项 代码块 (三)第三项