This is a status-bydesign issue because the code is being placed after a bullet list.
There is a Meta Stack Exchange post that deals with how to bypass the issue.
There are several ways to work around it, but I updated the answer to use 8 spaces instead of the standard 4 spaces for code and it now is displaying properly.
I ran your post through MarkdownSharp and the tilde was not encoded during the rendering from markdown to HTML. So the problem is likely elsewhere on the server side. Hopefully an SO dev will come along and check on this. The tilde doesn't need to be encoded in a URI, since it's an unreserved character.
The live preview (when editing) is not affected by ...
Thanks for reporting. This is indeed an issue around markdown rendering. We're using two different markdown renderers - markdown-it for the client-side preview and Markdig for server-side processing. Both are processing the formatting you've given differently.
It seems like the specific formatting you're giving is interpreted quite ambiguously among ...
The short answer is "so the parser can pick up what you intend"
The longer answer involves experimentation with regexes. I really don't think that's necessary.
Here's your basic rule of thumb: HTML doesn't care about whitespace, and neither should you (except when it's used as the four spaces to indicate indentation but that isn't whitespace, that's ...