Dachmt
Dachmt

Reputation: 2099

Bitbucket README markdown ordered list restarts after code block

I'm using Markdown for my README.md on Bitbucket and realize my ordered list restart to 1 after a code block. Here is an example of my text:

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

The number 4 and 5 are both 1. in my README, which is not what I want. Maybe should I use the `` instead? The result won't be the same style but if my list keep the numbering it would be better at least.

Any solutions?

Upvotes: 15

Views: 4741

Answers (4)

BatteryAcid
BatteryAcid

Reputation: 8881

To expand on @Willian's solution, try to just indent the code 8 spaces, it seems to enable basic block highlighting, not code syntax. Also, it won't work if you have some bullets nested before the code. Like if you had a couple bullets nested under #3 before the code.

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

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

4. Forth item

Upvotes: 0

Eric Kigathi
Eric Kigathi

Reputation: 2031

Just to summarize the comments above for users running into this issue on BitBucket here's a snippet of code that I use a README.md boilerplate for my nodejs/express projects that works:

**Instructions**

1. Clone the git repo from BitBucket

    ```
    cd *Install_Directory*
    git clone https://[email protected]/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/

And for completeness here's the output using StackOverflow's markdown parser:

Instructions

  1. Clone the git repo from BitBucket

    cd *Install_Directory*
    git clone https://[email protected]/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/

Upvotes: 0

Willian Mitsuda
Willian Mitsuda

Reputation: 1268

An even better answer, the general structure should be like this:

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

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

3. item n.3

So:

  1. Put a blank line before and after your code block.
  2. Indent everything with 8 spaces; no need to 3 backticks before and after the code block.
  3. If you want syntax highlighting, put a #!<language-name> indented with 8 spaces before your code block.

Bitbucket will respect the list numbering and you won't lose the syntax highlighting.

Upvotes: 7

Jongware
Jongware

Reputation: 22478

Insert 4 spaces before the blockquotes >. This serves two purposes at once: first, it indents the quote, so it aligns with the number above it (as it is part of that numbered item). Second, most MD parsers know this means the indented item should not interrupt the numbered list.

Actually, I think you're wrong to use a "block quote". Maybe you should use a regular indented 'code' here, using 4 spaces and backticks around your literal code:

  1. Clone the repository

    git clone URL

(Four spaces and ` around the command line.)

Upvotes: 15

Related Questions