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();
}
```
To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input: This is a normal paragraph: This is a code block. A code block continues until it reaches a line that is not indented (or the end of the article).
Bitbucket can parse and display Markdown, reStructuredText, Textile, and plain text README files. With a syntax like Markdown, you can emphasize text, include screen captures, and more.
Depending on your Markdown processor or editor, you'll use three backticks ( ``` ) or three tildes ( ~~~ ) on the lines before and after the code block.
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();
}
Note that the language tag here should be #!c
, not #!c#
as in your question.
Alternatively, you can use a fenced code block but it must still be indented by four spaces so it gets included in the list item:
**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();
}
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With