问题
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?
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();
}
```
回答1:
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();
}
来源:https://stackoverflow.com/questions/40707725/how-to-nest-code-block-under-a-list-item-in-bitbucket-mark-down