Search code examples
pythonmarkdownmkdocs

Syntax highlighted code block in markdown indented list paragraph


Markdown lets me indent a paragraph twice under a list item to make it part of that list.

1. List item

    Paragraph will be rendered inside of list item.

2. Other list item

    Other paragraph.

        This would be code.

3. But what about syntax highlighted code?

    ```bash
    echo "This won't work"
    ```

I can also indent twice as much to make code blocks.

BUT how do I use syntax highlighted code blocks such as these inside a list paragraph? Is it at all possible?

In my situation I'm using mkdocs, a python static HTML generator using markdown.

Background on why I'm asking is because such lists actually make for a really nice design when you're writing step by step guides.


Solution

  • What about this:

    3. But what about syntax highlighted code?
    
    ~~~~ bash
    echo "This won't work"
    ~~~~
    

    It renders like this in Firefox (using Stackedit):

    enter image description here