WiSeeker WiSeeker - 12 days ago 6
Markdown Question

How to nest code block under a list item in BitBucket mark down?

While there are several questions/answers with combination of keywords from this question, I don't see one that directly asks the same question or answers it.

I want to nest a code block under a list item. When I follow this answer, I don't quite get the effect I'm looking for. In below image, I wouldn't want the leading spaces in the code block and I would like the box itself to be indented under the list item. How do I achieve this?

enter image description here

And, here is the actual MD:

** Help Page **

* This is a list item that has a code block going with it

```
#!c#
try
{
DoSomething(passThis, andThis);
}
catch (Exception ex)
{
ex.Log();
}

```

Answer

Instead of a fenced code block (```), use an indented code block. Indent with four spaces to nest inside the list item, and four more to represent a code block:

**Help Page**

* This is a list item that has a code block going with it

        #!c#
        try
        {
            DoSomething(passThis, andThis);
        }
        catch (Exception ex)
        {
            ex.Log();
        }
Comments