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

期望的输出:

1. item 1
2. item 2

```
Code block
```

3. item 3

产生的输出:

第一项 第二项

代码块

项目3


当前回答

我在Github上解决了这个问题,用换行符分隔缩进的子块,例如,你写项目1,然后按enter两次(就像它是一个新的段落),缩进块,写你想要的(代码块,文本等)。关于Markdown列表和Markdown换行符的更多信息。

例子:

项目一个 两个项 这个块作为一个新的段落,上面有一个空行 项目三 其他代码 项目四

其他回答

如果你想让文本与前一个列表项对齐,但又避免“大”换行,请在列表项的末尾使用两个空格,并将文本缩进一些空格。

来源:(点为空格;-)当然)

1.·item1··
····This is some text
2.item2

结果:

item1 这是一些文本 第二条

我在Github上解决了这个问题,用换行符分隔缩进的子块,例如,你写项目1,然后按enter两次(就像它是一个新的段落),缩进块,写你想要的(代码块,文本等)。关于Markdown列表和Markdown换行符的更多信息。

例子:

项目一个 两个项 这个块作为一个新的段落,上面有一个空行 项目三 其他代码 项目四

如果您不希望列表项之间的行缩进,就像用户Mars在评论中提到的那样,您可以使用pandoc的example_lists特性。医生说:

(@)  My first example will be numbered (1).
(@)  My second example will be numbered (2).

Explanation of examples.

(@)  My third example will be numbered (3).

注意在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代码。不需要保存;)

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

1. item 1
2. item 2

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

生产:

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