15

我在 Bitbucket 上为我的 README.md 使用 Markdown,并在代码块后实现我的有序列表重新启动到 1。这是我的文本示例:

1. Download VirtualBox
2. Download Vagrant
3. Clone the repository

> git clone URL

4. Go to repository folder

> cd /my_repo

5. Setup your dev environment

数字 4 和 5 都1.在我的 README 中,这不是我想要的。也许我应该使用 `` 代替?结果不会是相同的样式,但如果我的列表保留编号,至少会更好。

有什么解决办法吗?

4

4 回答 4

15

在块引用之前插入 4 个空格>。这同时有两个目的:首先,它缩进引号,因此它与上面的数字对齐(因为它该编号项目的一部分)。其次,大多数 MD 解析器都知道这意味着缩进的项目不应该打断编号列表。

实际上,我认为使用“块引用”是错误的。也许您应该在这里使用常规缩进的“代码”,在您的文字代码周围使用 4 个空格和反引号:

  1. 克隆存储库

    git clone URL

(命令行周围有四个空格和`。)

于 2013-11-13T22:52:35.220 回答
7

一个更好的答案,一般结构应该是这样的:

1. item n.1
2. item n.2

        #!json
        {
            "key": "value"
        }

3. item n.3

所以:

  1. 在代码块之前和之后放置一个空行。
  2. 用 8 个空格缩进所有内容;代码块前后不需要 3 个反引号。
  3. 如果您想要语法高亮,#!<language-name>请在代码块之前缩进 8 个空格。

Bitbucket 将尊重列表编号,并且您不会丢失语法突出显示。

于 2018-04-12T05:43:05.473 回答
0

要扩展@Willian 的解决方案,请尝试将代码缩进 8 个空格,这似乎启用了基本的块突出显示,而不是代码语法。此外,如果您在代码之前嵌套了一些项目符号,它将不起作用。就像您在代码之前的 #3 下嵌套了几个项目符号一样。

1. First item
2. Second Item
3. Some code example:  

        var a = "Some string";
        function test() {
            return a + "/n";
        }

4. Forth item
于 2020-04-03T18:34:04.120 回答
0

只是为了总结上面对在 BitBucket 上遇到此问题的用户的评论,这是我为我的 nodejs/express 项目使用 README.md 样板的代码片段:

**Instructions**

1. Clone the git repo from BitBucket

    ```
    cd *Install_Directory*
    git clone https://user@bitbucket.org/user/repo.git
     ```

2. Install/upgrade required npm modules

    ```
     npm update
     ```

3. Run

    ```
    node server.js
    (or)
    nodemon
    ```

4. View tracking dashboard by visiting http://localhost:9988/

为了完整起见,这里是使用 StackOverflow 的 markdown 解析器的输出:

指示

  1. 从 BitBucket 克隆 git 存储库

    cd *Install_Directory*
    git clone https://user@bitbucket.org/user/repo.git
    
  2. 安装/升级所需的 npm 模块

     npm update
    
  3. node server.js
    (or)
    nodemon
    
  4. 通过访问http://localhost:9988/查看跟踪仪表板

于 2019-09-01T18:57:09.197 回答