visual editor – Stop removing whitespace in markdown code blocks?

I want to store my posts in plaintext markdown instead of HTML. I have started by following Store post in raw markdown format, no html?, and as a result I do get what seems like a plain text box as my editor. However, when I hit update, the spaces that I indent code blocks with are being removed (as described here).

With trial and error, I concluded that when I remove the recommended add_filter( 'user_can_richedit', '__return_false', 50 ), the spaces are no longer removed (while yes, I do revert back to the rich editor – which contradicts the whole markdown idea).

I found several solutions that don’t work for me (or at all):