Search code examples
markdownoctopresskramdown

Markdown: code snippets in the ordered list


I am using Octopress to generate static html-pages with markdown. What I want to do is to embed Pygments-highlighted code blocks inside of an ordered list. To include non-highlited code block into ordered list one can do the following:

1.  list item 1
    its description
        code block here
2.  list item 2
    its description
        code block

And markdown understand it correctly. But what if I want to include code snippet into ordered list? I am trying this:

1.  list item 1
    its description

    ```
    code block here
    ````

2.  list item 2
    its description

    ```
    code block
    ```

But this way code block is not recognized. Moving backticked code block to the left or to the right doesn't help. If I move it to the left, code block will be highlighted but the next number of a list will be «1», so, it will be a new list.

How can I solve this problem? By the way I am using kramdown, but I didn't get it to work neither with markdown nor with kramdown.


Solution

  • In Kramdown you have to use tildes for fenced code blocks (while other markdown implementations support backticks as well):

    1.  list item 1
        its description
    
        ~~~
        code block here
        ~~~