Perhaps this is a known issue. You can't put a codeblock directly after a list, even separated with line breaks. It came up in this question, where I finally just added a colon between the list and codeblock so that it would look right.

Here's a list:

  1. First line
  2. Second line

    This should be a code block, check the markdown!

(there needs to be at least one normal character in this line, or the next codeblock won't render either. Line breaks don't do it)

This is also a codeblock


I see that this has been discussed on meta.stackexchange.com; here and here are two examples. I don't see anything indicating that this behaviour will change.

But there are some good workarounds in those answers. My preference is to use


or a blank html comment

<!-- -->

as a separator.

  • \$\begingroup\$ Interesting - have you seen if this has been reported on meta.stackexchange.com ? \$\endgroup\$
    – W5VO
    Mar 2, 2017 at 15:34
  • \$\begingroup\$ No, I haven't looked, sorry. It'll be about an hour before I can search around :) \$\endgroup\$
    – bitsmack
    Mar 2, 2017 at 15:36
  • \$\begingroup\$ Sometimes it's useful to put a horizontal rule (a line with just --- on it in Markdown) right before a code block, as a separator. \$\endgroup\$
    – Dave Tweed
    Mar 2, 2017 at 17:19
  • \$\begingroup\$ @W5VO It turns out that is has been discussed on meta.stackexchange.com. I've included info in my post and also removed the [bug] tag. Thanks! \$\endgroup\$
    – bitsmack
    Mar 2, 2017 at 17:34
  • \$\begingroup\$ Thanks, @DaveTweed. I was editing my question as you posted your answer. I like the horizontal rule solution, and there were additional workarounds that I mentioned in my edit. Take care! \$\endgroup\$
    – bitsmack
    Mar 2, 2017 at 17:36

1 Answer 1


I think the issue is that Markdown considers any indented line to be part of the previous list item; this is a feature, not a bug. It gets indented to match the list indentation, but it doesn't get rendered in code font. A horizontal rule can fix this, and probably looks better than other options:

  1. List item

    Second paragraph for list item #1

  2. List item

    Second paragraph of list item #2

Code block

In Markdown, the horizontal rule is a blank line followed by a line containing just ---.

Nested lists:

  • Top item A

    1. 2nd-level item
    2. 2nd-level item

      text for 2nd level requires 5 spaces of indentation

    more text for 1st level

  • Top item B

In any case, it's definitely quirky!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .