Search code examples
markdownbitbucketwiki

How can I add code to a numeric list's item without breaking the numbering?


I'm trying to add code to a numeric list in Markdown (in the wiki of a BitBucket repository), but it break the numbering of the list: in the example below, item 3 starts with a 1.

1. item one

    text

2. item two

    text

```
#!ini
     code
```

3. item 3

enter image description here


Solution

  • Get rid of the backticks and simply indent your code by 4*(n+1) spaces, where n is the nesting level. In this case, the nesting level is 1, so you have to indent your code by 8 spaces.

    1. item one
    
        text
    
    2. item two
    
        text
    
            #!ini
            code
    
    3. item 3
    

    Test in the wiki of a BitBucket repo

    The output is as desired:

    enter image description here