It's not a bug. This is by design. Markdown lets you skip having to maintain the sequential order of a numbered list. You can just number everything as "1.", and then let the engine figure out the actual order when it renders it. (Open the source of this answer to see an example!)
There is one additional quirk: Stack Overflow Markdown lets you start the list with any number you want.
That's why your list began with "2." (because that's what you started numbering with), and then why the next item was numbered "3." (because that's the next cardinal number after 2).
There are two possible workarounds to avoid this and get exactly the numbers you want in the list, both of which have been demonstrated by edits to your question:
Escaping the number, like so: 2\.
This lets you use any arbitrary sequence of numbers that you like, but with the drawback of it no longer being an actual list. (In other words, it doesn't get rendered as an <ol>
in the resulting HTML.)
Inserting an HTML comment after the list item, which breaks up the list into multiple, separate and distinct lists.
This is a bit less obvious and less discoverable, but it works nicely, especially paired with the fact that you are allowed to start a list's numbering with any number you want.
Interestingly, this very topic is covered as part of the discussion in the original introduction of Markdown, by John Gruber.
<!-- -->
) between them. See this revision. Alternatively, use actual HTML, e.g.<ol> <li>
…</li>
…</ol>
,<blockquote>
…</blockquote>
, etc.